~mysql/mysql-server/mysql-6.0

« back to all changes in this revision

Viewing changes to sql/sql_show.cc

  • Committer: monty at mysql
  • Date: 2002-07-23 15:31:22 UTC
  • mto: (1110.1.7)
  • mto: This revision was merged to the branch mainline in revision 1116.
  • Revision ID: sp1r-monty@mashka.mysql.fi-20020723153122-09736
New SET syntax & system variables.
Made a some new buffers thread specific and changeable.
Resize of key_buffer.
AUTO_COMMIT -> AUTOCOMMIT
Fixed mutex bug in DROP DATABASE
Fixed bug when using auto_increment as second part of a key where first part could include NULL.
Split handler->extra() to extra() and extra_opt() to be able to support thread specific buffers.
Don't write message to error log when slave reconnects becasue of timeout.
Fixed possible update problem when using DELETE/UPDATE on small tables
(In some cases we used index even if table scanning would be better)
A lot of minior code cleanups

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
        (grant_option && !check_grant_db(thd, file_name)))
85
85
    {
86
86
      thd->packet.length(0);
87
 
      net_store_data(&thd->packet, thd->convert_set, file_name);
 
87
      net_store_data(&thd->packet, thd->variables.convert_set, file_name);
88
88
      if (my_net_write(&thd->net, (char*) thd->packet.ptr(),
89
89
                       thd->packet.length()))
90
90
        DBUG_RETURN(-1);
102
102
{
103
103
  List<Item> field_list;
104
104
  OPEN_TABLE_LIST *open_list;
105
 
  CONVERT *convert=thd->convert_set;
 
105
  CONVERT *convert=thd->variables.convert_set;
106
106
  DBUG_ENTER("mysqld_show_open_tables");
107
107
 
108
108
  field_list.push_back(new Item_empty_string("Database",NAME_LEN));
161
161
  while ((file_name=it++))
162
162
  {
163
163
    thd->packet.length(0);
164
 
    net_store_data(&thd->packet, thd->convert_set, file_name);
 
164
    net_store_data(&thd->packet, thd->variables.convert_set, file_name);
165
165
    if (my_net_write(&thd->net,(char*) thd->packet.ptr(),thd->packet.length()))
166
166
      DBUG_RETURN(-1);
167
167
  }
257
257
  char *file_name;
258
258
  TABLE *table;
259
259
  String *packet= &thd->packet;
260
 
  CONVERT *convert=thd->convert_set;
 
260
  CONVERT *convert=thd->variables.convert_set;
261
261
  DBUG_ENTER("mysqld_extend_show_tables");
262
262
 
263
263
  (void) sprintf(path,"%s/%s",mysql_data_home,db);
433
433
  handler *file;
434
434
  char tmp[MAX_FIELD_WIDTH];
435
435
  Item *item;
436
 
  CONVERT *convert=thd->convert_set;
 
436
  CONVERT *convert=thd->variables.convert_set;
437
437
  DBUG_ENTER("mysqld_show_fields");
438
438
  DBUG_PRINT("enter",("db: %s  table: %s",table_list->db,
439
439
                      table_list->real_name));
549
549
mysqld_show_create(THD *thd, TABLE_LIST *table_list)
550
550
{
551
551
  TABLE *table;
552
 
  CONVERT *convert=thd->convert_set;
 
552
  CONVERT *convert=thd->variables.convert_set;
553
553
  DBUG_ENTER("mysqld_show_create");
554
554
  DBUG_PRINT("enter",("db: %s  table: %s",table_list->db,
555
555
                      table_list->real_name));
637
637
{
638
638
  TABLE *table;
639
639
  char buff[256];
640
 
  CONVERT *convert=thd->convert_set;
 
640
  CONVERT *convert=thd->variables.convert_set;
641
641
  DBUG_ENTER("mysqld_show_keys");
642
642
  DBUG_PRINT("enter",("db: %s  table: %s",table_list->db,
643
643
                      table_list->real_name));
768
768
int
769
769
mysqld_dump_create_info(THD *thd, TABLE *table, int fd)
770
770
{
771
 
  CONVERT *convert=thd->convert_set;
 
771
  CONVERT *convert=thd->variables.convert_set;
772
772
  DBUG_ENTER("mysqld_dump_create_info");
773
773
  DBUG_PRINT("enter",("table: %s",table->real_name));
774
774
 
1018
1018
  Item *field;
1019
1019
  List<Item> field_list;
1020
1020
  I_List<thread_info> thread_infos;
1021
 
  ulong max_query_length= verbose ? max_allowed_packet : PROCESS_LIST_WIDTH;
1022
 
  CONVERT *convert=thd->convert_set;
 
1021
  ulong max_query_length= (verbose ? thd->variables.max_allowed_packet :
 
1022
                           PROCESS_LIST_WIDTH);
 
1023
  CONVERT *convert=thd->variables.convert_set;
1023
1024
  DBUG_ENTER("mysqld_list_processes");
1024
1025
 
1025
1026
  field_list.push_back(new Item_int("Id",0,7));
1143
1144
 
1144
1145
 
1145
1146
int mysqld_show(THD *thd, const char *wild, show_var_st *variables,
1146
 
                struct system_variables *values)
 
1147
                enum enum_var_type value_type)
1147
1148
{
1148
 
  uint i;
1149
1149
  char buff[8192];
1150
1150
  String packet2(buff,sizeof(buff));
1151
1151
  List<Item> field_list;
1152
 
  CONVERT *convert=thd->convert_set;
 
1152
  CONVERT *convert=thd->variables.convert_set;
1153
1153
  ulong offset;
1154
1154
 
1155
1155
  DBUG_ENTER("mysqld_show");
1160
1160
 
1161
1161
  /* pthread_mutex_lock(&THR_LOCK_keycache); */
1162
1162
  pthread_mutex_lock(&LOCK_status);
1163
 
  for (i=0; variables[i].name; i++)
 
1163
  for (; variables->name; variables++)
1164
1164
  {
1165
 
    if (!(wild && wild[0] && wild_case_compare(variables[i].name,wild)))
 
1165
    if (!(wild && wild[0] && wild_case_compare(variables->name,wild)))
1166
1166
    {
1167
1167
      packet2.length(0);
1168
 
      net_store_data(&packet2,convert,variables[i].name);
1169
 
      switch (variables[i].type){
 
1168
      net_store_data(&packet2,convert,variables->name);
 
1169
      SHOW_TYPE show_type=variables->type;
 
1170
      char *value=variables->value;
 
1171
      if (show_type == SHOW_SYS)
 
1172
      {
 
1173
        show_type= ((sys_var*) value)->type();
 
1174
        value=     ((sys_var*) value)->value_ptr(thd, value_type);
 
1175
      }
 
1176
 
 
1177
      switch (show_type) {
1170
1178
      case SHOW_LONG:
1171
1179
      case SHOW_LONG_CONST:
1172
 
        net_store_data(&packet2,(uint32) *(ulong*) variables[i].value);
1173
 
        break;
1174
 
      case SHOW_LONG_OFFSET:
1175
 
        offset= (ulong) variables[i].value;
1176
 
        net_store_data(&packet2,
1177
 
                       (uint32) *(ulong*) (((char*) values) + offset));
1178
 
        break;
 
1180
        net_store_data(&packet2,(uint32) *(ulong*) value);
 
1181
        break;
 
1182
      case SHOW_LONGLONG:
 
1183
        net_store_data(&packet2,(longlong) *(longlong*) value);
 
1184
        break;
1179
1185
      case SHOW_BOOL:
1180
 
        net_store_data(&packet2,(ulong) *(bool*) variables[i].value ?
1181
 
                       "ON" : "OFF");
 
1186
        net_store_data(&packet2,(ulong) *(bool*) value ? "ON" : "OFF");
1182
1187
        break;
1183
1188
      case SHOW_MY_BOOL:
1184
 
        net_store_data(&packet2,(ulong) *(my_bool*) variables[i].value ?
1185
 
                       "ON" : "OFF");
1186
 
        break;
1187
 
      case SHOW_MY_BOOL_OFFSET:
1188
 
        offset= (ulong) variables[i].value;
1189
 
        net_store_data(&packet2,
1190
 
                       ((ulong) *(my_bool*) (((char*) values) + offset)) ?
1191
 
                       "ON" : "OFF");
 
1189
        net_store_data(&packet2,(ulong) *(my_bool*) value ? "ON" : "OFF");
1192
1190
        break;
1193
1191
      case SHOW_INT_CONST:
1194
1192
      case SHOW_INT:
1195
 
        net_store_data(&packet2,(uint32) *(int*) variables[i].value);
1196
 
        break;
1197
 
      case SHOW_INT_OFFSET:
1198
 
        offset= (ulong) variables[i].value;
1199
 
        net_store_data(&packet2,
1200
 
                       (uint32) *(int*) (((char*) values) + offset));
 
1193
        net_store_data(&packet2,(uint32) *(int*) value);
1201
1194
        break;
1202
1195
      case SHOW_HAVE:
1203
1196
      {
1204
 
        SHOW_COMP_OPTION tmp= *(SHOW_COMP_OPTION*) variables[i].value;
 
1197
        SHOW_COMP_OPTION tmp= *(SHOW_COMP_OPTION*) value;
1205
1198
        net_store_data(&packet2, (tmp == SHOW_OPTION_NO ? "NO" :
1206
1199
                                  tmp == SHOW_OPTION_YES ? "YES" :
1207
1200
                                  "DISABLED"));
1208
1201
        break;
1209
1202
      }
1210
1203
      case SHOW_CHAR:
1211
 
        net_store_data(&packet2,convert, variables[i].value);
 
1204
        net_store_data(&packet2,convert, value);
1212
1205
        break;
1213
1206
      case SHOW_STARTTIME:
1214
1207
        net_store_data(&packet2,(uint32) (thd->query_start() - start_time));
1232
1225
        net_store_data(&packet2,(uint32) cached_tables());
1233
1226
        break;
1234
1227
      case SHOW_CHAR_PTR:
1235
 
        {
1236
 
          char *value= *(char**) variables[i].value;
1237
 
          net_store_data(&packet2,convert, value ? value : "");
1238
 
          break;
1239
 
        }
 
1228
      {
 
1229
        value= *(char**) value;
 
1230
        net_store_data(&packet2,convert, value ? value : "");
 
1231
        break;
 
1232
      }
1240
1233
#ifdef HAVE_OPENSSL
1241
1234
        /* First group - functions relying on CTX */
1242
1235
      case SHOW_SSL_CTX_SESS_ACCEPT:
1393
1386
        break;
1394
1387
 
1395
1388
#endif /* HAVE_OPENSSL */
 
1389
      case SHOW_UNDEF:                          // Show never happen
 
1390
      case SHOW_SYS:
 
1391
        net_store_data(&packet2, "");           // Safety
 
1392
        break;
1396
1393
      }
1397
1394
      if (my_net_write(&thd->net, (char*) packet2.ptr(),packet2.length()))
1398
1395
        goto err;                               /* purecov: inspected */