~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/sql_show.cc

  • Committer: Jay Pipes
  • Date: 2008-07-17 19:43:08 UTC
  • mto: This revision was merged to the branch mainline in revision 182.
  • Revision ID: jay@mysql.com-20080717194308-l9i4ti57gikm2qbv
Phase 1 removal of DBUG in mysys

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
 
17
17
/* Function with list databases, tables or fields */
18
 
#include <drizzled/server_includes.h>
19
 
#include <drizzled/sql_select.h>
20
 
#include <drizzled/sql_show.h>
 
18
 
 
19
#include "mysql_priv.h"
 
20
#include "sql_select.h"                         // For select_describe
 
21
#include "sql_show.h"
21
22
#include "repl_failsafe.h"
22
 
#include <mysys/my_dir.h>
23
 
#include <libdrizzle/gettext.h>
 
23
#include <my_dir.h>
24
24
 
25
 
inline const char *
26
 
str_or_nil(const char *str)
27
 
{
28
 
  return str ? str : "<nil>";
29
 
}
 
25
#define STR_OR_NIL(S) ((S) ? (S) : "<nil>")
30
26
 
31
27
/* Match the values of enum ha_choice */
32
28
static const char *ha_choice_values[] = {"", "0", "1"};
33
29
 
34
 
static void store_key_options(THD *thd, String *packet, Table *table,
 
30
static void store_key_options(THD *thd, String *packet, TABLE *table,
35
31
                              KEY *key_info);
36
32
 
37
33
 
38
34
 
39
 
int wild_case_compare(const CHARSET_INFO * const cs, const char *str,const char *wildstr)
 
35
int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr)
40
36
{
41
37
  register int flag;
42
38
  while (*wildstr)
86
82
** List all table types supported
87
83
***************************************************************************/
88
84
 
 
85
static int make_version_string(char *buf, int buf_length, uint version)
 
86
{
 
87
  return snprintf(buf, buf_length, "%d.%d", version>>8,version&0xff);
 
88
}
 
89
 
89
90
static bool show_plugins(THD *thd, plugin_ref plugin,
90
91
                            void *arg)
91
92
{
92
 
  Table *table= (Table*) arg;
 
93
  TABLE *table= (TABLE*) arg;
93
94
  struct st_mysql_plugin *plug= plugin_decl(plugin);
94
95
  struct st_plugin_dl *plugin_dl= plugin_dlib(plugin);
95
 
  const CHARSET_INFO * const cs= system_charset_info;
 
96
  CHARSET_INFO *cs= system_charset_info;
 
97
  char version_buf[20];
96
98
 
97
99
  restore_record(table, s->default_values);
98
100
 
99
101
  table->field[0]->store(plugin_name(plugin)->str,
100
102
                         plugin_name(plugin)->length, cs);
101
103
 
102
 
  if (plug->version)
103
 
  {
104
 
    table->field[1]->store(plug->version, strlen(plug->version), cs);
105
 
    table->field[1]->set_notnull();
106
 
  }
107
 
  else
108
 
    table->field[1]->set_null();
 
104
  table->field[1]->store(version_buf,
 
105
        make_version_string(version_buf, sizeof(version_buf), plug->version),
 
106
        cs);
 
107
 
109
108
 
110
109
  switch (plugin_state(plugin)) {
111
110
  /* case PLUGIN_IS_FREED: does not happen */
125
124
  table->field[3]->store(plugin_type_names[plug->type].str,
126
125
                         plugin_type_names[plug->type].length,
127
126
                         cs);
 
127
  table->field[4]->store(version_buf,
 
128
        make_version_string(version_buf, sizeof(version_buf),
 
129
                            *(uint *)plug->info), cs);
128
130
 
129
131
  if (plugin_dl)
130
132
  {
131
 
    table->field[4]->store(plugin_dl->dl.str, plugin_dl->dl.length, cs);
132
 
    table->field[4]->set_notnull();
133
 
  }
134
 
  else
135
 
  {
136
 
    table->field[4]->set_null();
137
 
  }
138
 
 
139
 
  if (plug->author)
140
 
  {
141
 
    table->field[5]->store(plug->author, strlen(plug->author), cs);
 
133
    table->field[5]->store(plugin_dl->dl.str, plugin_dl->dl.length, cs);
142
134
    table->field[5]->set_notnull();
 
135
    table->field[6]->store(version_buf,
 
136
          make_version_string(version_buf, sizeof(version_buf),
 
137
                              plugin_dl->version),
 
138
          cs);
 
139
    table->field[6]->set_notnull();
143
140
  }
144
141
  else
 
142
  {
145
143
    table->field[5]->set_null();
 
144
    table->field[6]->set_null();
 
145
  }
 
146
 
 
147
 
 
148
  if (plug->author)
 
149
  {
 
150
    table->field[7]->store(plug->author, strlen(plug->author), cs);
 
151
    table->field[7]->set_notnull();
 
152
  }
 
153
  else
 
154
    table->field[7]->set_null();
146
155
 
147
156
  if (plug->descr)
148
157
  {
149
 
    table->field[6]->store(plug->descr, strlen(plug->descr), cs);
150
 
    table->field[6]->set_notnull();
 
158
    table->field[8]->store(plug->descr, strlen(plug->descr), cs);
 
159
    table->field[8]->set_notnull();
151
160
  }
152
161
  else
153
 
    table->field[6]->set_null();
 
162
    table->field[8]->set_null();
154
163
 
155
164
  switch (plug->license) {
156
165
  case PLUGIN_LICENSE_GPL:
157
 
    table->field[7]->store(PLUGIN_LICENSE_GPL_STRING, 
 
166
    table->field[9]->store(PLUGIN_LICENSE_GPL_STRING, 
158
167
                           strlen(PLUGIN_LICENSE_GPL_STRING), cs);
159
168
    break;
160
169
  case PLUGIN_LICENSE_BSD:
161
 
    table->field[7]->store(PLUGIN_LICENSE_BSD_STRING, 
 
170
    table->field[9]->store(PLUGIN_LICENSE_BSD_STRING, 
162
171
                           strlen(PLUGIN_LICENSE_BSD_STRING), cs);
163
172
    break;
164
173
  default:
165
 
    table->field[7]->store(PLUGIN_LICENSE_PROPRIETARY_STRING, 
 
174
    table->field[9]->store(PLUGIN_LICENSE_PROPRIETARY_STRING, 
166
175
                           strlen(PLUGIN_LICENSE_PROPRIETARY_STRING), cs);
167
176
    break;
168
177
  }
169
 
  table->field[7]->set_notnull();
 
178
  table->field[9]->set_notnull();
170
179
 
171
180
  return schema_table_store_record(thd, table);
172
181
}
173
182
 
174
183
 
175
 
int fill_plugins(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
 
184
int fill_plugins(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((__unused__)))
176
185
{
177
 
  Table *table= tables->table;
 
186
  TABLE *table= tables->table;
178
187
 
179
 
  if (plugin_foreach_with_mask(thd, show_plugins, DRIZZLE_ANY_PLUGIN,
 
188
  if (plugin_foreach_with_mask(thd, show_plugins, MYSQL_ANY_PLUGIN,
180
189
                               ~PLUGIN_IS_FREED, table))
181
190
    return(1);
182
191
 
191
200
    find_files()
192
201
    thd                 thread handler
193
202
    files               put found files in this list
194
 
    db                  database name to set in TableList structure
 
203
    db                  database name to set in TABLE_LIST structure
195
204
    path                path to database
196
205
    wild                filter for found files
197
206
    dir                 read databases in path if true, read .frm files in
208
217
find_files(THD *thd, List<LEX_STRING> *files, const char *db,
209
218
           const char *path, const char *wild, bool dir)
210
219
{
211
 
  uint32_t i;
 
220
  uint i;
212
221
  char *ext;
213
222
  MY_DIR *dirp;
214
223
  FILEINFO *file;
215
224
  LEX_STRING *file_name= 0;
216
 
  uint32_t file_name_len;
217
 
  TableList table_list;
 
225
  uint file_name_len;
 
226
  TABLE_LIST table_list;
218
227
 
219
228
  if (wild && !wild[0])
220
229
    wild=0;
221
230
 
222
 
  memset(&table_list, 0, sizeof(table_list));
 
231
  bzero((char*) &table_list,sizeof(table_list));
223
232
 
224
233
  if (!(dirp = my_dir(path,MYF(dir ? MY_WANT_STAT : 0))))
225
234
  {
249
258
        char *end;
250
259
        *ext=0;                                 /* Remove extension */
251
260
        unpack_dirname(buff, file->name);
252
 
        end= strchr(buff, '\0');
 
261
        end= strend(buff);
253
262
        if (end != buff && end[-1] == FN_LIBCHAR)
254
263
          end[-1]= 0;                           // Remove end FN_LIBCHAR
255
264
        if (stat(buff, file->mystat))
256
265
               continue;
257
266
       }
258
267
#endif
259
 
      if (!S_ISDIR(file->mystat->st_mode))
 
268
      if (!MY_S_ISDIR(file->mystat->st_mode))
260
269
        continue;
261
270
 
262
271
      file_name_len= filename_to_tablename(file->name, uname, sizeof(uname));
303
312
 
304
313
 
305
314
bool
306
 
mysqld_show_create(THD *thd, TableList *table_list)
 
315
mysqld_show_create(THD *thd, TABLE_LIST *table_list)
307
316
{
308
317
  Protocol *protocol= thd->protocol;
309
318
  char buff[2048];
320
329
      issue a warning with 'warning' level status in 
321
330
      case of invalid view and last error is ER_VIEW_INVALID
322
331
    */
323
 
    drizzle_reset_errors(thd, true);
 
332
    mysql_reset_errors(thd, true);
324
333
    thd->clear_error();
325
334
  }
326
335
 
334
343
    field_list.push_back(new Item_empty_string("Table",NAME_CHAR_LEN));
335
344
    // 1024 is for not to confuse old clients
336
345
    field_list.push_back(new Item_empty_string("Create Table",
337
 
                                               cmax(buffer.length(),(uint32_t)1024)));
 
346
                                               max(buffer.length(),1024)));
338
347
  }
339
348
 
340
349
  if (protocol->send_fields(&field_list,
401
410
****************************************************************************/
402
411
 
403
412
void
404
 
mysqld_list_fields(THD *thd, TableList *table_list, const char *wild)
 
413
mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild)
405
414
{
406
 
  Table *table;
 
415
  TABLE *table;
407
416
 
408
417
  if (open_normal_and_derived_tables(thd, table_list, 0))
409
418
    return;
443
452
    0   No conflicting character
444
453
*/
445
454
 
446
 
static const char *require_quotes(const char *name, uint32_t name_length)
 
455
static const char *require_quotes(const char *name, uint name_length)
447
456
{
448
 
  uint32_t length;
 
457
  uint length;
449
458
  bool pure_digit= true;
450
459
  const char *end= name + name_length;
451
460
 
452
461
  for (; name < end ; name++)
453
462
  {
454
 
    unsigned char chr= (unsigned char) *name;
 
463
    uchar chr= (uchar) *name;
455
464
    length= my_mbcharlen(system_charset_info, chr);
456
465
    if (length == 1 && !system_charset_info->ident_map[chr])
457
466
      return name;
477
486
*/
478
487
 
479
488
void
480
 
append_identifier(THD *thd, String *packet, const char *name, uint32_t length)
 
489
append_identifier(THD *thd, String *packet, const char *name, uint length)
481
490
{
482
491
  const char *name_end;
483
492
  char quote_char;
494
503
   it's a keyword
495
504
  */
496
505
 
497
 
  packet->reserve(length*2 + 2);
 
506
  VOID(packet->reserve(length*2 + 2));
498
507
  quote_char= (char) q;
499
508
  packet->append(&quote_char, 1, system_charset_info);
500
509
 
501
510
  for (name_end= name+length ; name < name_end ; name+= length)
502
511
  {
503
 
    unsigned char chr= (unsigned char) *name;
 
512
    uchar chr= (uchar) *name;
504
513
    length= my_mbcharlen(system_charset_info, chr);
505
514
    /*
506
515
      my_mbcharlen can return 0 on a wrong multibyte
511
520
    */
512
521
    if (!length)
513
522
      length= 1;
514
 
    if (length == 1 && chr == (unsigned char) quote_char)
 
523
    if (length == 1 && chr == (uchar) quote_char)
515
524
      packet->append(&quote_char, 1, system_charset_info);
516
525
    packet->append(name, length, system_charset_info);
517
526
  }
542
551
    #     Quote character
543
552
*/
544
553
 
545
 
int get_quote_char_for_identifier(THD *thd, const char *name, uint32_t length)
 
554
int get_quote_char_for_identifier(THD *thd, const char *name, uint length)
546
555
{
547
556
  if (length &&
548
557
      !is_keyword(name,length) &&
549
558
      !require_quotes(name, length) &&
550
559
      !(thd->options & OPTION_QUOTE_SHOW_CREATE))
551
560
    return EOF;
552
 
  return '`';
 
561
  return '"';
553
562
}
554
563
 
555
564
 
556
565
/* Append directory name (if exists) to CREATE INFO */
557
566
 
558
 
static void append_directory(THD *thd __attribute__((unused)),
 
567
static void append_directory(THD *thd __attribute__((__unused__)),
559
568
                             String *packet, const char *dir_type,
560
569
                             const char *filename)
561
570
{
562
571
  if (filename)
563
572
  {
564
 
    uint32_t length= dirname_length(filename);
 
573
    uint length= dirname_length(filename);
565
574
    packet->append(' ');
566
575
    packet->append(dir_type);
567
576
    packet->append(STRING_WITH_LEN(" DIRECTORY='"));
573
582
 
574
583
#define LIST_PROCESS_HOST_LEN 64
575
584
 
576
 
static bool get_field_default_value(THD *thd __attribute__((unused)),
 
585
static bool get_field_default_value(THD *thd __attribute__((__unused__)),
577
586
                                    Field *timestamp_field,
578
587
                                    Field *field, String *def_value,
579
588
                                    bool quoted)
588
597
  has_now_default= (timestamp_field == field &&
589
598
                    field->unireg_check != Field::TIMESTAMP_UN_FIELD);
590
599
    
591
 
  has_default= (field->type() != DRIZZLE_TYPE_BLOB &&
 
600
  has_default= (field->type() != FIELD_TYPE_BLOB &&
592
601
                !(field->flags & NO_DEFAULT_VALUE_FLAG) &&
593
602
                field->unireg_check != Field::NEXT_NUMBER
594
603
                  && has_now_default);
606
615
      if (type.length())
607
616
      {
608
617
        String def_val;
609
 
        uint32_t dummy_errors;
 
618
        uint dummy_errors;
610
619
        /* convert to system_charset_info == utf8 */
611
620
        def_val.copy(type.ptr(), type.length(), field->charset(),
612
621
                     system_charset_info, &dummy_errors);
650
659
    0       OK
651
660
 */
652
661
 
653
 
int store_create_info(THD *thd, TableList *table_list, String *packet,
 
662
int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
654
663
                      HA_CREATE_INFO *create_info_arg)
655
664
{
656
665
  List<Item> field_list;
659
668
  String type(tmp, sizeof(tmp), system_charset_info);
660
669
  String def_value(def_value_buf, sizeof(def_value_buf), system_charset_info);
661
670
  Field **ptr,*field;
662
 
  uint32_t primary_key;
 
671
  uint primary_key;
663
672
  KEY *key_info;
664
 
  Table *table= table_list->table;
 
673
  TABLE *table= table_list->table;
665
674
  handler *file= table->file;
666
675
  TABLE_SHARE *share= table->s;
667
676
  HA_CREATE_INFO create_info;
695
704
    We have to restore the read_set if we are called from insert in case
696
705
    of row based replication.
697
706
  */
698
 
  old_map= table->use_all_columns(table->read_set);
 
707
  old_map= tmp_use_all_columns(table, table->read_set);
699
708
 
700
709
  for (ptr=table->field ; (field= *ptr); ptr++)
701
710
  {
702
 
    uint32_t flags = field->flags;
 
711
    uint flags = field->flags;
703
712
 
704
713
    if (ptr != table->field)
705
714
      packet->append(STRING_WITH_LEN(",\n"));
736
745
 
737
746
    if (flags & NOT_NULL_FLAG)
738
747
      packet->append(STRING_WITH_LEN(" NOT NULL"));
739
 
    else if (field->type() == DRIZZLE_TYPE_TIMESTAMP)
 
748
    else if (field->type() == MYSQL_TYPE_TIMESTAMP)
740
749
    {
741
750
      /*
742
751
        TIMESTAMP field require explicit NULL flag, because unlike
754
763
      if (column_format)
755
764
      {
756
765
        packet->append(STRING_WITH_LEN(" /*!"));
757
 
        packet->append(STRING_WITH_LEN(DRIZZLE_VERSION_TABLESPACE_IN_FRM_STR));
 
766
        packet->append(STRING_WITH_LEN(MYSQL_VERSION_TABLESPACE_IN_FRM_STR));
758
767
        packet->append(STRING_WITH_LEN(" COLUMN_FORMAT"));
759
768
        if (column_format == COLUMN_FORMAT_TYPE_FIXED)
760
769
          packet->append(STRING_WITH_LEN(" FIXED */"));
783
792
  }
784
793
 
785
794
  key_info= table->key_info;
786
 
  memset(&create_info, 0, sizeof(create_info));
 
795
  bzero((char*) &create_info, sizeof(create_info));
787
796
  /* Allow update_create_info to update row type */
788
797
  create_info.row_type= share->row_type;
789
798
  file->update_create_info(&create_info);
790
799
  primary_key= share->primary_key;
791
800
 
792
 
  for (uint32_t i=0 ; i < share->keys ; i++,key_info++)
 
801
  for (uint i=0 ; i < share->keys ; i++,key_info++)
793
802
  {
794
803
    KEY_PART_INFO *key_part= key_info->key_part;
795
804
    bool found_primary=0;
814
823
 
815
824
    packet->append(STRING_WITH_LEN(" ("));
816
825
 
817
 
    for (uint32_t j=0 ; j < key_info->key_parts ; j++,key_part++)
 
826
    for (uint j=0 ; j < key_info->key_parts ; j++,key_part++)
818
827
    {
819
828
      if (j)
820
829
        packet->append(',');
888
897
      packet->append(buff, (uint) (end - buff));
889
898
    }
890
899
 
 
900
    
 
901
    if (share->table_charset)
 
902
    {
 
903
      /*
 
904
        IF   check_create_info
 
905
        THEN add DEFAULT CHARSET only if it was used when creating the table
 
906
      */
 
907
      if (!create_info_arg ||
 
908
          (create_info_arg->used_fields & HA_CREATE_USED_DEFAULT_CHARSET))
 
909
      {
 
910
        packet->append(STRING_WITH_LEN(" DEFAULT CHARSET="));
 
911
        packet->append(share->table_charset->csname);
 
912
        if (!(share->table_charset->state & MY_CS_PRIMARY))
 
913
        {
 
914
          packet->append(STRING_WITH_LEN(" COLLATE="));
 
915
          packet->append(table->s->table_charset->name);
 
916
        }
 
917
      }
 
918
    }
 
919
 
891
920
    if (share->min_rows)
892
921
    {
893
922
      char *end;
943
972
      end= int64_t10_to_str(table->s->key_block_size, buff, 10);
944
973
      packet->append(buff, (uint) (end - buff));
945
974
    }
946
 
    if (share->block_size)
947
 
    {
948
 
      char *end;
949
 
      packet->append(STRING_WITH_LEN(" BLOCK_SIZE="));
950
 
      end= int64_t10_to_str(share->block_size, buff,10);
951
 
      packet->append(buff, (uint) (end - buff));
952
 
    }
953
975
    table->file->append_create_info(packet);
954
976
    if (share->comment.length)
955
977
    {
964
986
    append_directory(thd, packet, "DATA",  create_info.data_file_name);
965
987
    append_directory(thd, packet, "INDEX", create_info.index_file_name);
966
988
  }
967
 
  table->restore_column_map(old_map);
 
989
  tmp_restore_column_map(table->read_set, old_map);
968
990
  return(0);
969
991
}
970
992
 
994
1016
                          HA_CREATE_INFO *create_info)
995
1017
{
996
1018
  HA_CREATE_INFO create;
997
 
  uint32_t create_options = create_info ? create_info->options : 0;
 
1019
  uint create_options = create_info ? create_info->options : 0;
998
1020
 
999
1021
  if (!my_strcasecmp(system_charset_info, dbname,
1000
1022
                     INFORMATION_SCHEMA_NAME.str))
1036
1058
  return(false);
1037
1059
}
1038
1060
 
1039
 
static void store_key_options(THD *thd __attribute__((unused)),
1040
 
                              String *packet, Table *table,
 
1061
static void store_key_options(THD *thd __attribute__((__unused__)),
 
1062
                              String *packet, TABLE *table,
1041
1063
                              KEY *key_info)
1042
1064
{
1043
1065
  char *end, buff[32];
1084
1106
 
1085
1107
  ulong thread_id;
1086
1108
  time_t start_time;
1087
 
  uint32_t   command;
 
1109
  uint   command;
1088
1110
  const char *user,*host,*db,*proc_info,*state_info;
1089
1111
  char *query;
1090
1112
};
1108
1130
  field_list.push_back(field=new Item_empty_string("db",NAME_CHAR_LEN));
1109
1131
  field->maybe_null=1;
1110
1132
  field_list.push_back(new Item_empty_string("Command",16));
1111
 
  field_list.push_back(new Item_return_int("Time",7, DRIZZLE_TYPE_LONG));
 
1133
  field_list.push_back(new Item_return_int("Time",7, MYSQL_TYPE_LONG));
1112
1134
  field_list.push_back(field=new Item_empty_string("State",30));
1113
1135
  field->maybe_null=1;
1114
1136
  field_list.push_back(field=new Item_empty_string("Info",max_query_length));
1117
1139
                            Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
1118
1140
    return;
1119
1141
 
1120
 
  pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
 
1142
  VOID(pthread_mutex_lock(&LOCK_thread_count)); // For unlink from list
1121
1143
  if (!thd->killed)
1122
1144
  {
1123
1145
    I_List_iterator<THD> it(threads);
1134
1156
        thd_info->user= thd->strdup(tmp_sctx->user ? tmp_sctx->user :
1135
1157
                                    (tmp->system_thread ?
1136
1158
                                     "system user" : "unauthenticated user"));
1137
 
        thd_info->host= thd->strdup(tmp_sctx->ip);
 
1159
        thd_info->host= thd->strdup(tmp_sctx->host_or_ip[0] ? 
 
1160
                                    tmp_sctx->host_or_ip : 
 
1161
                                    tmp_sctx->host ? tmp_sctx->host : "");
1138
1162
        if ((thd_info->db=tmp->db))             // Safe test
1139
1163
          thd_info->db=thd->strdup(thd_info->db);
1140
1164
        thd_info->command=(int) tmp->command;
1144
1168
        thd_info->state_info= (char*) (tmp->net.reading_or_writing ?
1145
1169
                                       (tmp->net.reading_or_writing == 2 ?
1146
1170
                                        "Writing to net" :
1147
 
                                        thd_info->command == COM_SLEEP ? NULL :
 
1171
                                        thd_info->command == COM_SLEEP ? NullS :
1148
1172
                                        "Reading from net") :
1149
 
                                       tmp->get_proc_info() ? tmp->get_proc_info() :
 
1173
                                       tmp->proc_info ? tmp->proc_info :
1150
1174
                                       tmp->mysys_var &&
1151
1175
                                       tmp->mysys_var->current_cond ?
1152
 
                                       "Waiting on cond" : NULL);
 
1176
                                       "Waiting on cond" : NullS);
1153
1177
        if (mysys_var)
1154
1178
          pthread_mutex_unlock(&mysys_var->mutex);
1155
1179
 
1162
1186
            the comment in sql_class.h why this prevents crashes in possible
1163
1187
            races with query_length
1164
1188
          */
1165
 
          uint32_t length= cmin((uint32_t)max_query_length, tmp->query_length);
 
1189
          uint length= min(max_query_length, tmp->query_length);
1166
1190
          thd_info->query=(char*) thd->strmake(tmp->query,length);
1167
1191
        }
1168
1192
        thread_infos.append(thd_info);
1169
1193
      }
1170
1194
    }
1171
1195
  }
1172
 
  pthread_mutex_unlock(&LOCK_thread_count);
 
1196
  VOID(pthread_mutex_unlock(&LOCK_thread_count));
1173
1197
 
1174
1198
  thread_info *thd_info;
1175
1199
  time_t now= my_time(0);
1185
1209
    else
1186
1210
      protocol->store(command_name[thd_info->command].str, system_charset_info);
1187
1211
    if (thd_info->start_time)
1188
 
      protocol->store((uint32_t) (now - thd_info->start_time));
 
1212
      protocol->store((uint32) (now - thd_info->start_time));
1189
1213
    else
1190
1214
      protocol->store_null();
1191
1215
    protocol->store(thd_info->state_info, system_charset_info);
1197
1221
  return;
1198
1222
}
1199
1223
 
1200
 
int fill_schema_processlist(THD* thd, TableList* tables,
1201
 
                            COND* cond __attribute__((unused)))
 
1224
int fill_schema_processlist(THD* thd, TABLE_LIST* tables,
 
1225
                            COND* cond __attribute__((__unused__)))
1202
1226
{
1203
 
  Table *table= tables->table;
1204
 
  const CHARSET_INFO * const cs= system_charset_info;
 
1227
  TABLE *table= tables->table;
 
1228
  CHARSET_INFO *cs= system_charset_info;
1205
1229
  char *user;
1206
1230
  time_t now= my_time(0);
1207
1231
 
1208
 
  user= NULL;
 
1232
  user= NullS;
1209
1233
 
1210
 
  pthread_mutex_lock(&LOCK_thread_count);
 
1234
  VOID(pthread_mutex_lock(&LOCK_thread_count));
1211
1235
 
1212
1236
  if (!thd->killed)
1213
1237
  {
1231
1255
            (tmp->system_thread ? "system user" : "unauthenticated user");
1232
1256
      table->field[1]->store(val, strlen(val), cs);
1233
1257
      /* HOST */
1234
 
      table->field[2]->store(tmp_sctx->ip, strlen(tmp_sctx->ip), cs);
 
1258
      table->field[2]->store(tmp_sctx->host_or_ip,
 
1259
                             strlen(tmp_sctx->host_or_ip), cs);
1235
1260
      /* DB */
1236
1261
      if (tmp->db)
1237
1262
      {
1247
1272
      else
1248
1273
        table->field[4]->store(command_name[tmp->command].str,
1249
1274
                               command_name[tmp->command].length, cs);
1250
 
      /* DRIZZLE_TIME */
1251
 
      table->field[5]->store((uint32_t)(tmp->start_time ?
 
1275
      /* MYSQL_TIME */
 
1276
      table->field[5]->store((uint32)(tmp->start_time ?
1252
1277
                                      now - tmp->start_time : 0), true);
1253
1278
      /* STATE */
1254
1279
      val= (char*) (tmp->net.reading_or_writing ?
1255
1280
                    (tmp->net.reading_or_writing == 2 ?
1256
1281
                     "Writing to net" :
1257
 
                     tmp->command == COM_SLEEP ? NULL :
 
1282
                     tmp->command == COM_SLEEP ? NullS :
1258
1283
                     "Reading from net") :
1259
 
                    tmp->get_proc_info() ? tmp->get_proc_info() :
 
1284
                    tmp->proc_info ? tmp->proc_info :
1260
1285
                    tmp->mysys_var &&
1261
1286
                    tmp->mysys_var->current_cond ?
1262
 
                    "Waiting on cond" : NULL);
 
1287
                    "Waiting on cond" : NullS);
1263
1288
      if (val)
1264
1289
      {
1265
1290
        table->field[6]->store(val, strlen(val), cs);
1273
1298
      if (tmp->query)
1274
1299
      {
1275
1300
        table->field[7]->store(tmp->query,
1276
 
                               cmin((uint32_t)PROCESS_LIST_INFO_WIDTH,
 
1301
                               min(PROCESS_LIST_INFO_WIDTH,
1277
1302
                                   tmp->query_length), cs);
1278
1303
        table->field[7]->set_notnull();
1279
1304
      }
1280
1305
 
1281
1306
      if (schema_table_store_record(thd, table))
1282
1307
      {
1283
 
        pthread_mutex_unlock(&LOCK_thread_count);
 
1308
        VOID(pthread_mutex_unlock(&LOCK_thread_count));
1284
1309
        return(1);
1285
1310
      }
1286
1311
    }
1287
1312
  }
1288
1313
 
1289
 
  pthread_mutex_unlock(&LOCK_thread_count);
 
1314
  VOID(pthread_mutex_unlock(&LOCK_thread_count));
1290
1315
  return(0);
1291
1316
}
1292
1317
 
1307
1332
*/
1308
1333
static void shrink_var_array(DYNAMIC_ARRAY *array)
1309
1334
{
1310
 
  uint32_t a,b;
 
1335
  uint a,b;
1311
1336
  SHOW_VAR *all= dynamic_element(array, 0, SHOW_VAR *);
1312
1337
 
1313
1338
  for (a= b= 0; b < array->elements; b++)
1315
1340
      all[a++]= all[b];
1316
1341
  if (a)
1317
1342
  {
1318
 
    memset(all+a, 0, sizeof(SHOW_VAR)); // writing NULL-element to the end
 
1343
    bzero(all+a, sizeof(SHOW_VAR)); // writing NULL-element to the end
1319
1344
    array->elements= a;
1320
1345
  }
1321
1346
  else // array is completely empty - delete it
1353
1378
    goto err;
1354
1379
  }
1355
1380
  while (list->name)
1356
 
    res|= insert_dynamic(&all_status_vars, (unsigned char*)list++);
1357
 
  res|= insert_dynamic(&all_status_vars, (unsigned char*)list); // appending NULL-element
 
1381
    res|= insert_dynamic(&all_status_vars, (uchar*)list++);
 
1382
  res|= insert_dynamic(&all_status_vars, (uchar*)list); // appending NULL-element
1358
1383
  all_status_vars.elements--; // but next insert_dynamic should overwite it
1359
1384
  if (status_vars_inited)
1360
1385
    sort_dynamic(&all_status_vars, show_var_cmp);
1448
1473
  else
1449
1474
  {
1450
1475
    SHOW_VAR *all= dynamic_element(&all_status_vars, 0, SHOW_VAR *);
1451
 
    uint32_t i;
 
1476
    uint i;
1452
1477
    for (; list->name; list++)
1453
1478
    {
1454
1479
      for (i= 0; i < all_status_vars.elements; i++)
1473
1498
                              SHOW_VAR *variables,
1474
1499
                              enum enum_var_type value_type,
1475
1500
                              struct system_status_var *status_var,
1476
 
                              const char *prefix, Table *table,
 
1501
                              const char *prefix, TABLE *table,
1477
1502
                              bool ucase_names)
1478
1503
{
1479
1504
  MY_ALIGNED_BYTE_ARRAY(buff_data, SHOW_VAR_FUNC_BUFF_SIZE, long);
1488
1513
  null_lex_str.str= 0;                          // For sys_var->value_ptr()
1489
1514
  null_lex_str.length= 0;
1490
1515
 
1491
 
  prefix_end=my_stpncpy(name_buffer, prefix, sizeof(name_buffer)-1);
 
1516
  prefix_end=strnmov(name_buffer, prefix, sizeof(name_buffer)-1);
1492
1517
  if (*prefix)
1493
1518
    *prefix_end++= '_';
1494
1519
  len=name_buffer + sizeof(name_buffer) - prefix_end;
1495
1520
 
1496
1521
  for (; variables->name; variables++)
1497
1522
  {
1498
 
    my_stpncpy(prefix_end, variables->name, len);
 
1523
    strnmov(prefix_end, variables->name, len);
1499
1524
    name_buffer[sizeof(name_buffer)-1]=0;       /* Safety */
1500
1525
    if (ucase_names)
1501
1526
      make_upper(name_buffer);
1560
1585
          end= int64_t10_to_str((int64_t) *(ha_rows*) value, buff, 10);
1561
1586
          break;
1562
1587
        case SHOW_BOOL:
1563
 
          end= my_stpcpy(buff, *(bool*) value ? "ON" : "OFF");
 
1588
          end= strmov(buff, *(bool*) value ? "ON" : "OFF");
1564
1589
          break;
1565
1590
        case SHOW_MY_BOOL:
1566
 
          end= my_stpcpy(buff, *(bool*) value ? "ON" : "OFF");
 
1591
          end= strmov(buff, *(bool*) value ? "ON" : "OFF");
1567
1592
          break;
1568
1593
        case SHOW_INT:
1569
 
          end= int10_to_str((long) *(uint32_t*) value, buff, 10);
 
1594
          end= int10_to_str((long) *(uint32*) value, buff, 10);
1570
1595
          break;
1571
1596
        case SHOW_HAVE:
1572
1597
        {
1573
1598
          SHOW_COMP_OPTION tmp= *(SHOW_COMP_OPTION*) value;
1574
1599
          pos= show_comp_option_name[(int) tmp];
1575
 
          end= strchr(pos, '\0');
 
1600
          end= strend(pos);
1576
1601
          break;
1577
1602
        }
1578
1603
        case SHOW_CHAR:
1579
1604
        {
1580
1605
          if (!(pos= value))
1581
1606
            pos= "";
1582
 
          end= strchr(pos, '\0');
 
1607
          end= strend(pos);
1583
1608
          break;
1584
1609
        }
1585
1610
       case SHOW_CHAR_PTR:
1586
1611
        {
1587
1612
          if (!(pos= *(char**) value))
1588
1613
            pos= "";
1589
 
          end= strchr(pos, '\0');
 
1614
          end= strend(pos);
1590
1615
          break;
1591
1616
        }
1592
1617
        case SHOW_KEY_CACHE_LONG:
1607
1632
        restore_record(table, s->default_values);
1608
1633
        table->field[0]->store(name_buffer, strlen(name_buffer),
1609
1634
                               system_charset_info);
1610
 
        table->field[1]->store(pos, (uint32_t) (end - pos), system_charset_info);
 
1635
        table->field[1]->store(pos, (uint32) (end - pos), system_charset_info);
1611
1636
        table->field[1]->set_notnull();
1612
1637
 
1613
1638
        pthread_mutex_unlock(&LOCK_global_system_variables);
1628
1653
{
1629
1654
 
1630
1655
  /* Ensure that thread id not killed during loop */
1631
 
  pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
 
1656
  VOID(pthread_mutex_lock(&LOCK_thread_count)); // For unlink from list
1632
1657
 
1633
1658
  I_List_iterator<THD> it(threads);
1634
1659
  THD *tmp;
1640
1665
  while ((tmp= it++))
1641
1666
    add_to_status(to, &tmp->status_var);
1642
1667
  
1643
 
  pthread_mutex_unlock(&LOCK_thread_count);
 
1668
  VOID(pthread_mutex_unlock(&LOCK_thread_count));
1644
1669
  return;
1645
1670
}
1646
1671
 
1669
1694
    1                     error
1670
1695
*/
1671
1696
 
1672
 
bool schema_table_store_record(THD *thd, Table *table)
 
1697
bool schema_table_store_record(THD *thd, TABLE *table)
1673
1698
{
1674
1699
  int error;
1675
1700
  if ((error= table->file->ha_write_row(table->record[0])))
1715
1740
*/
1716
1741
 
1717
1742
bool get_lookup_value(THD *thd, Item_func *item_func,
1718
 
                      TableList *table, 
 
1743
                      TABLE_LIST *table, 
1719
1744
                      LOOKUP_FIELD_VALUES *lookup_field_vals)
1720
1745
{
1721
1746
  ST_SCHEMA_TABLE *schema_table= table->schema_table;
1732
1757
    char tmp[MAX_FIELD_WIDTH];
1733
1758
    String *tmp_str, str_buff(tmp, sizeof(tmp), system_charset_info);
1734
1759
    Item_field *item_field;
1735
 
    const CHARSET_INFO * const cs= system_charset_info;
 
1760
    CHARSET_INFO *cs= system_charset_info;
1736
1761
 
1737
1762
    if (item_func->arguments()[0]->type() == Item::FIELD_ITEM &&
1738
1763
        item_func->arguments()[1]->const_item())
1759
1784
      return 1;
1760
1785
 
1761
1786
    /* Lookup value is database name */
1762
 
    if (!cs->coll->strnncollsp(cs, (unsigned char *) field_name1, strlen(field_name1),
1763
 
                               (unsigned char *) item_field->field_name,
 
1787
    if (!cs->coll->strnncollsp(cs, (uchar *) field_name1, strlen(field_name1),
 
1788
                               (uchar *) item_field->field_name,
1764
1789
                               strlen(item_field->field_name), 0))
1765
1790
    {
1766
1791
      thd->make_lex_string(&lookup_field_vals->db_value, tmp_str->ptr(),
1767
1792
                           tmp_str->length(), false);
1768
1793
    }
1769
1794
    /* Lookup value is table name */
1770
 
    else if (!cs->coll->strnncollsp(cs, (unsigned char *) field_name2,
 
1795
    else if (!cs->coll->strnncollsp(cs, (uchar *) field_name2,
1771
1796
                                    strlen(field_name2),
1772
 
                                    (unsigned char *) item_field->field_name,
 
1797
                                    (uchar *) item_field->field_name,
1773
1798
                                    strlen(item_field->field_name), 0))
1774
1799
    {
1775
1800
      thd->make_lex_string(&lookup_field_vals->table_value, tmp_str->ptr(),
1797
1822
    1             error, there can be no matching records for the condition
1798
1823
*/
1799
1824
 
1800
 
bool calc_lookup_values_from_cond(THD *thd, COND *cond, TableList *table,
 
1825
bool calc_lookup_values_from_cond(THD *thd, COND *cond, TABLE_LIST *table,
1801
1826
                                  LOOKUP_FIELD_VALUES *lookup_field_vals)
1802
1827
{
1803
1828
  if (!cond)
1832
1857
}
1833
1858
 
1834
1859
 
1835
 
bool uses_only_table_name_fields(Item *item, TableList *table)
 
1860
bool uses_only_table_name_fields(Item *item, TABLE_LIST *table)
1836
1861
{
1837
1862
  if (item->type() == Item::FUNC_ITEM)
1838
1863
  {
1839
1864
    Item_func *item_func= (Item_func*)item;
1840
 
    for (uint32_t i=0; i<item_func->argument_count(); i++)
 
1865
    for (uint i=0; i<item_func->argument_count(); i++)
1841
1866
    {
1842
1867
      if (!uses_only_table_name_fields(item_func->arguments()[i], table))
1843
1868
        return 0;
1846
1871
  else if (item->type() == Item::FIELD_ITEM)
1847
1872
  {
1848
1873
    Item_field *item_field= (Item_field*)item;
1849
 
    const CHARSET_INFO * const cs= system_charset_info;
 
1874
    CHARSET_INFO *cs= system_charset_info;
1850
1875
    ST_SCHEMA_TABLE *schema_table= table->schema_table;
1851
1876
    ST_FIELD_INFO *field_info= schema_table->fields_info;
1852
1877
    const char *field_name1= schema_table->idx_field1 >= 0 ?
1854
1879
    const char *field_name2= schema_table->idx_field2 >= 0 ?
1855
1880
      field_info[schema_table->idx_field2].field_name : "";
1856
1881
    if (table->table != item_field->field->table ||
1857
 
        (cs->coll->strnncollsp(cs, (unsigned char *) field_name1, strlen(field_name1),
1858
 
                               (unsigned char *) item_field->field_name,
 
1882
        (cs->coll->strnncollsp(cs, (uchar *) field_name1, strlen(field_name1),
 
1883
                               (uchar *) item_field->field_name,
1859
1884
                               strlen(item_field->field_name), 0) &&
1860
 
         cs->coll->strnncollsp(cs, (unsigned char *) field_name2, strlen(field_name2),
1861
 
                               (unsigned char *) item_field->field_name,
 
1885
         cs->coll->strnncollsp(cs, (uchar *) field_name2, strlen(field_name2),
 
1886
                               (uchar *) item_field->field_name,
1862
1887
                               strlen(item_field->field_name), 0)))
1863
1888
      return 0;
1864
1889
  }
1872
1897
}
1873
1898
 
1874
1899
 
1875
 
static COND * make_cond_for_info_schema(COND *cond, TableList *table)
 
1900
static COND * make_cond_for_info_schema(COND *cond, TABLE_LIST *table)
1876
1901
{
1877
1902
  if (!cond)
1878
1903
    return (COND*) 0;
1946
1971
    1             error, there can be no matching records for the condition
1947
1972
*/
1948
1973
 
1949
 
bool get_lookup_field_values(THD *thd, COND *cond, TableList *tables,
 
1974
bool get_lookup_field_values(THD *thd, COND *cond, TABLE_LIST *tables,
1950
1975
                             LOOKUP_FIELD_VALUES *lookup_field_values)
1951
1976
{
1952
1977
  LEX *lex= thd->lex;
1953
 
  const char *wild= lex->wild ? lex->wild->ptr() : NULL;
1954
 
  memset(lookup_field_values, 0, sizeof(LOOKUP_FIELD_VALUES));
 
1978
  const char *wild= lex->wild ? lex->wild->ptr() : NullS;
 
1979
  bzero((char*) lookup_field_values, sizeof(LOOKUP_FIELD_VALUES));
1955
1980
  switch (lex->sql_command) {
1956
1981
  case SQLCOM_SHOW_DATABASES:
1957
1982
    if (wild)
2031
2056
      if (files->push_back(i_s_name_copy))
2032
2057
        return 1;
2033
2058
    }
2034
 
    return (find_files(thd, files, NULL, mysql_data_home,
 
2059
    return (find_files(thd, files, NullS, mysql_data_home,
2035
2060
                       lookup_field_vals->db_value.str, 1) != FIND_FILES_OK);
2036
2061
  }
2037
2062
 
2062
2087
  if (files->push_back(i_s_name_copy))
2063
2088
    return 1;
2064
2089
  *with_i_schema= 1;
2065
 
  return (find_files(thd, files, NULL,
2066
 
                     mysql_data_home, NULL, 1) != FIND_FILES_OK);
 
2090
  return (find_files(thd, files, NullS,
 
2091
                     mysql_data_home, NullS, 1) != FIND_FILES_OK);
2067
2092
}
2068
2093
 
2069
2094
 
2140
2165
  add_data.files= files;
2141
2166
  add_data.wild= wild;
2142
2167
  if (plugin_foreach(thd, add_schema_table,
2143
 
                     DRIZZLE_INFORMATION_SCHEMA_PLUGIN, &add_data))
2144
 
    return(1);
 
2168
                     MYSQL_INFORMATION_SCHEMA_PLUGIN, &add_data))
 
2169
      return(1);
2145
2170
 
2146
2171
  return(0);
2147
2172
}
2227
2252
  @brief          Fill I_S table for SHOW COLUMNS|INDEX commands
2228
2253
 
2229
2254
  @param[in]      thd                      thread handler
2230
 
  @param[in]      tables                   TableList for I_S table
 
2255
  @param[in]      tables                   TABLE_LIST for I_S table
2231
2256
  @param[in]      schema_table             pointer to I_S structure
2232
2257
  @param[in]      open_tables_state_backup pointer to Open_tables_state object
2233
2258
                                           which is used to save|restore original
2240
2265
*/
2241
2266
 
2242
2267
static int 
2243
 
fill_schema_show_cols_or_idxs(THD *thd, TableList *tables,
 
2268
fill_schema_show_cols_or_idxs(THD *thd, TABLE_LIST *tables,
2244
2269
                              ST_SCHEMA_TABLE *schema_table,
2245
2270
                              Open_tables_state *open_tables_state_backup)
2246
2271
{
2248
2273
  bool res;
2249
2274
  LEX_STRING tmp_lex_string, tmp_lex_string1, *db_name, *table_name;
2250
2275
  enum_sql_command save_sql_command= lex->sql_command;
2251
 
  TableList *show_table_list= (TableList*) tables->schema_select_lex->
 
2276
  TABLE_LIST *show_table_list= (TABLE_LIST*) tables->schema_select_lex->
2252
2277
    table_list.first;
2253
 
  Table *table= tables->table;
 
2278
  TABLE *table= tables->table;
2254
2279
  int error= 1;
2255
2280
 
2256
2281
  lex->all_selects_list= tables->schema_select_lex;
2269
2294
  */
2270
2295
  lex->sql_command= SQLCOM_SHOW_FIELDS;
2271
2296
  res= open_normal_and_derived_tables(thd, show_table_list,
2272
 
                                      DRIZZLE_LOCK_IGNORE_FLUSH);
 
2297
                                      MYSQL_LOCK_IGNORE_FLUSH);
2273
2298
  lex->sql_command= save_sql_command;
2274
2299
  /*
2275
2300
    get_all_tables() returns 1 on failure and 0 on success thus
2298
2323
 
2299
2324
 
2300
2325
/**
2301
 
  @brief          Fill I_S table for SHOW Table NAMES commands
 
2326
  @brief          Fill I_S table for SHOW TABLE NAMES commands
2302
2327
 
2303
2328
  @param[in]      thd                      thread handler
2304
 
  @param[in]      table                    Table struct for I_S table
 
2329
  @param[in]      table                    TABLE struct for I_S table
2305
2330
  @param[in]      db_name                  database name
2306
2331
  @param[in]      table_name               table name
2307
2332
  @param[in]      with_i_schema            I_S table if true
2311
2336
    @retval       1           error
2312
2337
*/
2313
2338
 
2314
 
static int fill_schema_table_names(THD *thd, Table *table,
 
2339
static int fill_schema_table_names(THD *thd, TABLE *table,
2315
2340
                                   LEX_STRING *db_name, LEX_STRING *table_name,
2316
2341
                                   bool with_i_schema)
2317
2342
{
2326
2351
    char path[FN_REFLEN];
2327
2352
    (void) build_table_filename(path, sizeof(path), db_name->str, 
2328
2353
                                table_name->str, reg_ext, 0);
2329
 
    if (mysql_frm_type(thd, path, &not_used)) 
2330
 
    {
2331
 
      table->field[3]->store(STRING_WITH_LEN("BASE Table"),
2332
 
                             system_charset_info);
2333
 
    }
2334
 
    else
2335
 
    {
 
2354
    switch (mysql_frm_type(thd, path, &not_used)) {
 
2355
    case FRMTYPE_ERROR:
2336
2356
      table->field[3]->store(STRING_WITH_LEN("ERROR"),
2337
2357
                             system_charset_info);
 
2358
      break;
 
2359
    case FRMTYPE_TABLE:
 
2360
      table->field[3]->store(STRING_WITH_LEN("BASE TABLE"),
 
2361
                             system_charset_info);
 
2362
      break;
 
2363
    default:
 
2364
      assert(0);
2338
2365
    }
2339
 
 
2340
2366
    if (thd->is_error() && thd->main_da.sql_errno() == ER_NO_SUCH_TABLE)
2341
2367
    {
2342
2368
      thd->clear_error();
2365
2391
    @retval       SKIP_OPEN_TABLE | OPEN_FRM_ONLY | OPEN_FULL_TABLE
2366
2392
*/
2367
2393
 
2368
 
static uint32_t get_table_open_method(TableList *tables,
 
2394
static uint get_table_open_method(TABLE_LIST *tables,
2369
2395
                                  ST_SCHEMA_TABLE *schema_table,
2370
 
                                  enum enum_schema_tables schema_table_idx __attribute__((unused)))
 
2396
                                  enum enum_schema_tables schema_table_idx __attribute__((__unused__)))
2371
2397
{
2372
2398
  /*
2373
2399
    determine which method will be used for table opening
2393
2419
  @brief          Fill I_S table with data from FRM file only
2394
2420
 
2395
2421
  @param[in]      thd                      thread handler
2396
 
  @param[in]      table                    Table struct for I_S table
 
2422
  @param[in]      table                    TABLE struct for I_S table
2397
2423
  @param[in]      schema_table             I_S table struct
2398
2424
  @param[in]      db_name                  database name
2399
2425
  @param[in]      table_name               table name
2406
2432
                              open_tables function for this table
2407
2433
*/
2408
2434
 
2409
 
static int fill_schema_table_from_frm(THD *thd,TableList *tables,
 
2435
static int fill_schema_table_from_frm(THD *thd,TABLE_LIST *tables,
2410
2436
                                      ST_SCHEMA_TABLE *schema_table,
2411
2437
                                      LEX_STRING *db_name,
2412
2438
                                      LEX_STRING *table_name,
2413
 
                                      enum enum_schema_tables schema_table_idx __attribute__((unused)))
 
2439
                                      enum enum_schema_tables schema_table_idx __attribute__((__unused__)))
2414
2440
{
2415
 
  Table *table= tables->table;
 
2441
  TABLE *table= tables->table;
2416
2442
  TABLE_SHARE *share;
2417
 
  Table tbl;
2418
 
  TableList table_list;
2419
 
  uint32_t res= 0;
 
2443
  TABLE tbl;
 
2444
  TABLE_LIST table_list;
 
2445
  uint res= 0;
2420
2446
  int error;
2421
2447
  char key[MAX_DBKEY_LENGTH];
2422
 
  uint32_t key_length;
 
2448
  uint key_length;
2423
2449
 
2424
 
  memset(&table_list, 0, sizeof(TableList));
2425
 
  memset(&tbl, 0, sizeof(Table));
 
2450
  bzero((char*) &table_list, sizeof(TABLE_LIST));
 
2451
  bzero((char*) &tbl, sizeof(TABLE));
2426
2452
 
2427
2453
  table_list.table_name= table_name->str;
2428
2454
  table_list.db= db_name->str;
2430
2456
  key_length= create_table_def_key(thd, key, &table_list, 0);
2431
2457
  pthread_mutex_lock(&LOCK_open);
2432
2458
  share= get_table_share(thd, &table_list, key,
2433
 
                         key_length, 0, &error);
 
2459
                         key_length, OPEN_VIEW, &error);
2434
2460
  if (!share)
2435
2461
  {
2436
2462
    res= 0;
2473
2499
    @retval       1                        error
2474
2500
*/
2475
2501
 
2476
 
int get_all_tables(THD *thd, TableList *tables, COND *cond)
 
2502
int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
2477
2503
{
2478
2504
  LEX *lex= thd->lex;
2479
 
  Table *table= tables->table;
 
2505
  TABLE *table= tables->table;
2480
2506
  SELECT_LEX *old_all_select_lex= lex->all_selects_list;
2481
2507
  enum_sql_command save_sql_command= lex->sql_command;
2482
2508
  SELECT_LEX *lsel= tables->schema_select_lex;
2489
2515
  List<LEX_STRING> db_names;
2490
2516
  List_iterator_fast<LEX_STRING> it(db_names);
2491
2517
  COND *partial_cond= 0;
2492
 
  uint32_t derived_tables= lex->derived_tables; 
 
2518
  uint derived_tables= lex->derived_tables; 
2493
2519
  int error= 1;
2494
2520
  Open_tables_state open_tables_state_backup;
2495
2521
  Query_tables_list query_tables_list_backup;
2496
 
  uint32_t table_open_method;
 
2522
  uint table_open_method;
2497
2523
  bool old_value= thd->no_warnings_for_error;
2498
2524
 
2499
2525
  lex->reset_n_backup_query_tables_list(&query_tables_list_backup);
2601
2627
            continue;
2602
2628
          }
2603
2629
 
2604
 
          /* SHOW Table NAMES command */
 
2630
          /* SHOW TABLE NAMES command */
2605
2631
          if (schema_table_idx == SCH_TABLE_NAMES)
2606
2632
          {
2607
2633
            if (fill_schema_table_names(thd, tables->table, db_name,
2632
2658
              goto err;
2633
2659
            if (make_table_list(thd, &sel, db_name, table_name))
2634
2660
              goto err;
2635
 
            TableList *show_table_list= (TableList*) sel.table_list.first;
 
2661
            TABLE_LIST *show_table_list= (TABLE_LIST*) sel.table_list.first;
2636
2662
            lex->all_selects_list= &sel;
2637
2663
            lex->derived_tables= 0;
2638
2664
            lex->sql_command= SQLCOM_SHOW_FIELDS;
2639
2665
            show_table_list->i_s_requested_object=
2640
2666
              schema_table->i_s_requested_object;
2641
2667
            res= open_normal_and_derived_tables(thd, show_table_list,
2642
 
                                                DRIZZLE_LOCK_IGNORE_FLUSH);
 
2668
                                                MYSQL_LOCK_IGNORE_FLUSH);
2643
2669
            lex->sql_command= save_sql_command;
2644
2670
            /*
2645
2671
              XXX:  show_table_list has a flag i_is_requested,
2703
2729
}
2704
2730
 
2705
2731
 
2706
 
bool store_schema_shemata(THD* thd, Table *table, LEX_STRING *db_name,
2707
 
                          const CHARSET_INFO * const cs)
 
2732
bool store_schema_shemata(THD* thd, TABLE *table, LEX_STRING *db_name,
 
2733
                          CHARSET_INFO *cs)
2708
2734
{
2709
2735
  restore_record(table, s->default_values);
2710
2736
  table->field[1]->store(db_name->str, db_name->length, system_charset_info);
2714
2740
}
2715
2741
 
2716
2742
 
2717
 
int fill_schema_schemata(THD *thd, TableList *tables, COND *cond)
 
2743
int fill_schema_schemata(THD *thd, TABLE_LIST *tables, COND *cond)
2718
2744
{
2719
2745
  /*
2720
2746
    TODO: fill_schema_shemata() is called when new client is connected.
2726
2752
  LEX_STRING *db_name;
2727
2753
  bool with_i_schema;
2728
2754
  HA_CREATE_INFO create;
2729
 
  Table *table= tables->table;
 
2755
  TABLE *table= tables->table;
2730
2756
 
2731
2757
  if (get_lookup_field_values(thd, cond, tables, &lookup_field_vals))
2732
2758
    return(0);
2741
2767
     !with_i_schema)
2742
2768
  {
2743
2769
    char path[FN_REFLEN+16];
2744
 
    uint32_t path_len;
 
2770
    uint path_len;
2745
2771
    struct stat stat_info;
2746
2772
    if (!lookup_field_vals.db_value.str[0])
2747
2773
      return(0);
2774
2800
}
2775
2801
 
2776
2802
 
2777
 
static int get_schema_tables_record(THD *thd, TableList *tables,
2778
 
                                    Table *table, bool res,
 
2803
static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
 
2804
                                    TABLE *table, bool res,
2779
2805
                                    LEX_STRING *db_name,
2780
2806
                                    LEX_STRING *table_name)
2781
2807
{
2782
2808
  const char *tmp_buff;
2783
 
  DRIZZLE_TIME time;
2784
 
  const CHARSET_INFO * const cs= system_charset_info;
 
2809
  MYSQL_TIME time;
 
2810
  CHARSET_INFO *cs= system_charset_info;
2785
2811
 
2786
2812
  restore_record(table, s->default_values);
2787
2813
  table->field[1]->store(db_name->str, db_name->length, cs);
2795
2821
    if (tables->schema_table)
2796
2822
      table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"), cs);
2797
2823
    else
2798
 
      table->field[3]->store(STRING_WITH_LEN("BASE Table"), cs);
 
2824
      table->field[3]->store(STRING_WITH_LEN("BASE TABLE"), cs);
2799
2825
    table->field[20]->store(error, strlen(error), cs);
2800
2826
    thd->clear_error();
2801
2827
  }
2802
2828
  else
2803
2829
  {
2804
 
    char option_buff[400],*ptr;
2805
 
    Table *show_table= tables->table;
 
2830
    char option_buff[350],*ptr;
 
2831
    TABLE *show_table= tables->table;
2806
2832
    TABLE_SHARE *share= show_table->s;
2807
2833
    handler *file= show_table->file;
2808
2834
    handlerton *tmp_db_type= share->db_type();
2811
2837
    else if (share->tmp_table)
2812
2838
      table->field[3]->store(STRING_WITH_LEN("LOCAL TEMPORARY"), cs);
2813
2839
    else
2814
 
      table->field[3]->store(STRING_WITH_LEN("BASE Table"), cs);
 
2840
      table->field[3]->store(STRING_WITH_LEN("BASE TABLE"), cs);
2815
2841
 
2816
2842
    for (int i= 4; i < 20; i++)
2817
2843
    {
2826
2852
    ptr=option_buff;
2827
2853
    if (share->min_rows)
2828
2854
    {
2829
 
      ptr=my_stpcpy(ptr," min_rows=");
 
2855
      ptr=strmov(ptr," min_rows=");
2830
2856
      ptr=int64_t10_to_str(share->min_rows,ptr,10);
2831
2857
    }
2832
2858
    if (share->max_rows)
2833
2859
    {
2834
 
      ptr=my_stpcpy(ptr," max_rows=");
 
2860
      ptr=strmov(ptr," max_rows=");
2835
2861
      ptr=int64_t10_to_str(share->max_rows,ptr,10);
2836
2862
    }
2837
2863
    if (share->avg_row_length)
2838
2864
    {
2839
 
      ptr=my_stpcpy(ptr," avg_row_length=");
 
2865
      ptr=strmov(ptr," avg_row_length=");
2840
2866
      ptr=int64_t10_to_str(share->avg_row_length,ptr,10);
2841
2867
    }
2842
2868
    if (share->db_create_options & HA_OPTION_PACK_KEYS)
2843
 
      ptr=my_stpcpy(ptr," pack_keys=1");
 
2869
      ptr=strmov(ptr," pack_keys=1");
2844
2870
    if (share->db_create_options & HA_OPTION_NO_PACK_KEYS)
2845
 
      ptr=my_stpcpy(ptr," pack_keys=0");
 
2871
      ptr=strmov(ptr," pack_keys=0");
2846
2872
    /* We use CHECKSUM, instead of TABLE_CHECKSUM, for backward compability */
2847
2873
    if (share->db_create_options & HA_OPTION_CHECKSUM)
2848
 
      ptr=my_stpcpy(ptr," checksum=1");
 
2874
      ptr=strmov(ptr," checksum=1");
2849
2875
    if (share->page_checksum != HA_CHOICE_UNDEF)
2850
2876
      ptr= strxmov(ptr, " page_checksum=",
2851
 
                   ha_choice_values[(uint) share->page_checksum], NULL);
 
2877
                   ha_choice_values[(uint) share->page_checksum], NullS);
2852
2878
    if (share->db_create_options & HA_OPTION_DELAY_KEY_WRITE)
2853
 
      ptr=my_stpcpy(ptr," delay_key_write=1");
 
2879
      ptr=strmov(ptr," delay_key_write=1");
2854
2880
    if (share->row_type != ROW_TYPE_DEFAULT)
2855
2881
      ptr=strxmov(ptr, " row_format=", 
2856
2882
                  ha_row_type[(uint) share->row_type],
2857
 
                  NULL);
2858
 
    if (share->block_size)
2859
 
    {
2860
 
      ptr= my_stpcpy(ptr, " block_size=");
2861
 
      ptr= int64_t10_to_str(share->block_size, ptr, 10);
2862
 
    }
2863
 
    
 
2883
                  NullS);
2864
2884
    if (share->transactional != HA_CHOICE_UNDEF)
2865
2885
    {
2866
2886
      ptr= strxmov(ptr, " TRANSACTIONAL=",
2867
2887
                   (share->transactional == HA_CHOICE_YES ? "1" : "0"),
2868
 
                   NULL);
 
2888
                   NullS);
2869
2889
    }
2870
2890
    if (share->transactional != HA_CHOICE_UNDEF)
2871
2891
      ptr= strxmov(ptr, " transactional=",
2872
 
                   ha_choice_values[(uint) share->transactional], NULL);
 
2892
                   ha_choice_values[(uint) share->transactional], NullS);
2873
2893
    table->field[19]->store(option_buff+1,
2874
2894
                            (ptr == option_buff ? 0 : 
2875
2895
                             (uint) (ptr-option_buff)-1), cs);
2938
2958
      {
2939
2959
        thd->variables.time_zone->gmt_sec_to_TIME(&time,
2940
2960
                                                  (my_time_t) file->stats.create_time);
2941
 
        table->field[14]->store_time(&time, DRIZZLE_TIMESTAMP_DATETIME);
 
2961
        table->field[14]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
2942
2962
        table->field[14]->set_notnull();
2943
2963
      }
2944
2964
      if (file->stats.update_time)
2945
2965
      {
2946
2966
        thd->variables.time_zone->gmt_sec_to_TIME(&time,
2947
2967
                                                  (my_time_t) file->stats.update_time);
2948
 
        table->field[15]->store_time(&time, DRIZZLE_TIMESTAMP_DATETIME);
 
2968
        table->field[15]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
2949
2969
        table->field[15]->set_notnull();
2950
2970
      }
2951
2971
      if (file->stats.check_time)
2952
2972
      {
2953
2973
        thd->variables.time_zone->gmt_sec_to_TIME(&time,
2954
2974
                                                  (my_time_t) file->stats.check_time);
2955
 
        table->field[16]->store_time(&time, DRIZZLE_TIMESTAMP_DATETIME);
 
2975
        table->field[16]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
2956
2976
        table->field[16]->set_notnull();
2957
2977
      }
2958
2978
      if (file->ha_table_flags() & (ulong) HA_HAS_CHECKSUM)
2978
2998
  @return         void
2979
2999
*/
2980
3000
 
2981
 
void store_column_type(Table *table, Field *field, const CHARSET_INFO * const cs,
2982
 
                       uint32_t offset)
 
3001
void store_column_type(TABLE *table, Field *field, CHARSET_INFO *cs,
 
3002
                       uint offset)
2983
3003
{
2984
3004
  bool is_blob;
2985
3005
  int decimals, field_length;
2996
3016
  table->field[offset]->store(column_type.ptr(),
2997
3017
                         (tmp_buff ? tmp_buff - column_type.ptr() :
2998
3018
                          column_type.length()), cs);
2999
 
  is_blob= (field->type() == DRIZZLE_TYPE_BLOB);
 
3019
  is_blob= (field->type() == MYSQL_TYPE_BLOB);
3000
3020
  if (field->has_charset() || is_blob ||
3001
 
      field->real_type() == DRIZZLE_TYPE_VARCHAR)  // For varbinary type
 
3021
      field->real_type() == MYSQL_TYPE_VARCHAR ||  // For varbinary type
 
3022
      field->real_type() == MYSQL_TYPE_STRING)     // For binary type
3002
3023
  {
3003
 
    uint32_t octet_max_length= field->max_display_length();
3004
 
    if (is_blob && octet_max_length != (uint32_t) 4294967295U)
 
3024
    uint32 octet_max_length= field->max_display_length();
 
3025
    if (is_blob && octet_max_length != (uint32) 4294967295U)
3005
3026
      octet_max_length /= field->charset()->mbmaxlen;
3006
3027
    int64_t char_max_len= is_blob ? 
3007
3028
      (int64_t) octet_max_length / field->charset()->mbminlen :
3021
3042
 
3022
3043
  decimals= field->decimals();
3023
3044
  switch (field->type()) {
3024
 
  case DRIZZLE_TYPE_NEWDECIMAL:
 
3045
  case MYSQL_TYPE_NEWDECIMAL:
3025
3046
    field_length= ((Field_new_decimal*) field)->precision;
3026
3047
    break;
3027
 
  case DRIZZLE_TYPE_TINY:
3028
 
  case DRIZZLE_TYPE_LONG:
3029
 
  case DRIZZLE_TYPE_LONGLONG:
 
3048
  case MYSQL_TYPE_TINY:
 
3049
  case MYSQL_TYPE_SHORT:
 
3050
  case MYSQL_TYPE_LONG:
 
3051
  case MYSQL_TYPE_LONGLONG:
3030
3052
    field_length= field->max_display_length() - 1;
3031
3053
    break;
3032
 
  case DRIZZLE_TYPE_DOUBLE:
 
3054
  case MYSQL_TYPE_DOUBLE:
3033
3055
    field_length= field->field_length;
3034
3056
    if (decimals == NOT_FIXED_DEC)
3035
3057
      decimals= -1;                           // return NULL
3065
3087
}
3066
3088
 
3067
3089
 
3068
 
static int get_schema_column_record(THD *thd, TableList *tables,
3069
 
                                    Table *table, bool res,
 
3090
static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
 
3091
                                    TABLE *table, bool res,
3070
3092
                                    LEX_STRING *db_name,
3071
3093
                                    LEX_STRING *table_name)
3072
3094
{
3073
3095
  LEX *lex= thd->lex;
3074
 
  const char *wild= lex->wild ? lex->wild->ptr() : NULL;
3075
 
  const CHARSET_INFO * const cs= system_charset_info;
3076
 
  Table *show_table;
 
3096
  const char *wild= lex->wild ? lex->wild->ptr() : NullS;
 
3097
  CHARSET_INFO *cs= system_charset_info;
 
3098
  TABLE *show_table;
3077
3099
  TABLE_SHARE *show_table_share;
3078
3100
  Field **ptr, *field, *timestamp_field;
3079
3101
  int count;
3087
3109
        rather than in SHOW COLUMNS
3088
3110
      */ 
3089
3111
      if (thd->is_error())
3090
 
        push_warning(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
3112
        push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
3091
3113
                     thd->main_da.sql_errno(), thd->main_da.message());
3092
3114
      thd->clear_error();
3093
3115
      res= 0;
3116
3138
    if (!show_table->read_set)
3117
3139
    {
3118
3140
      /* to satisfy 'field->val_str' ASSERTs */
3119
 
      unsigned char *bitmaps;
3120
 
      uint32_t bitmap_size= show_table_share->column_bitmap_size;
3121
 
      if (!(bitmaps= (unsigned char*) alloc_root(thd->mem_root, bitmap_size)))
 
3141
      uchar *bitmaps;
 
3142
      uint bitmap_size= show_table_share->column_bitmap_size;
 
3143
      if (!(bitmaps= (uchar*) alloc_root(thd->mem_root, bitmap_size)))
3122
3144
        return(0);
3123
3145
      bitmap_init(&show_table->def_read_set,
3124
3146
                  (my_bitmap_map*) bitmaps, show_table_share->fields, false);
3130
3152
 
3131
3153
  for (; (field= *ptr) ; ptr++)
3132
3154
  {
3133
 
    unsigned char *pos;
 
3155
    uchar *pos;
3134
3156
    char tmp[MAX_FIELD_WIDTH];
3135
3157
    String type(tmp,sizeof(tmp), system_charset_info);
3136
3158
    char *end;
3158
3180
      table->field[5]->store(type.ptr(), type.length(), cs);
3159
3181
      table->field[5]->set_notnull();
3160
3182
    }
3161
 
    pos=(unsigned char*) ((field->flags & NOT_NULL_FLAG) ?  "NO" : "YES");
 
3183
    pos=(uchar*) ((field->flags & NOT_NULL_FLAG) ?  "NO" : "YES");
3162
3184
    table->field[6]->store((const char*) pos,
3163
3185
                           strlen((const char*) pos), cs);
3164
3186
    store_column_type(table, field, cs, 7);
3165
3187
 
3166
 
    pos=(unsigned char*) ((field->flags & PRI_KEY_FLAG) ? "PRI" :
 
3188
    pos=(uchar*) ((field->flags & PRI_KEY_FLAG) ? "PRI" :
3167
3189
                 (field->flags & UNIQUE_KEY_FLAG) ? "UNI" :
3168
3190
                 (field->flags & MULTIPLE_KEY_FLAG) ? "MUL":"");
3169
3191
    table->field[15]->store((const char*) pos,
3181
3203
    {
3182
3204
      enum column_format_type column_format= (enum column_format_type)
3183
3205
        ((field->flags >> COLUMN_FORMAT_FLAGS) & COLUMN_FORMAT_MASK);
3184
 
      pos=(unsigned char*)"Default";
 
3206
      pos=(uchar*)"Default";
3185
3207
      table->field[19]->store((const char*) pos,
3186
3208
                              strlen((const char*) pos), cs);
3187
 
      pos=(unsigned char*)(column_format == COLUMN_FORMAT_TYPE_DEFAULT ? "Default" :
 
3209
      pos=(uchar*)(column_format == COLUMN_FORMAT_TYPE_DEFAULT ? "Default" :
3188
3210
                   column_format == COLUMN_FORMAT_TYPE_FIXED ? "Fixed" :
3189
3211
                                                             "Dynamic");
3190
3212
      table->field[20]->store((const char*) pos,
3198
3220
 
3199
3221
 
3200
3222
 
3201
 
int fill_schema_charsets(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
 
3223
int fill_schema_charsets(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((__unused__)))
3202
3224
{
3203
3225
  CHARSET_INFO **cs;
3204
 
  const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NULL;
3205
 
  Table *table= tables->table;
3206
 
  const CHARSET_INFO * const scs= system_charset_info;
 
3226
  const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
 
3227
  TABLE *table= tables->table;
 
3228
  CHARSET_INFO *scs= system_charset_info;
3207
3229
 
3208
3230
  for (cs= all_charsets ; cs < all_charsets+255 ; cs++)
3209
3231
  {
3210
 
    const CHARSET_INFO * const tmp_cs= cs[0];
 
3232
    CHARSET_INFO *tmp_cs= cs[0];
3211
3233
    if (tmp_cs && (tmp_cs->state & MY_CS_PRIMARY) && 
3212
3234
        (tmp_cs->state & MY_CS_AVAILABLE) &&
3213
3235
        !(tmp_cs->state & MY_CS_HIDDEN) &&
3214
3236
        !(wild && wild[0] &&
3215
 
          wild_case_compare(scs, tmp_cs->csname,wild)))
 
3237
          wild_case_compare(scs, tmp_cs->csname,wild)))
3216
3238
    {
3217
3239
      const char *comment;
3218
3240
      restore_record(table, s->default_values);
3229
3251
}
3230
3252
 
3231
3253
 
3232
 
int fill_schema_collation(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
 
3254
int fill_schema_collation(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((__unused__)))
3233
3255
{
3234
3256
  CHARSET_INFO **cs;
3235
 
  const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NULL;
3236
 
  Table *table= tables->table;
3237
 
  const CHARSET_INFO * const scs= system_charset_info;
 
3257
  const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
 
3258
  TABLE *table= tables->table;
 
3259
  CHARSET_INFO *scs= system_charset_info;
3238
3260
  for (cs= all_charsets ; cs < all_charsets+255 ; cs++ )
3239
3261
  {
3240
3262
    CHARSET_INFO **cl;
3241
 
    const CHARSET_INFO *tmp_cs= cs[0];
 
3263
    CHARSET_INFO *tmp_cs= cs[0];
3242
3264
    if (!tmp_cs || !(tmp_cs->state & MY_CS_AVAILABLE) ||
3243
3265
         (tmp_cs->state & MY_CS_HIDDEN) ||
3244
3266
        !(tmp_cs->state & MY_CS_PRIMARY))
3245
3267
      continue;
3246
3268
    for (cl= all_charsets; cl < all_charsets+255 ;cl ++)
3247
3269
    {
3248
 
      const CHARSET_INFO *tmp_cl= cl[0];
 
3270
      CHARSET_INFO *tmp_cl= cl[0];
3249
3271
      if (!tmp_cl || !(tmp_cl->state & MY_CS_AVAILABLE) || 
3250
3272
          !my_charset_same(tmp_cs, tmp_cl))
3251
 
        continue;
 
3273
        continue;
3252
3274
      if (!(wild && wild[0] &&
3253
 
          wild_case_compare(scs, tmp_cl->name,wild)))
 
3275
          wild_case_compare(scs, tmp_cl->name,wild)))
3254
3276
      {
3255
 
        const char *tmp_buff;
3256
 
        restore_record(table, s->default_values);
3257
 
        table->field[0]->store(tmp_cl->name, strlen(tmp_cl->name), scs);
 
3277
        const char *tmp_buff;
 
3278
        restore_record(table, s->default_values);
 
3279
        table->field[0]->store(tmp_cl->name, strlen(tmp_cl->name), scs);
3258
3280
        table->field[1]->store(tmp_cl->csname , strlen(tmp_cl->csname), scs);
3259
3281
        table->field[2]->store((int64_t) tmp_cl->number, true);
3260
3282
        tmp_buff= (tmp_cl->state & MY_CS_PRIMARY) ? "Yes" : "";
3261
 
        table->field[3]->store(tmp_buff, strlen(tmp_buff), scs);
 
3283
        table->field[3]->store(tmp_buff, strlen(tmp_buff), scs);
3262
3284
        tmp_buff= (tmp_cl->state & MY_CS_COMPILED)? "Yes" : "";
3263
 
        table->field[4]->store(tmp_buff, strlen(tmp_buff), scs);
 
3285
        table->field[4]->store(tmp_buff, strlen(tmp_buff), scs);
3264
3286
        table->field[5]->store((int64_t) tmp_cl->strxfrm_multiply, true);
3265
3287
        if (schema_table_store_record(thd, table))
3266
3288
          return 1;
3271
3293
}
3272
3294
 
3273
3295
 
3274
 
int fill_schema_coll_charset_app(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
 
3296
int fill_schema_coll_charset_app(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((__unused__)))
3275
3297
{
3276
3298
  CHARSET_INFO **cs;
3277
 
  Table *table= tables->table;
3278
 
  const CHARSET_INFO * const scs= system_charset_info;
 
3299
  TABLE *table= tables->table;
 
3300
  CHARSET_INFO *scs= system_charset_info;
3279
3301
  for (cs= all_charsets ; cs < all_charsets+255 ; cs++ )
3280
3302
  {
3281
3303
    CHARSET_INFO **cl;
3282
 
    const CHARSET_INFO *tmp_cs= cs[0];
 
3304
    CHARSET_INFO *tmp_cs= cs[0];
3283
3305
    if (!tmp_cs || !(tmp_cs->state & MY_CS_AVAILABLE) || 
3284
3306
        !(tmp_cs->state & MY_CS_PRIMARY))
3285
3307
      continue;
3286
3308
    for (cl= all_charsets; cl < all_charsets+255 ;cl ++)
3287
3309
    {
3288
 
      const CHARSET_INFO *tmp_cl= cl[0];
 
3310
      CHARSET_INFO *tmp_cl= cl[0];
3289
3311
      if (!tmp_cl || !(tmp_cl->state & MY_CS_AVAILABLE) || 
3290
3312
          !my_charset_same(tmp_cs,tmp_cl))
3291
3313
        continue;
3300
3322
}
3301
3323
 
3302
3324
 
3303
 
static int get_schema_stat_record(THD *thd, TableList *tables,
3304
 
                                  Table *table, bool res,
 
3325
static int get_schema_stat_record(THD *thd, TABLE_LIST *tables,
 
3326
                                  TABLE *table, bool res,
3305
3327
                                  LEX_STRING *db_name,
3306
3328
                                  LEX_STRING *table_name)
3307
3329
{
3308
 
  const CHARSET_INFO * const cs= system_charset_info;
 
3330
  CHARSET_INFO *cs= system_charset_info;
3309
3331
  if (res)
3310
3332
  {
3311
3333
    if (thd->lex->sql_command != SQLCOM_SHOW_KEYS)
3315
3337
        rather than in SHOW KEYS
3316
3338
      */
3317
3339
      if (thd->is_error())
3318
 
        push_warning(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
3340
        push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
3319
3341
                     thd->main_da.sql_errno(), thd->main_da.message());
3320
3342
      thd->clear_error();
3321
3343
      res= 0;
3324
3346
  }
3325
3347
  else
3326
3348
  {
3327
 
    Table *show_table= tables->table;
 
3349
    TABLE *show_table= tables->table;
3328
3350
    KEY *key_info=show_table->s->key_info;
3329
3351
    if (show_table->file)
3330
3352
      show_table->file->info(HA_STATUS_VARIABLE |
3331
3353
                             HA_STATUS_NO_LOCK |
3332
3354
                             HA_STATUS_TIME);
3333
 
    for (uint32_t i=0 ; i < show_table->s->keys ; i++,key_info++)
 
3355
    for (uint i=0 ; i < show_table->s->keys ; i++,key_info++)
3334
3356
    {
3335
3357
      KEY_PART_INFO *key_part= key_info->key_part;
3336
3358
      const char *str;
3337
 
      for (uint32_t j=0 ; j < key_info->key_parts ; j++,key_part++)
 
3359
      for (uint j=0 ; j < key_info->key_parts ; j++,key_part++)
3338
3360
      {
3339
3361
        restore_record(table, s->default_values);
3340
3362
        table->field[1]->store(db_name->str, db_name->length, cs);
3375
3397
                                  key_part->field->charset()->mbmaxlen, true);
3376
3398
          table->field[10]->set_notnull();
3377
3399
        }
3378
 
        uint32_t flags= key_part->field ? key_part->field->flags : 0;
 
3400
        uint flags= key_part->field ? key_part->field->flags : 0;
3379
3401
        const char *pos=(char*) ((flags & NOT_NULL_FLAG) ? "" : "YES");
3380
3402
        table->field[12]->store(pos, strlen(pos), cs);
3381
3403
        if (!show_table->s->keys_in_use.is_set(i))
3397
3419
}
3398
3420
 
3399
3421
 
3400
 
bool store_constraints(THD *thd, Table *table, LEX_STRING *db_name,
 
3422
bool store_constraints(THD *thd, TABLE *table, LEX_STRING *db_name,
3401
3423
                       LEX_STRING *table_name, const char *key_name,
3402
 
                       uint32_t key_len, const char *con_type, uint32_t con_len)
 
3424
                       uint key_len, const char *con_type, uint con_len)
3403
3425
{
3404
 
  const CHARSET_INFO * const cs= system_charset_info;
 
3426
  CHARSET_INFO *cs= system_charset_info;
3405
3427
  restore_record(table, s->default_values);
3406
3428
  table->field[1]->store(db_name->str, db_name->length, cs);
3407
3429
  table->field[2]->store(key_name, key_len, cs);
3412
3434
}
3413
3435
 
3414
3436
 
3415
 
static int get_schema_constraints_record(THD *thd, TableList *tables,
3416
 
                                         Table *table, bool res,
 
3437
static int get_schema_constraints_record(THD *thd, TABLE_LIST *tables,
 
3438
                                         TABLE *table, bool res,
3417
3439
                                         LEX_STRING *db_name,
3418
3440
                                         LEX_STRING *table_name)
3419
3441
{
3420
3442
  if (res)
3421
3443
  {
3422
3444
    if (thd->is_error())
3423
 
      push_warning(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
3445
      push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
3424
3446
                   thd->main_da.sql_errno(), thd->main_da.message());
3425
3447
    thd->clear_error();
3426
3448
    return(0);
3428
3450
  else
3429
3451
  {
3430
3452
    List<FOREIGN_KEY_INFO> f_key_list;
3431
 
    Table *show_table= tables->table;
 
3453
    TABLE *show_table= tables->table;
3432
3454
    KEY *key_info=show_table->key_info;
3433
 
    uint32_t primary_key= show_table->s->primary_key;
 
3455
    uint primary_key= show_table->s->primary_key;
3434
3456
    show_table->file->info(HA_STATUS_VARIABLE | 
3435
3457
                           HA_STATUS_NO_LOCK |
3436
3458
                           HA_STATUS_TIME);
3437
 
    for (uint32_t i=0 ; i < show_table->s->keys ; i++, key_info++)
 
3459
    for (uint i=0 ; i < show_table->s->keys ; i++, key_info++)
3438
3460
    {
3439
3461
      if (i != primary_key && !(key_info->flags & HA_NOSAME))
3440
3462
        continue;
3471
3493
}
3472
3494
 
3473
3495
 
3474
 
void store_key_column_usage(Table *table, LEX_STRING *db_name,
 
3496
void store_key_column_usage(TABLE *table, LEX_STRING *db_name,
3475
3497
                            LEX_STRING *table_name, const char *key_name,
3476
 
                            uint32_t key_len, const char *con_type, uint32_t con_len,
 
3498
                            uint key_len, const char *con_type, uint con_len,
3477
3499
                            int64_t idx)
3478
3500
{
3479
 
  const CHARSET_INFO * const cs= system_charset_info;
 
3501
  CHARSET_INFO *cs= system_charset_info;
3480
3502
  table->field[1]->store(db_name->str, db_name->length, cs);
3481
3503
  table->field[2]->store(key_name, key_len, cs);
3482
3504
  table->field[4]->store(db_name->str, db_name->length, cs);
3487
3509
 
3488
3510
 
3489
3511
static int get_schema_key_column_usage_record(THD *thd,
3490
 
                                              TableList *tables,
3491
 
                                              Table *table, bool res,
 
3512
                                              TABLE_LIST *tables,
 
3513
                                              TABLE *table, bool res,
3492
3514
                                              LEX_STRING *db_name,
3493
3515
                                              LEX_STRING *table_name)
3494
3516
{
3495
3517
  if (res)
3496
3518
  {
3497
3519
    if (thd->is_error())
3498
 
      push_warning(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
3520
      push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
3499
3521
                   thd->main_da.sql_errno(), thd->main_da.message());
3500
3522
    thd->clear_error();
3501
3523
    return(0);
3503
3525
  else
3504
3526
  {
3505
3527
    List<FOREIGN_KEY_INFO> f_key_list;
3506
 
    Table *show_table= tables->table;
 
3528
    TABLE *show_table= tables->table;
3507
3529
    KEY *key_info=show_table->key_info;
3508
 
    uint32_t primary_key= show_table->s->primary_key;
 
3530
    uint primary_key= show_table->s->primary_key;
3509
3531
    show_table->file->info(HA_STATUS_VARIABLE | 
3510
3532
                           HA_STATUS_NO_LOCK |
3511
3533
                           HA_STATUS_TIME);
3512
 
    for (uint32_t i=0 ; i < show_table->s->keys ; i++, key_info++)
 
3534
    for (uint i=0 ; i < show_table->s->keys ; i++, key_info++)
3513
3535
    {
3514
3536
      if (i != primary_key && !(key_info->flags & HA_NOSAME))
3515
3537
        continue;
3516
 
      uint32_t f_idx= 0;
 
3538
      uint f_idx= 0;
3517
3539
      KEY_PART_INFO *key_part= key_info->key_part;
3518
 
      for (uint32_t j=0 ; j < key_info->key_parts ; j++,key_part++)
 
3540
      for (uint j=0 ; j < key_info->key_parts ; j++,key_part++)
3519
3541
      {
3520
3542
        if (key_part->field)
3521
3543
        {
3542
3564
      LEX_STRING *r_info;
3543
3565
      List_iterator_fast<LEX_STRING> it(f_key_info->foreign_fields),
3544
3566
        it1(f_key_info->referenced_fields);
3545
 
      uint32_t f_idx= 0;
 
3567
      uint f_idx= 0;
3546
3568
      while ((f_info= it++))
3547
3569
      {
3548
3570
        r_info= it1++;
3575
3597
}
3576
3598
 
3577
3599
 
3578
 
int fill_open_tables(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
 
3600
int fill_open_tables(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((__unused__)))
3579
3601
{
3580
 
  const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NULL;
3581
 
  Table *table= tables->table;
3582
 
  const CHARSET_INFO * const cs= system_charset_info;
3583
 
  OPEN_TableList *open_list;
 
3602
  const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
 
3603
  TABLE *table= tables->table;
 
3604
  CHARSET_INFO *cs= system_charset_info;
 
3605
  OPEN_TABLE_LIST *open_list;
3584
3606
  if (!(open_list=list_open_tables(thd,thd->lex->select_lex.db, wild))
3585
3607
            && thd->is_fatal_error)
3586
3608
    return(1);
3599
3621
}
3600
3622
 
3601
3623
 
3602
 
int fill_variables(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
 
3624
int fill_variables(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((__unused__)))
3603
3625
{
3604
3626
  int res= 0;
3605
3627
  LEX *lex= thd->lex;
3606
 
  const char *wild= lex->wild ? lex->wild->ptr() : NULL;
 
3628
  const char *wild= lex->wild ? lex->wild->ptr() : NullS;
3607
3629
  enum enum_schema_tables schema_table_idx=
3608
3630
    get_schema_table_idx(tables->schema_table);
3609
3631
  enum enum_var_type option_type= OPT_SESSION;
3622
3644
}
3623
3645
 
3624
3646
 
3625
 
int fill_status(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
 
3647
int fill_status(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((__unused__)))
3626
3648
{
3627
3649
  LEX *lex= thd->lex;
3628
 
  const char *wild= lex->wild ? lex->wild->ptr() : NULL;
 
3650
  const char *wild= lex->wild ? lex->wild->ptr() : NullS;
3629
3651
  int res= 0;
3630
3652
  STATUS_VAR *tmp1, tmp;
3631
3653
  enum enum_schema_tables schema_table_idx=
3683
3705
*/
3684
3706
 
3685
3707
static int
3686
 
get_referential_constraints_record(THD *thd, TableList *tables,
3687
 
                                   Table *table, bool res,
 
3708
get_referential_constraints_record(THD *thd, TABLE_LIST *tables,
 
3709
                                   TABLE *table, bool res,
3688
3710
                                   LEX_STRING *db_name, LEX_STRING *table_name)
3689
3711
{
3690
 
  const CHARSET_INFO * const cs= system_charset_info;
 
3712
  CHARSET_INFO *cs= system_charset_info;
3691
3713
 
3692
3714
  if (res)
3693
3715
  {
3694
3716
    if (thd->is_error())
3695
 
      push_warning(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
3717
      push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
3696
3718
                   thd->main_da.sql_errno(), thd->main_da.message());
3697
3719
    thd->clear_error();
3698
3720
    return(0);
3700
3722
 
3701
3723
  {
3702
3724
    List<FOREIGN_KEY_INFO> f_key_list;
3703
 
    Table *show_table= tables->table;
 
3725
    TABLE *show_table= tables->table;
3704
3726
    show_table->file->info(HA_STATUS_VARIABLE | 
3705
3727
                           HA_STATUS_NO_LOCK |
3706
3728
                           HA_STATUS_TIME);
3760
3782
    0   table not found
3761
3783
    1   found the schema table
3762
3784
*/
3763
 
static bool find_schema_table_in_plugin(THD *thd __attribute__((unused)),
 
3785
static bool find_schema_table_in_plugin(THD *thd __attribute__((__unused__)),
3764
3786
                                           plugin_ref plugin,
3765
3787
                                           void* p_table)
3766
3788
{
3807
3829
 
3808
3830
  schema_table_a.table_name= table_name;
3809
3831
  if (plugin_foreach(thd, find_schema_table_in_plugin, 
3810
 
                     DRIZZLE_INFORMATION_SCHEMA_PLUGIN, &schema_table_a))
 
3832
                     MYSQL_INFORMATION_SCHEMA_PLUGIN, &schema_table_a))
3811
3833
    return(schema_table_a.schema_table);
3812
3834
 
3813
3835
  return(NULL);
3835
3857
  @retval  NULL           Can't create table
3836
3858
*/
3837
3859
 
3838
 
Table *create_schema_table(THD *thd, TableList *table_list)
 
3860
TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
3839
3861
{
3840
3862
  int field_count= 0;
3841
3863
  Item *item;
3842
 
  Table *table;
 
3864
  TABLE *table;
3843
3865
  List<Item> field_list;
3844
3866
  ST_SCHEMA_TABLE *schema_table= table_list->schema_table;
3845
3867
  ST_FIELD_INFO *fields_info= schema_table->fields_info;
3846
 
  const CHARSET_INFO * const cs= system_charset_info;
 
3868
  CHARSET_INFO *cs= system_charset_info;
3847
3869
 
3848
3870
  for (; fields_info->field_name; fields_info++)
3849
3871
  {
3850
3872
    switch (fields_info->field_type) {
3851
 
    case DRIZZLE_TYPE_TINY:
3852
 
    case DRIZZLE_TYPE_LONG:
3853
 
    case DRIZZLE_TYPE_LONGLONG:
 
3873
    case MYSQL_TYPE_TINY:
 
3874
    case MYSQL_TYPE_LONG:
 
3875
    case MYSQL_TYPE_SHORT:
 
3876
    case MYSQL_TYPE_LONGLONG:
3854
3877
      if (!(item= new Item_return_int(fields_info->field_name,
3855
3878
                                      fields_info->field_length,
3856
3879
                                      fields_info->field_type,
3860
3883
      }
3861
3884
      item->unsigned_flag= (fields_info->field_flags & MY_I_S_UNSIGNED);
3862
3885
      break;
3863
 
    case DRIZZLE_TYPE_NEWDATE:
3864
 
    case DRIZZLE_TYPE_TIME:
3865
 
    case DRIZZLE_TYPE_TIMESTAMP:
3866
 
    case DRIZZLE_TYPE_DATETIME:
 
3886
    case MYSQL_TYPE_NEWDATE:
 
3887
    case MYSQL_TYPE_TIME:
 
3888
    case MYSQL_TYPE_TIMESTAMP:
 
3889
    case MYSQL_TYPE_DATETIME:
3867
3890
      if (!(item=new Item_return_date_time(fields_info->field_name,
3868
3891
                                           fields_info->field_type)))
3869
3892
      {
3870
3893
        return(0);
3871
3894
      }
3872
3895
      break;
3873
 
    case DRIZZLE_TYPE_DOUBLE:
 
3896
    case MYSQL_TYPE_DOUBLE:
3874
3897
      if ((item= new Item_float(fields_info->field_name, 0.0, NOT_FIXED_DEC, 
3875
3898
                           fields_info->field_length)) == NULL)
3876
3899
        return(NULL);
3877
3900
      break;
3878
 
    case DRIZZLE_TYPE_NEWDECIMAL:
 
3901
    case MYSQL_TYPE_NEWDECIMAL:
3879
3902
      if (!(item= new Item_decimal((int64_t) fields_info->value, false)))
3880
3903
      {
3881
3904
        return(0);
3890
3913
      item->set_name(fields_info->field_name,
3891
3914
                     strlen(fields_info->field_name), cs);
3892
3915
      break;
3893
 
    case DRIZZLE_TYPE_BLOB:
 
3916
    case MYSQL_TYPE_BLOB:
3894
3917
      if (!(item= new Item_blob(fields_info->field_name,
3895
3918
                                fields_info->field_length)))
3896
3919
      {
3898
3921
      }
3899
3922
      break;
3900
3923
    default:
 
3924
      /* Don't let unimplemented types pass through. Could be a grave error. */
 
3925
      assert(fields_info->field_type == MYSQL_TYPE_STRING);
 
3926
 
3901
3927
      if (!(item= new Item_empty_string("", fields_info->field_length, cs)))
3902
3928
      {
3903
3929
        return(0);
3918
3944
  tmp_table_param->schema_table= 1;
3919
3945
  SELECT_LEX *select_lex= thd->lex->current_select;
3920
3946
  if (!(table= create_tmp_table(thd, tmp_table_param,
3921
 
                                field_list, (order_st*) 0, 0, 0, 
 
3947
                                field_list, (ORDER*) 0, 0, 0, 
3922
3948
                                (select_lex->options | thd->options |
3923
3949
                                 TMP_TABLE_ALL_COLUMNS),
3924
3950
                                HA_POS_ERROR, table_list->alias)))
3958
3984
    if (field_info->old_name)
3959
3985
    {
3960
3986
      Item_field *field= new Item_field(context,
3961
 
                                        NULL, NULL, field_info->field_name);
 
3987
                                        NullS, NullS, field_info->field_name);
3962
3988
      if (field)
3963
3989
      {
3964
3990
        field->set_name(field_info->old_name,
3985
4011
    ST_FIELD_INFO *field_info= &schema_table->fields_info[1];
3986
4012
    String buffer(tmp,sizeof(tmp), system_charset_info);
3987
4013
    Item_field *field= new Item_field(context,
3988
 
                                      NULL, NULL, field_info->field_name);
 
4014
                                      NullS, NullS, field_info->field_name);
3989
4015
    if (!field || add_item_to_list(thd, field))
3990
4016
      return 1;
3991
4017
    buffer.length(0);
4020
4046
    buffer.append(')');
4021
4047
  }
4022
4048
  Item_field *field= new Item_field(context,
4023
 
                                    NULL, NULL, field_info->field_name);
 
4049
                                    NullS, NullS, field_info->field_name);
4024
4050
  if (add_item_to_list(thd, field))
4025
4051
    return 1;
4026
4052
  field->set_name(buffer.ptr(), buffer.length(), system_charset_info);
4028
4054
  {
4029
4055
    field->set_name(buffer.ptr(), buffer.length(), system_charset_info);
4030
4056
    field_info= &schema_table->fields_info[3];
4031
 
    field= new Item_field(context, NULL, NULL, field_info->field_name);
 
4057
    field= new Item_field(context, NullS, NullS, field_info->field_name);
4032
4058
    if (add_item_to_list(thd, field))
4033
4059
      return 1;
4034
4060
    field->set_name(field_info->old_name, strlen(field_info->old_name),
4053
4079
                               *field_num == 18))
4054
4080
      continue;
4055
4081
    Item_field *field= new Item_field(context,
4056
 
                                      NULL, NULL, field_info->field_name);
 
4082
                                      NullS, NullS, field_info->field_name);
4057
4083
    if (field)
4058
4084
    {
4059
4085
      field->set_name(field_info->old_name,
4078
4104
  {
4079
4105
    field_info= &schema_table->fields_info[*field_num];
4080
4106
    Item_field *field= new Item_field(context,
4081
 
                                      NULL, NULL, field_info->field_name);
 
4107
                                      NullS, NullS, field_info->field_name);
4082
4108
    if (field)
4083
4109
    {
4084
4110
      field->set_name(field_info->old_name,
4106
4132
    1   error
4107
4133
*/
4108
4134
 
4109
 
int mysql_schema_table(THD *thd, LEX *lex, TableList *table_list)
 
4135
int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list)
4110
4136
{
4111
 
  Table *table;
 
4137
  TABLE *table;
4112
4138
  if (!(table= table_list->schema_table->create_table(thd, table_list)))
4113
4139
    return(1);
4114
4140
  table->s->tmp_table= SYSTEM_TMP_TABLE;
4149
4175
    }
4150
4176
    List_iterator_fast<Item> it(sel->item_list);
4151
4177
    if (!(transl=
4152
 
          (Field_translator*)(thd->alloc(sel->item_list.elements *
 
4178
          (Field_translator*)(thd->stmt_arena->
 
4179
                              alloc(sel->item_list.elements *
4153
4180
                                    sizeof(Field_translator)))))
4154
4181
    {
4155
4182
      return(1);
4235
4262
    if (!tab->table || !tab->table->pos_in_table_list)
4236
4263
      break;
4237
4264
 
4238
 
    TableList *table_list= tab->table->pos_in_table_list;
 
4265
    TABLE_LIST *table_list= tab->table->pos_in_table_list;
4239
4266
    if (table_list->schema_table)
4240
4267
    {
4241
4268
      bool is_subselect= (&lex->unit != lex->current_select->master_unit() &&
4296
4323
 
4297
4324
ST_FIELD_INFO schema_fields_info[]=
4298
4325
{
4299
 
  {"CATALOG_NAME", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, SKIP_OPEN_TABLE},
4300
 
  {"SCHEMA_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Database",
4301
 
   SKIP_OPEN_TABLE},
4302
 
  {"DEFAULT_CHARACTER_SET_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4303
 
   SKIP_OPEN_TABLE},
4304
 
  {"DEFAULT_COLLATION_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE},
4305
 
  {"SQL_PATH", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, SKIP_OPEN_TABLE},
4306
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4326
  {"CATALOG_NAME", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
 
4327
  {"SCHEMA_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Database",
 
4328
   SKIP_OPEN_TABLE},
 
4329
  {"DEFAULT_CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 0, 0,
 
4330
   SKIP_OPEN_TABLE},
 
4331
  {"DEFAULT_COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4332
  {"SQL_PATH", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
 
4333
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4307
4334
};
4308
4335
 
4309
4336
 
4310
4337
ST_FIELD_INFO tables_fields_info[]=
4311
4338
{
4312
 
  {"TABLE_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, SKIP_OPEN_TABLE},
4313
 
  {"TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE},
4314
 
  {"TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Name",
 
4339
  {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
 
4340
  {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4341
  {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Name",
4315
4342
   SKIP_OPEN_TABLE},
4316
 
  {"TABLE_TYPE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FRM_ONLY},
4317
 
  {"ENGINE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, "Engine", OPEN_FRM_ONLY},
4318
 
  {"VERSION", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
 
4343
  {"TABLE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
 
4344
  {"ENGINE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, "Engine", OPEN_FRM_ONLY},
 
4345
  {"VERSION", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
4319
4346
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Version", OPEN_FRM_ONLY},
4320
 
  {"ROW_FORMAT", 10, DRIZZLE_TYPE_VARCHAR, 0, 1, "Row_format", OPEN_FULL_TABLE},
4321
 
  {"TABLE_ROWS", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
 
4347
  {"ROW_FORMAT", 10, MYSQL_TYPE_STRING, 0, 1, "Row_format", OPEN_FULL_TABLE},
 
4348
  {"TABLE_ROWS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
4322
4349
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Rows", OPEN_FULL_TABLE},
4323
 
  {"AVG_ROW_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0, 
 
4350
  {"AVG_ROW_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 
4324
4351
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Avg_row_length", OPEN_FULL_TABLE},
4325
 
  {"DATA_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0, 
 
4352
  {"DATA_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 
4326
4353
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Data_length", OPEN_FULL_TABLE},
4327
 
  {"MAX_DATA_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
 
4354
  {"MAX_DATA_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
4328
4355
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Max_data_length", OPEN_FULL_TABLE},
4329
 
  {"INDEX_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0, 
 
4356
  {"INDEX_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 
4330
4357
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Index_length", OPEN_FULL_TABLE},
4331
 
  {"DATA_FREE", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
 
4358
  {"DATA_FREE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
4332
4359
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Data_free", OPEN_FULL_TABLE},
4333
 
  {"AUTO_INCREMENT", MY_INT64_NUM_DECIMAL_DIGITS , DRIZZLE_TYPE_LONGLONG, 0, 
 
4360
  {"AUTO_INCREMENT", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONGLONG, 0, 
4334
4361
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Auto_increment", OPEN_FULL_TABLE},
4335
 
  {"CREATE_TIME", 0, DRIZZLE_TYPE_DATETIME, 0, 1, "Create_time", OPEN_FULL_TABLE},
4336
 
  {"UPDATE_TIME", 0, DRIZZLE_TYPE_DATETIME, 0, 1, "Update_time", OPEN_FULL_TABLE},
4337
 
  {"CHECK_TIME", 0, DRIZZLE_TYPE_DATETIME, 0, 1, "Check_time", OPEN_FULL_TABLE},
4338
 
  {"TABLE_COLLATION", 64, DRIZZLE_TYPE_VARCHAR, 0, 1, "Collation", OPEN_FRM_ONLY},
4339
 
  {"CHECKSUM", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
 
4362
  {"CREATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, "Create_time", OPEN_FULL_TABLE},
 
4363
  {"UPDATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, "Update_time", OPEN_FULL_TABLE},
 
4364
  {"CHECK_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, "Check_time", OPEN_FULL_TABLE},
 
4365
  {"TABLE_COLLATION", 64, MYSQL_TYPE_STRING, 0, 1, "Collation", OPEN_FRM_ONLY},
 
4366
  {"CHECKSUM", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
4340
4367
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Checksum", OPEN_FULL_TABLE},
4341
 
  {"CREATE_OPTIONS", 255, DRIZZLE_TYPE_VARCHAR, 0, 1, "Create_options",
 
4368
  {"CREATE_OPTIONS", 255, MYSQL_TYPE_STRING, 0, 1, "Create_options",
4342
4369
   OPEN_FRM_ONLY},
4343
 
  {"TABLE_COMMENT", TABLE_COMMENT_MAXLEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Comment", OPEN_FRM_ONLY},
4344
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4370
  {"TABLE_COMMENT", TABLE_COMMENT_MAXLEN, MYSQL_TYPE_STRING, 0, 0, "Comment", OPEN_FRM_ONLY},
 
4371
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4345
4372
};
4346
4373
 
4347
4374
 
4348
4375
ST_FIELD_INFO columns_fields_info[]=
4349
4376
{
4350
 
  {"TABLE_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, OPEN_FRM_ONLY},
4351
 
  {"TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FRM_ONLY},
4352
 
  {"TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FRM_ONLY},
4353
 
  {"COLUMN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Field",
 
4377
  {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FRM_ONLY},
 
4378
  {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
 
4379
  {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
 
4380
  {"COLUMN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Field",
4354
4381
   OPEN_FRM_ONLY},
4355
 
  {"ORDINAL_POSITION", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
 
4382
  {"ORDINAL_POSITION", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
4356
4383
   MY_I_S_UNSIGNED, 0, OPEN_FRM_ONLY},
4357
 
  {"COLUMN_DEFAULT", MAX_FIELD_VARCHARLENGTH, DRIZZLE_TYPE_VARCHAR, 0,
 
4384
  {"COLUMN_DEFAULT", MAX_FIELD_VARCHARLENGTH, MYSQL_TYPE_STRING, 0,
4358
4385
   1, "Default", OPEN_FRM_ONLY},
4359
 
  {"IS_NULLABLE", 3, DRIZZLE_TYPE_VARCHAR, 0, 0, "Null", OPEN_FRM_ONLY},
4360
 
  {"DATA_TYPE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FRM_ONLY},
4361
 
  {"CHARACTER_MAXIMUM_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG,
4362
 
   0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
4363
 
  {"CHARACTER_OCTET_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS , DRIZZLE_TYPE_LONGLONG,
4364
 
   0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
4365
 
  {"NUMERIC_PRECISION", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG,
4366
 
   0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
4367
 
  {"NUMERIC_SCALE", MY_INT64_NUM_DECIMAL_DIGITS , DRIZZLE_TYPE_LONGLONG,
4368
 
   0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
4369
 
  {"CHARACTER_SET_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, OPEN_FRM_ONLY},
4370
 
  {"COLLATION_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 1, "Collation", OPEN_FRM_ONLY},
4371
 
  {"COLUMN_TYPE", 65535, DRIZZLE_TYPE_VARCHAR, 0, 0, "Type", OPEN_FRM_ONLY},
4372
 
  {"COLUMN_KEY", 3, DRIZZLE_TYPE_VARCHAR, 0, 0, "Key", OPEN_FRM_ONLY},
4373
 
  {"EXTRA", 27, DRIZZLE_TYPE_VARCHAR, 0, 0, "Extra", OPEN_FRM_ONLY},
4374
 
  {"PRIVILEGES", 80, DRIZZLE_TYPE_VARCHAR, 0, 0, "Privileges", OPEN_FRM_ONLY},
4375
 
  {"COLUMN_COMMENT", COLUMN_COMMENT_MAXLEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Comment", OPEN_FRM_ONLY},
4376
 
  {"STORAGE", 8, DRIZZLE_TYPE_VARCHAR, 0, 0, "Storage", OPEN_FRM_ONLY},
4377
 
  {"FORMAT", 8, DRIZZLE_TYPE_VARCHAR, 0, 0, "Format", OPEN_FRM_ONLY},
4378
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4386
  {"IS_NULLABLE", 3, MYSQL_TYPE_STRING, 0, 0, "Null", OPEN_FRM_ONLY},
 
4387
  {"DATA_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
 
4388
  {"CHARACTER_MAXIMUM_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG,
 
4389
   0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
 
4390
  {"CHARACTER_OCTET_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONGLONG,
 
4391
   0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
 
4392
  {"NUMERIC_PRECISION", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG,
 
4393
   0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
 
4394
  {"NUMERIC_SCALE", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONGLONG,
 
4395
   0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
 
4396
  {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FRM_ONLY},
 
4397
  {"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 1, "Collation", OPEN_FRM_ONLY},
 
4398
  {"COLUMN_TYPE", 65535, MYSQL_TYPE_STRING, 0, 0, "Type", OPEN_FRM_ONLY},
 
4399
  {"COLUMN_KEY", 3, MYSQL_TYPE_STRING, 0, 0, "Key", OPEN_FRM_ONLY},
 
4400
  {"EXTRA", 27, MYSQL_TYPE_STRING, 0, 0, "Extra", OPEN_FRM_ONLY},
 
4401
  {"PRIVILEGES", 80, MYSQL_TYPE_STRING, 0, 0, "Privileges", OPEN_FRM_ONLY},
 
4402
  {"COLUMN_COMMENT", COLUMN_COMMENT_MAXLEN, MYSQL_TYPE_STRING, 0, 0, "Comment", OPEN_FRM_ONLY},
 
4403
  {"STORAGE", 8, MYSQL_TYPE_STRING, 0, 0, "Storage", OPEN_FRM_ONLY},
 
4404
  {"FORMAT", 8, MYSQL_TYPE_STRING, 0, 0, "Format", OPEN_FRM_ONLY},
 
4405
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4379
4406
};
4380
4407
 
4381
4408
 
4382
4409
ST_FIELD_INFO charsets_fields_info[]=
4383
4410
{
4384
 
  {"CHARACTER_SET_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, "Charset",
4385
 
   SKIP_OPEN_TABLE},
4386
 
  {"DEFAULT_COLLATE_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, "Default collation",
4387
 
   SKIP_OPEN_TABLE},
4388
 
  {"DESCRIPTION", 60, DRIZZLE_TYPE_VARCHAR, 0, 0, "Description",
4389
 
   SKIP_OPEN_TABLE},
4390
 
  {"MAXLEN", 3, DRIZZLE_TYPE_LONGLONG, 0, 0, "Maxlen", SKIP_OPEN_TABLE},
4391
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4411
  {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Charset",
 
4412
   SKIP_OPEN_TABLE},
 
4413
  {"DEFAULT_COLLATE_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Default collation",
 
4414
   SKIP_OPEN_TABLE},
 
4415
  {"DESCRIPTION", 60, MYSQL_TYPE_STRING, 0, 0, "Description",
 
4416
   SKIP_OPEN_TABLE},
 
4417
  {"MAXLEN", 3, MYSQL_TYPE_LONGLONG, 0, 0, "Maxlen", SKIP_OPEN_TABLE},
 
4418
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4392
4419
};
4393
4420
 
4394
4421
 
4395
4422
ST_FIELD_INFO collation_fields_info[]=
4396
4423
{
4397
 
  {"COLLATION_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, "Collation", SKIP_OPEN_TABLE},
4398
 
  {"CHARACTER_SET_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, "Charset",
4399
 
   SKIP_OPEN_TABLE},
4400
 
  {"ID", MY_INT32_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0, 0, "Id",
4401
 
   SKIP_OPEN_TABLE},
4402
 
  {"IS_DEFAULT", 3, DRIZZLE_TYPE_VARCHAR, 0, 0, "Default", SKIP_OPEN_TABLE},
4403
 
  {"IS_COMPILED", 3, DRIZZLE_TYPE_VARCHAR, 0, 0, "Compiled", SKIP_OPEN_TABLE},
4404
 
  {"SORTLEN", 3, DRIZZLE_TYPE_LONGLONG, 0, 0, "Sortlen", SKIP_OPEN_TABLE},
4405
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4424
  {"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Collation", SKIP_OPEN_TABLE},
 
4425
  {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Charset",
 
4426
   SKIP_OPEN_TABLE},
 
4427
  {"ID", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Id",
 
4428
   SKIP_OPEN_TABLE},
 
4429
  {"IS_DEFAULT", 3, MYSQL_TYPE_STRING, 0, 0, "Default", SKIP_OPEN_TABLE},
 
4430
  {"IS_COMPILED", 3, MYSQL_TYPE_STRING, 0, 0, "Compiled", SKIP_OPEN_TABLE},
 
4431
  {"SORTLEN", 3, MYSQL_TYPE_LONGLONG, 0, 0, "Sortlen", SKIP_OPEN_TABLE},
 
4432
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
 
4433
};
 
4434
 
 
4435
 
 
4436
ST_FIELD_INFO events_fields_info[]=
 
4437
{
 
4438
  {"EVENT_CATALOG", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
 
4439
  {"EVENT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Db",
 
4440
   SKIP_OPEN_TABLE},
 
4441
  {"EVENT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Name",
 
4442
   SKIP_OPEN_TABLE},
 
4443
  {"DEFINER", 77, MYSQL_TYPE_STRING, 0, 0, "Definer", SKIP_OPEN_TABLE},
 
4444
  {"TIME_ZONE", 64, MYSQL_TYPE_STRING, 0, 0, "Time zone", SKIP_OPEN_TABLE},
 
4445
  {"EVENT_BODY", 8, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4446
  {"EVENT_DEFINITION", 65535, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4447
  {"EVENT_TYPE", 9, MYSQL_TYPE_STRING, 0, 0, "Type", SKIP_OPEN_TABLE},
 
4448
  {"EXECUTE_AT", 0, MYSQL_TYPE_DATETIME, 0, 1, "Execute at", SKIP_OPEN_TABLE},
 
4449
  {"INTERVAL_VALUE", 256, MYSQL_TYPE_STRING, 0, 1, "Interval value",
 
4450
   SKIP_OPEN_TABLE},
 
4451
  {"INTERVAL_FIELD", 18, MYSQL_TYPE_STRING, 0, 1, "Interval field",
 
4452
   SKIP_OPEN_TABLE},
 
4453
  {"SQL_MODE", 65535, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4454
  {"STARTS", 0, MYSQL_TYPE_DATETIME, 0, 1, "Starts", SKIP_OPEN_TABLE},
 
4455
  {"ENDS", 0, MYSQL_TYPE_DATETIME, 0, 1, "Ends", SKIP_OPEN_TABLE},
 
4456
  {"STATUS", 18, MYSQL_TYPE_STRING, 0, 0, "Status", SKIP_OPEN_TABLE},
 
4457
  {"ON_COMPLETION", 12, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4458
  {"CREATED", 0, MYSQL_TYPE_DATETIME, 0, 0, 0, SKIP_OPEN_TABLE},
 
4459
  {"LAST_ALTERED", 0, MYSQL_TYPE_DATETIME, 0, 0, 0, SKIP_OPEN_TABLE},
 
4460
  {"LAST_EXECUTED", 0, MYSQL_TYPE_DATETIME, 0, 1, 0, SKIP_OPEN_TABLE},
 
4461
  {"EVENT_COMMENT", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4462
  {"ORIGINATOR", 10, MYSQL_TYPE_LONGLONG, 0, 0, "Originator", SKIP_OPEN_TABLE},
 
4463
  {"CHARACTER_SET_CLIENT", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
 
4464
   "character_set_client", SKIP_OPEN_TABLE},
 
4465
  {"COLLATION_CONNECTION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
 
4466
   "collation_connection", SKIP_OPEN_TABLE},
 
4467
  {"DATABASE_COLLATION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
 
4468
   "Database Collation", SKIP_OPEN_TABLE},
 
4469
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4406
4470
};
4407
4471
 
4408
4472
 
4409
4473
 
4410
4474
ST_FIELD_INFO coll_charset_app_fields_info[]=
4411
4475
{
4412
 
  {"COLLATION_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE},
4413
 
  {"CHARACTER_SET_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE},
4414
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4476
  {"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4477
  {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4478
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4415
4479
};
4416
4480
 
4417
4481
 
4418
4482
ST_FIELD_INFO stat_fields_info[]=
4419
4483
{
4420
 
  {"TABLE_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, OPEN_FRM_ONLY},
4421
 
  {"TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FRM_ONLY},
4422
 
  {"TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Table", OPEN_FRM_ONLY},
4423
 
  {"NON_UNIQUE", 1, DRIZZLE_TYPE_LONGLONG, 0, 0, "Non_unique", OPEN_FRM_ONLY},
4424
 
  {"INDEX_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FRM_ONLY},
4425
 
  {"INDEX_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Key_name",
4426
 
   OPEN_FRM_ONLY},
4427
 
  {"SEQ_IN_INDEX", 2, DRIZZLE_TYPE_LONGLONG, 0, 0, "Seq_in_index", OPEN_FRM_ONLY},
4428
 
  {"COLUMN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Column_name",
4429
 
   OPEN_FRM_ONLY},
4430
 
  {"COLLATION", 1, DRIZZLE_TYPE_VARCHAR, 0, 1, "Collation", OPEN_FRM_ONLY},
4431
 
  {"CARDINALITY", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0, 1,
 
4484
  {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FRM_ONLY},
 
4485
  {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
 
4486
  {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Table", OPEN_FRM_ONLY},
 
4487
  {"NON_UNIQUE", 1, MYSQL_TYPE_LONGLONG, 0, 0, "Non_unique", OPEN_FRM_ONLY},
 
4488
  {"INDEX_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
 
4489
  {"INDEX_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Key_name",
 
4490
   OPEN_FRM_ONLY},
 
4491
  {"SEQ_IN_INDEX", 2, MYSQL_TYPE_LONGLONG, 0, 0, "Seq_in_index", OPEN_FRM_ONLY},
 
4492
  {"COLUMN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Column_name",
 
4493
   OPEN_FRM_ONLY},
 
4494
  {"COLLATION", 1, MYSQL_TYPE_STRING, 0, 1, "Collation", OPEN_FRM_ONLY},
 
4495
  {"CARDINALITY", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 1,
4432
4496
   "Cardinality", OPEN_FULL_TABLE},
4433
 
  {"SUB_PART", 3, DRIZZLE_TYPE_LONGLONG, 0, 1, "Sub_part", OPEN_FRM_ONLY},
4434
 
  {"PACKED", 10, DRIZZLE_TYPE_VARCHAR, 0, 1, "Packed", OPEN_FRM_ONLY},
4435
 
  {"NULLABLE", 3, DRIZZLE_TYPE_VARCHAR, 0, 0, "Null", OPEN_FRM_ONLY},
4436
 
  {"INDEX_TYPE", 16, DRIZZLE_TYPE_VARCHAR, 0, 0, "Index_type", OPEN_FULL_TABLE},
4437
 
  {"COMMENT", 16, DRIZZLE_TYPE_VARCHAR, 0, 1, "Comment", OPEN_FRM_ONLY},
4438
 
  {"INDEX_COMMENT", INDEX_COMMENT_MAXLEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Index_Comment", OPEN_FRM_ONLY},
4439
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4497
  {"SUB_PART", 3, MYSQL_TYPE_LONGLONG, 0, 1, "Sub_part", OPEN_FRM_ONLY},
 
4498
  {"PACKED", 10, MYSQL_TYPE_STRING, 0, 1, "Packed", OPEN_FRM_ONLY},
 
4499
  {"NULLABLE", 3, MYSQL_TYPE_STRING, 0, 0, "Null", OPEN_FRM_ONLY},
 
4500
  {"INDEX_TYPE", 16, MYSQL_TYPE_STRING, 0, 0, "Index_type", OPEN_FULL_TABLE},
 
4501
  {"COMMENT", 16, MYSQL_TYPE_STRING, 0, 1, "Comment", OPEN_FRM_ONLY},
 
4502
  {"INDEX_COMMENT", INDEX_COMMENT_MAXLEN, MYSQL_TYPE_STRING, 0, 0, "Index_Comment", OPEN_FRM_ONLY},
 
4503
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
 
4504
};
 
4505
 
 
4506
 
 
4507
ST_FIELD_INFO user_privileges_fields_info[]=
 
4508
{
 
4509
  {"GRANTEE", 81, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4510
  {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
 
4511
  {"PRIVILEGE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4512
  {"IS_GRANTABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4513
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
 
4514
};
 
4515
 
 
4516
 
 
4517
ST_FIELD_INFO schema_privileges_fields_info[]=
 
4518
{
 
4519
  {"GRANTEE", 81, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4520
  {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
 
4521
  {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4522
  {"PRIVILEGE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4523
  {"IS_GRANTABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4524
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
 
4525
};
 
4526
 
 
4527
 
 
4528
ST_FIELD_INFO table_privileges_fields_info[]=
 
4529
{
 
4530
  {"GRANTEE", 81, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4531
  {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
 
4532
  {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4533
  {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4534
  {"PRIVILEGE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4535
  {"IS_GRANTABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4536
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
 
4537
};
 
4538
 
 
4539
 
 
4540
ST_FIELD_INFO column_privileges_fields_info[]=
 
4541
{
 
4542
  {"GRANTEE", 81, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4543
  {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
 
4544
  {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4545
  {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4546
  {"COLUMN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4547
  {"PRIVILEGE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4548
  {"IS_GRANTABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4549
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4440
4550
};
4441
4551
 
4442
4552
 
4443
4553
ST_FIELD_INFO table_constraints_fields_info[]=
4444
4554
{
4445
 
  {"CONSTRAINT_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, OPEN_FULL_TABLE},
4446
 
  {"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4447
 
   OPEN_FULL_TABLE},
4448
 
  {"CONSTRAINT_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4449
 
   OPEN_FULL_TABLE},
4450
 
  {"TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4451
 
  {"TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4452
 
  {"CONSTRAINT_TYPE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4453
 
   OPEN_FULL_TABLE},
4454
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4555
  {"CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
 
4556
  {"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
 
4557
   OPEN_FULL_TABLE},
 
4558
  {"CONSTRAINT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
 
4559
   OPEN_FULL_TABLE},
 
4560
  {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4561
  {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4562
  {"CONSTRAINT_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
 
4563
   OPEN_FULL_TABLE},
 
4564
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4455
4565
};
4456
4566
 
4457
4567
 
4458
4568
ST_FIELD_INFO key_column_usage_fields_info[]=
4459
4569
{
4460
 
  {"CONSTRAINT_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, OPEN_FULL_TABLE},
4461
 
  {"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4462
 
   OPEN_FULL_TABLE},
4463
 
  {"CONSTRAINT_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4464
 
   OPEN_FULL_TABLE},
4465
 
  {"TABLE_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, OPEN_FULL_TABLE},
4466
 
  {"TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4467
 
  {"TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4468
 
  {"COLUMN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4469
 
  {"ORDINAL_POSITION", 10 ,DRIZZLE_TYPE_LONGLONG, 0, 0, 0, OPEN_FULL_TABLE},
4470
 
  {"POSITION_IN_UNIQUE_CONSTRAINT", 10 ,DRIZZLE_TYPE_LONGLONG, 0, 1, 0,
4471
 
   OPEN_FULL_TABLE},
4472
 
  {"REFERENCED_TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0,
4473
 
   OPEN_FULL_TABLE},
4474
 
  {"REFERENCED_TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0,
4475
 
   OPEN_FULL_TABLE},
4476
 
  {"REFERENCED_COLUMN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0,
4477
 
   OPEN_FULL_TABLE},
4478
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4570
  {"CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
 
4571
  {"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
 
4572
   OPEN_FULL_TABLE},
 
4573
  {"CONSTRAINT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
 
4574
   OPEN_FULL_TABLE},
 
4575
  {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
 
4576
  {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4577
  {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4578
  {"COLUMN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4579
  {"ORDINAL_POSITION", 10 ,MYSQL_TYPE_LONGLONG, 0, 0, 0, OPEN_FULL_TABLE},
 
4580
  {"POSITION_IN_UNIQUE_CONSTRAINT", 10 ,MYSQL_TYPE_LONGLONG, 0, 1, 0,
 
4581
   OPEN_FULL_TABLE},
 
4582
  {"REFERENCED_TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0,
 
4583
   OPEN_FULL_TABLE},
 
4584
  {"REFERENCED_TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0,
 
4585
   OPEN_FULL_TABLE},
 
4586
  {"REFERENCED_COLUMN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0,
 
4587
   OPEN_FULL_TABLE},
 
4588
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4479
4589
};
4480
4590
 
4481
4591
 
4482
4592
ST_FIELD_INFO table_names_fields_info[]=
4483
4593
{
4484
 
  {"TABLE_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, SKIP_OPEN_TABLE},
4485
 
  {"TABLE_SCHEMA",NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE},
4486
 
  {"TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Tables_in_",
 
4594
  {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
 
4595
  {"TABLE_SCHEMA",NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4596
  {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Tables_in_",
4487
4597
   SKIP_OPEN_TABLE},
4488
 
  {"TABLE_TYPE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Table_type",
 
4598
  {"TABLE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_type",
4489
4599
   OPEN_FRM_ONLY},
4490
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4600
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4491
4601
};
4492
4602
 
4493
4603
 
4494
4604
ST_FIELD_INFO open_tables_fields_info[]=
4495
4605
{
4496
 
  {"Database", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Database",
 
4606
  {"Database", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Database",
4497
4607
   SKIP_OPEN_TABLE},
4498
 
  {"Table",NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Table", SKIP_OPEN_TABLE},
4499
 
  {"In_use", 1, DRIZZLE_TYPE_LONGLONG, 0, 0, "In_use", SKIP_OPEN_TABLE},
4500
 
  {"Name_locked", 4, DRIZZLE_TYPE_LONGLONG, 0, 0, "Name_locked", SKIP_OPEN_TABLE},
4501
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4608
  {"Table",NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Table", SKIP_OPEN_TABLE},
 
4609
  {"In_use", 1, MYSQL_TYPE_LONGLONG, 0, 0, "In_use", SKIP_OPEN_TABLE},
 
4610
  {"Name_locked", 4, MYSQL_TYPE_LONGLONG, 0, 0, "Name_locked", SKIP_OPEN_TABLE},
 
4611
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4502
4612
};
4503
4613
 
4504
4614
 
4505
4615
ST_FIELD_INFO variables_fields_info[]=
4506
4616
{
4507
 
  {"VARIABLE_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, "Variable_name",
 
4617
  {"VARIABLE_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Variable_name",
4508
4618
   SKIP_OPEN_TABLE},
4509
 
  {"VARIABLE_VALUE", 16300, DRIZZLE_TYPE_VARCHAR, 0, 1, "Value", SKIP_OPEN_TABLE},
4510
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4619
  {"VARIABLE_VALUE", 16300, MYSQL_TYPE_STRING, 0, 1, "Value", SKIP_OPEN_TABLE},
 
4620
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4511
4621
};
4512
4622
 
4513
4623
 
4514
4624
ST_FIELD_INFO processlist_fields_info[]=
4515
4625
{
4516
 
  {"ID", 4, DRIZZLE_TYPE_LONGLONG, 0, 0, "Id", SKIP_OPEN_TABLE},
4517
 
  {"USER", 16, DRIZZLE_TYPE_VARCHAR, 0, 0, "User", SKIP_OPEN_TABLE},
4518
 
  {"HOST", LIST_PROCESS_HOST_LEN,  DRIZZLE_TYPE_VARCHAR, 0, 0, "Host",
4519
 
   SKIP_OPEN_TABLE},
4520
 
  {"DB", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, "Db", SKIP_OPEN_TABLE},
4521
 
  {"COMMAND", 16, DRIZZLE_TYPE_VARCHAR, 0, 0, "Command", SKIP_OPEN_TABLE},
4522
 
  {"TIME", 7, DRIZZLE_TYPE_LONGLONG, 0, 0, "Time", SKIP_OPEN_TABLE},
4523
 
  {"STATE", 64, DRIZZLE_TYPE_VARCHAR, 0, 1, "State", SKIP_OPEN_TABLE},
4524
 
  {"INFO", PROCESS_LIST_INFO_WIDTH, DRIZZLE_TYPE_VARCHAR, 0, 1, "Info",
4525
 
   SKIP_OPEN_TABLE},
4526
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4626
  {"ID", 4, MYSQL_TYPE_LONGLONG, 0, 0, "Id", SKIP_OPEN_TABLE},
 
4627
  {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User", SKIP_OPEN_TABLE},
 
4628
  {"HOST", LIST_PROCESS_HOST_LEN,  MYSQL_TYPE_STRING, 0, 0, "Host",
 
4629
   SKIP_OPEN_TABLE},
 
4630
  {"DB", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, "Db", SKIP_OPEN_TABLE},
 
4631
  {"COMMAND", 16, MYSQL_TYPE_STRING, 0, 0, "Command", SKIP_OPEN_TABLE},
 
4632
  {"TIME", 7, MYSQL_TYPE_LONGLONG, 0, 0, "Time", SKIP_OPEN_TABLE},
 
4633
  {"STATE", 64, MYSQL_TYPE_STRING, 0, 1, "State", SKIP_OPEN_TABLE},
 
4634
  {"INFO", PROCESS_LIST_INFO_WIDTH, MYSQL_TYPE_STRING, 0, 1, "Info",
 
4635
   SKIP_OPEN_TABLE},
 
4636
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4527
4637
};
4528
4638
 
4529
4639
 
4530
4640
ST_FIELD_INFO plugin_fields_info[]=
4531
4641
{
4532
 
  {"PLUGIN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Name", 
4533
 
   SKIP_OPEN_TABLE},
4534
 
  {"PLUGIN_VERSION", 20, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE},
4535
 
  {"PLUGIN_STATUS", 10, DRIZZLE_TYPE_VARCHAR, 0, 0, "Status", SKIP_OPEN_TABLE},
4536
 
  {"PLUGIN_TYPE", 80, DRIZZLE_TYPE_VARCHAR, 0, 0, "Type", SKIP_OPEN_TABLE},
4537
 
  {"PLUGIN_LIBRARY", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, "Library",
4538
 
   SKIP_OPEN_TABLE},
4539
 
  {"PLUGIN_AUTHOR", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, SKIP_OPEN_TABLE},
4540
 
  {"PLUGIN_DESCRIPTION", 65535, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, SKIP_OPEN_TABLE},
4541
 
  {"PLUGIN_LICENSE", 80, DRIZZLE_TYPE_VARCHAR, 0, 1, "License", SKIP_OPEN_TABLE},
4542
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4642
  {"PLUGIN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Name",
 
4643
   SKIP_OPEN_TABLE},
 
4644
  {"PLUGIN_VERSION", 20, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4645
  {"PLUGIN_STATUS", 10, MYSQL_TYPE_STRING, 0, 0, "Status", SKIP_OPEN_TABLE},
 
4646
  {"PLUGIN_TYPE", 80, MYSQL_TYPE_STRING, 0, 0, "Type", SKIP_OPEN_TABLE},
 
4647
  {"PLUGIN_TYPE_VERSION", 20, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4648
  {"PLUGIN_LIBRARY", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, "Library",
 
4649
   SKIP_OPEN_TABLE},
 
4650
  {"PLUGIN_LIBRARY_VERSION", 20, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
 
4651
  {"PLUGIN_AUTHOR", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
 
4652
  {"PLUGIN_DESCRIPTION", 65535, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
 
4653
  {"PLUGIN_LICENSE", 80, MYSQL_TYPE_STRING, 0, 1, "License", SKIP_OPEN_TABLE},
 
4654
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4543
4655
};
4544
4656
 
4545
4657
ST_FIELD_INFO referential_constraints_fields_info[]=
4546
4658
{
4547
 
  {"CONSTRAINT_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, OPEN_FULL_TABLE},
4548
 
  {"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4549
 
   OPEN_FULL_TABLE},
4550
 
  {"CONSTRAINT_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4551
 
   OPEN_FULL_TABLE},
4552
 
  {"UNIQUE_CONSTRAINT_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0,
4553
 
   OPEN_FULL_TABLE},
4554
 
  {"UNIQUE_CONSTRAINT_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4555
 
   OPEN_FULL_TABLE},
4556
 
  {"UNIQUE_CONSTRAINT_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0,
 
4659
  {"CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
 
4660
  {"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
 
4661
   OPEN_FULL_TABLE},
 
4662
  {"CONSTRAINT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
 
4663
   OPEN_FULL_TABLE},
 
4664
  {"UNIQUE_CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0,
 
4665
   OPEN_FULL_TABLE},
 
4666
  {"UNIQUE_CONSTRAINT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
 
4667
   OPEN_FULL_TABLE},
 
4668
  {"UNIQUE_CONSTRAINT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0,
4557
4669
   MY_I_S_MAYBE_NULL, 0, OPEN_FULL_TABLE},
4558
 
  {"MATCH_OPTION", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4559
 
  {"UPDATE_RULE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4560
 
  {"DELETE_RULE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4561
 
  {"TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4562
 
  {"REFERENCED_TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
 
4670
  {"MATCH_OPTION", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4671
  {"UPDATE_RULE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4672
  {"DELETE_RULE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4673
  {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4674
  {"REFERENCED_TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
4563
4675
   OPEN_FULL_TABLE},
4564
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4676
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
 
4677
};
 
4678
 
 
4679
 
 
4680
ST_FIELD_INFO parameters_fields_info[]=
 
4681
{
 
4682
  {"SPECIFIC_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
 
4683
  {"SPECIFIC_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4684
  {"SPECIFIC_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4685
  {"ORDINAL_POSITION", 21 , MYSQL_TYPE_LONG, 0, 0, 0, OPEN_FULL_TABLE},
 
4686
  {"PARAMETER_MODE", 5, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
 
4687
  {"PARAMETER_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
 
4688
  {"DATA_TYPE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4689
  {"CHARACTER_MAXIMUM_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, 0, OPEN_FULL_TABLE},
 
4690
  {"CHARACTER_OCTET_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, 0, OPEN_FULL_TABLE},
 
4691
  {"NUMERIC_PRECISION", 21 , MYSQL_TYPE_LONG, 0, 1, 0, OPEN_FULL_TABLE},
 
4692
  {"NUMERIC_SCALE", 21 , MYSQL_TYPE_LONG, 0, 1, 0, OPEN_FULL_TABLE},
 
4693
  {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
 
4694
  {"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
 
4695
  {"DTD_IDENTIFIER", 65535, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4696
  {"ROUTINE_TYPE", 9, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4697
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}
4565
4698
};
4566
4699
 
4567
4700
 
4582
4715
   create_schema_table, fill_schema_coll_charset_app, 0, 0, -1, -1, 0, 0},
4583
4716
  {"COLUMNS", columns_fields_info, create_schema_table, 
4584
4717
   get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0,
4585
 
   OPTIMIZE_I_S_TABLE},
 
4718
   OPTIMIZE_I_S_TABLE|OPEN_VIEW_FULL},
4586
4719
  {"GLOBAL_STATUS", variables_fields_info, create_schema_table,
4587
4720
   fill_status, make_old_format, 0, -1, -1, 0, 0},
4588
4721
  {"GLOBAL_VARIABLES", variables_fields_info, create_schema_table,
4649
4782
 
4650
4783
    if (plugin->plugin->init(schema_table))
4651
4784
    {
4652
 
      sql_print_error(_("Plugin '%s' init function returned error."),
 
4785
      sql_print_error("Plugin '%s' init function returned error.",
4653
4786
                      plugin->name.str);
4654
4787
      goto err;
4655
4788
    }
4660
4793
 
4661
4794
  return(0);
4662
4795
err:
4663
 
  free(schema_table);
 
4796
  my_free(schema_table, MYF(0));
4664
4797
  return(1);
4665
4798
}
4666
4799
 
4669
4802
  ST_SCHEMA_TABLE *schema_table= (ST_SCHEMA_TABLE *)plugin->data;
4670
4803
 
4671
4804
  if (schema_table && plugin->plugin->deinit)
4672
 
    free(schema_table);
 
4805
    my_free(schema_table, MYF(0));
4673
4806
 
4674
4807
  return(0);
4675
4808
}