~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/sql_show.cc

  • Committer: Patrick Galbraith
  • Date: 2008-07-24 16:57:40 UTC
  • mto: (202.2.4 rename-mysql-to-drizzle)
  • mto: This revision was merged to the branch mainline in revision 212.
  • Revision ID: patg@ishvara-20080724165740-x58yw6zs6d9o17lf
Most everything working with client rename
mysqlslap test still fails... can't connect to the server

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>
21
 
#include <mysys/my_dir.h>
22
 
#include <libdrizzle/gettext.h>
23
 
#include <drizzled/util/convert.h>
24
 
#include <string>
25
 
 
26
 
inline const char *
27
 
str_or_nil(const char *str)
28
 
{
29
 
  return str ? str : "<nil>";
30
 
}
 
18
 
 
19
#include "mysql_priv.h"
 
20
#include "sql_select.h"                         // For select_describe
 
21
#include "sql_show.h"
 
22
#include "repl_failsafe.h"
 
23
#include <my_dir.h>
 
24
 
 
25
#define STR_OR_NIL(S) ((S) ? (S) : "<nil>")
31
26
 
32
27
/* Match the values of enum ha_choice */
33
28
static const char *ha_choice_values[] = {"", "0", "1"};
34
29
 
35
 
static void store_key_options(THD *thd, String *packet, Table *table,
 
30
static void store_key_options(THD *thd, String *packet, TABLE *table,
36
31
                              KEY *key_info);
37
32
 
38
33
 
39
34
 
40
 
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)
41
36
{
42
37
  register int flag;
43
38
  while (*wildstr)
90
85
static bool show_plugins(THD *thd, plugin_ref plugin,
91
86
                            void *arg)
92
87
{
93
 
  Table *table= (Table*) arg;
 
88
  TABLE *table= (TABLE*) arg;
94
89
  struct st_mysql_plugin *plug= plugin_decl(plugin);
95
90
  struct st_plugin_dl *plugin_dl= plugin_dlib(plugin);
96
 
  const CHARSET_INFO * const cs= system_charset_info;
 
91
  CHARSET_INFO *cs= system_charset_info;
97
92
 
98
93
  restore_record(table, s->default_values);
99
94
 
173
168
}
174
169
 
175
170
 
176
 
int fill_plugins(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
 
171
int fill_plugins(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((__unused__)))
177
172
{
178
 
  Table *table= tables->table;
 
173
  TABLE *table= tables->table;
179
174
 
180
 
  if (plugin_foreach_with_mask(thd, show_plugins, DRIZZLE_ANY_PLUGIN,
 
175
  if (plugin_foreach_with_mask(thd, show_plugins, MYSQL_ANY_PLUGIN,
181
176
                               ~PLUGIN_IS_FREED, table))
182
177
    return(1);
183
178
 
192
187
    find_files()
193
188
    thd                 thread handler
194
189
    files               put found files in this list
195
 
    db                  database name to set in TableList structure
 
190
    db                  database name to set in TABLE_LIST structure
196
191
    path                path to database
197
192
    wild                filter for found files
198
193
    dir                 read databases in path if true, read .frm files in
209
204
find_files(THD *thd, List<LEX_STRING> *files, const char *db,
210
205
           const char *path, const char *wild, bool dir)
211
206
{
212
 
  uint32_t i;
 
207
  uint i;
213
208
  char *ext;
214
209
  MY_DIR *dirp;
215
210
  FILEINFO *file;
216
211
  LEX_STRING *file_name= 0;
217
 
  uint32_t file_name_len;
218
 
  TableList table_list;
 
212
  uint file_name_len;
 
213
  TABLE_LIST table_list;
219
214
 
220
215
  if (wild && !wild[0])
221
216
    wild=0;
222
217
 
223
 
  memset(&table_list, 0, sizeof(table_list));
 
218
  bzero((char*) &table_list,sizeof(table_list));
224
219
 
225
220
  if (!(dirp = my_dir(path,MYF(dir ? MY_WANT_STAT : 0))))
226
221
  {
250
245
        char *end;
251
246
        *ext=0;                                 /* Remove extension */
252
247
        unpack_dirname(buff, file->name);
253
 
        end= strchr(buff, '\0');
 
248
        end= strend(buff);
254
249
        if (end != buff && end[-1] == FN_LIBCHAR)
255
250
          end[-1]= 0;                           // Remove end FN_LIBCHAR
256
251
        if (stat(buff, file->mystat))
257
252
               continue;
258
253
       }
259
254
#endif
260
 
      if (!S_ISDIR(file->mystat->st_mode))
 
255
      if (!MY_S_ISDIR(file->mystat->st_mode))
261
256
        continue;
262
257
 
263
258
      file_name_len= filename_to_tablename(file->name, uname, sizeof(uname));
304
299
 
305
300
 
306
301
bool
307
 
mysqld_show_create(THD *thd, TableList *table_list)
 
302
mysqld_show_create(THD *thd, TABLE_LIST *table_list)
308
303
{
309
304
  Protocol *protocol= thd->protocol;
310
305
  char buff[2048];
321
316
      issue a warning with 'warning' level status in 
322
317
      case of invalid view and last error is ER_VIEW_INVALID
323
318
    */
324
 
    drizzle_reset_errors(thd, true);
 
319
    mysql_reset_errors(thd, true);
325
320
    thd->clear_error();
326
321
  }
327
322
 
335
330
    field_list.push_back(new Item_empty_string("Table",NAME_CHAR_LEN));
336
331
    // 1024 is for not to confuse old clients
337
332
    field_list.push_back(new Item_empty_string("Create Table",
338
 
                                               cmax(buffer.length(),(uint32_t)1024)));
 
333
                                               max(buffer.length(),1024)));
339
334
  }
340
335
 
341
336
  if (protocol->send_fields(&field_list,
402
397
****************************************************************************/
403
398
 
404
399
void
405
 
mysqld_list_fields(THD *thd, TableList *table_list, const char *wild)
 
400
mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild)
406
401
{
407
 
  Table *table;
 
402
  TABLE *table;
408
403
 
409
404
  if (open_normal_and_derived_tables(thd, table_list, 0))
410
405
    return;
444
439
    0   No conflicting character
445
440
*/
446
441
 
447
 
static const char *require_quotes(const char *name, uint32_t name_length)
 
442
static const char *require_quotes(const char *name, uint name_length)
448
443
{
449
 
  uint32_t length;
 
444
  uint length;
450
445
  bool pure_digit= true;
451
446
  const char *end= name + name_length;
452
447
 
453
448
  for (; name < end ; name++)
454
449
  {
455
 
    unsigned char chr= (unsigned char) *name;
 
450
    uchar chr= (uchar) *name;
456
451
    length= my_mbcharlen(system_charset_info, chr);
457
452
    if (length == 1 && !system_charset_info->ident_map[chr])
458
453
      return name;
478
473
*/
479
474
 
480
475
void
481
 
append_identifier(THD *thd, String *packet, const char *name, uint32_t length)
 
476
append_identifier(THD *thd, String *packet, const char *name, uint length)
482
477
{
483
478
  const char *name_end;
484
479
  char quote_char;
495
490
   it's a keyword
496
491
  */
497
492
 
498
 
  packet->reserve(length*2 + 2);
 
493
  VOID(packet->reserve(length*2 + 2));
499
494
  quote_char= (char) q;
500
495
  packet->append(&quote_char, 1, system_charset_info);
501
496
 
502
497
  for (name_end= name+length ; name < name_end ; name+= length)
503
498
  {
504
 
    unsigned char chr= (unsigned char) *name;
 
499
    uchar chr= (uchar) *name;
505
500
    length= my_mbcharlen(system_charset_info, chr);
506
501
    /*
507
502
      my_mbcharlen can return 0 on a wrong multibyte
512
507
    */
513
508
    if (!length)
514
509
      length= 1;
515
 
    if (length == 1 && chr == (unsigned char) quote_char)
 
510
    if (length == 1 && chr == (uchar) quote_char)
516
511
      packet->append(&quote_char, 1, system_charset_info);
517
512
    packet->append(name, length, system_charset_info);
518
513
  }
543
538
    #     Quote character
544
539
*/
545
540
 
546
 
int get_quote_char_for_identifier(THD *thd, const char *name, uint32_t length)
 
541
int get_quote_char_for_identifier(THD *thd, const char *name, uint length)
547
542
{
548
543
  if (length &&
549
544
      !is_keyword(name,length) &&
550
545
      !require_quotes(name, length) &&
551
546
      !(thd->options & OPTION_QUOTE_SHOW_CREATE))
552
547
    return EOF;
553
 
  return '`';
 
548
  return '"';
554
549
}
555
550
 
556
551
 
557
552
/* Append directory name (if exists) to CREATE INFO */
558
553
 
559
 
static void append_directory(THD *thd __attribute__((unused)),
 
554
static void append_directory(THD *thd __attribute__((__unused__)),
560
555
                             String *packet, const char *dir_type,
561
556
                             const char *filename)
562
557
{
563
558
  if (filename)
564
559
  {
565
 
    uint32_t length= dirname_length(filename);
 
560
    uint length= dirname_length(filename);
566
561
    packet->append(' ');
567
562
    packet->append(dir_type);
568
563
    packet->append(STRING_WITH_LEN(" DIRECTORY='"));
574
569
 
575
570
#define LIST_PROCESS_HOST_LEN 64
576
571
 
577
 
static bool get_field_default_value(THD *thd __attribute__((unused)),
 
572
static bool get_field_default_value(THD *thd __attribute__((__unused__)),
578
573
                                    Field *timestamp_field,
579
574
                                    Field *field, String *def_value,
580
575
                                    bool quoted)
589
584
  has_now_default= (timestamp_field == field &&
590
585
                    field->unireg_check != Field::TIMESTAMP_UN_FIELD);
591
586
    
592
 
  has_default= (field->type() != DRIZZLE_TYPE_BLOB &&
 
587
  has_default= (field->type() != FIELD_TYPE_BLOB &&
593
588
                !(field->flags & NO_DEFAULT_VALUE_FLAG) &&
594
589
                field->unireg_check != Field::NEXT_NUMBER
595
590
                  && has_now_default);
607
602
      if (type.length())
608
603
      {
609
604
        String def_val;
610
 
        uint32_t dummy_errors;
 
605
        uint dummy_errors;
611
606
        /* convert to system_charset_info == utf8 */
612
607
        def_val.copy(type.ptr(), type.length(), field->charset(),
613
608
                     system_charset_info, &dummy_errors);
651
646
    0       OK
652
647
 */
653
648
 
654
 
int store_create_info(THD *thd, TableList *table_list, String *packet,
 
649
int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
655
650
                      HA_CREATE_INFO *create_info_arg)
656
651
{
657
652
  List<Item> field_list;
658
 
  char tmp[MAX_FIELD_WIDTH], *for_str, def_value_buf[MAX_FIELD_WIDTH];
 
653
  char tmp[MAX_FIELD_WIDTH], *for_str, buff[128], def_value_buf[MAX_FIELD_WIDTH];
659
654
  const char *alias;
660
 
  std::string buff;
661
655
  String type(tmp, sizeof(tmp), system_charset_info);
662
656
  String def_value(def_value_buf, sizeof(def_value_buf), system_charset_info);
663
657
  Field **ptr,*field;
664
 
  uint32_t primary_key;
 
658
  uint primary_key;
665
659
  KEY *key_info;
666
 
  Table *table= table_list->table;
 
660
  TABLE *table= table_list->table;
667
661
  handler *file= table->file;
668
662
  TABLE_SHARE *share= table->s;
669
663
  HA_CREATE_INFO create_info;
697
691
    We have to restore the read_set if we are called from insert in case
698
692
    of row based replication.
699
693
  */
700
 
  old_map= table->use_all_columns(table->read_set);
 
694
  old_map= tmp_use_all_columns(table, table->read_set);
701
695
 
702
696
  for (ptr=table->field ; (field= *ptr); ptr++)
703
697
  {
704
 
    uint32_t flags = field->flags;
 
698
    uint flags = field->flags;
705
699
 
706
700
    if (ptr != table->field)
707
701
      packet->append(STRING_WITH_LEN(",\n"));
715
709
    else
716
710
      type.set_charset(system_charset_info);
717
711
 
718
 
    if (field->vcol_info)
719
 
    {
720
 
      packet->append(STRING_WITH_LEN("VIRTUAL "));
721
 
    }
722
 
 
723
712
    field->sql_type(type);
724
713
    packet->append(type.ptr(), type.length(), system_charset_info);
725
714
 
726
 
    if (field->vcol_info)
727
 
    {
728
 
      packet->append(STRING_WITH_LEN(" AS ("));
729
 
      packet->append(field->vcol_info->expr_str.str,
730
 
                     field->vcol_info->expr_str.length,
731
 
                     system_charset_info);
732
 
      packet->append(STRING_WITH_LEN(")"));
733
 
      if (field->is_stored)
734
 
        packet->append(STRING_WITH_LEN(" STORED"));
735
 
    }
736
 
    
737
715
    if (field->has_charset())
738
716
    {
739
717
      if (field->charset() != share->table_charset)
754
732
 
755
733
    if (flags & NOT_NULL_FLAG)
756
734
      packet->append(STRING_WITH_LEN(" NOT NULL"));
757
 
    else if (field->type() == DRIZZLE_TYPE_TIMESTAMP)
 
735
    else if (field->type() == MYSQL_TYPE_TIMESTAMP)
758
736
    {
759
737
      /*
760
738
        TIMESTAMP field require explicit NULL flag, because unlike
772
750
      if (column_format)
773
751
      {
774
752
        packet->append(STRING_WITH_LEN(" /*!"));
775
 
        packet->append(STRING_WITH_LEN(DRIZZLE_VERSION_TABLESPACE_IN_FRM_STR));
 
753
        packet->append(STRING_WITH_LEN(MYSQL_VERSION_TABLESPACE_IN_FRM_STR));
776
754
        packet->append(STRING_WITH_LEN(" COLUMN_FORMAT"));
777
755
        if (column_format == COLUMN_FORMAT_TYPE_FIXED)
778
756
          packet->append(STRING_WITH_LEN(" FIXED */"));
780
758
          packet->append(STRING_WITH_LEN(" DYNAMIC */"));
781
759
      }
782
760
    }
783
 
    if (!field->vcol_info &&
784
 
        get_field_default_value(thd, table->timestamp_field,
 
761
    if (get_field_default_value(thd, table->timestamp_field,
785
762
                                field, &def_value, 1))
786
763
    {
787
764
      packet->append(STRING_WITH_LEN(" DEFAULT "));
802
779
  }
803
780
 
804
781
  key_info= table->key_info;
805
 
  memset(&create_info, 0, sizeof(create_info));
 
782
  bzero((char*) &create_info, sizeof(create_info));
806
783
  /* Allow update_create_info to update row type */
807
784
  create_info.row_type= share->row_type;
808
785
  file->update_create_info(&create_info);
809
786
  primary_key= share->primary_key;
810
787
 
811
 
  for (uint32_t i=0 ; i < share->keys ; i++,key_info++)
 
788
  for (uint i=0 ; i < share->keys ; i++,key_info++)
812
789
  {
813
790
    KEY_PART_INFO *key_part= key_info->key_part;
814
791
    bool found_primary=0;
833
810
 
834
811
    packet->append(STRING_WITH_LEN(" ("));
835
812
 
836
 
    for (uint32_t j=0 ; j < key_info->key_parts ; j++,key_part++)
 
813
    for (uint j=0 ; j < key_info->key_parts ; j++,key_part++)
837
814
    {
838
815
      if (j)
839
816
        packet->append(',');
845
822
          (key_part->length !=
846
823
           table->field[key_part->fieldnr-1]->key_length()))
847
824
      {
848
 
        buff= "(";
849
 
        buff= to_string(buff, (int32_t) key_part->length /
850
 
                              key_part->field->charset()->mbmaxlen);
851
 
        buff += ")";
852
 
        packet->append(buff.c_str(), buff.length());
 
825
        char *end;
 
826
        buff[0] = '(';
 
827
        end= int10_to_str((long) key_part->length /
 
828
                          key_part->field->charset()->mbmaxlen,
 
829
                          buff + 1,10);
 
830
        *end++ = ')';
 
831
        packet->append(buff,(uint) (end-buff));
853
832
      }
854
833
    }
855
834
    packet->append(')');
899
878
 
900
879
    if (create_info.auto_increment_value > 1)
901
880
    {
 
881
      char *end;
902
882
      packet->append(STRING_WITH_LEN(" AUTO_INCREMENT="));
903
 
      buff= to_string(create_info.auto_increment_value);
904
 
      packet->append(buff.c_str(), buff.length());
 
883
      end= int64_t10_to_str(create_info.auto_increment_value, buff,10);
 
884
      packet->append(buff, (uint) (end - buff));
 
885
    }
 
886
 
 
887
    
 
888
    if (share->table_charset)
 
889
    {
 
890
      /*
 
891
        IF   check_create_info
 
892
        THEN add DEFAULT CHARSET only if it was used when creating the table
 
893
      */
 
894
      if (!create_info_arg ||
 
895
          (create_info_arg->used_fields & HA_CREATE_USED_DEFAULT_CHARSET))
 
896
      {
 
897
        packet->append(STRING_WITH_LEN(" DEFAULT CHARSET="));
 
898
        packet->append(share->table_charset->csname);
 
899
        if (!(share->table_charset->state & MY_CS_PRIMARY))
 
900
        {
 
901
          packet->append(STRING_WITH_LEN(" COLLATE="));
 
902
          packet->append(table->s->table_charset->name);
 
903
        }
 
904
      }
905
905
    }
906
906
 
907
907
    if (share->min_rows)
908
908
    {
 
909
      char *end;
909
910
      packet->append(STRING_WITH_LEN(" MIN_ROWS="));
910
 
      buff= to_string(share->min_rows);
911
 
      packet->append(buff.c_str(), buff.length());
 
911
      end= int64_t10_to_str(share->min_rows, buff, 10);
 
912
      packet->append(buff, (uint) (end- buff));
912
913
    }
913
914
 
914
915
    if (share->max_rows && !table_list->schema_table)
915
916
    {
 
917
      char *end;
916
918
      packet->append(STRING_WITH_LEN(" MAX_ROWS="));
917
 
      buff= to_string(share->max_rows);
918
 
      packet->append(buff.c_str(), buff.length());
 
919
      end= int64_t10_to_str(share->max_rows, buff, 10);
 
920
      packet->append(buff, (uint) (end - buff));
919
921
    }
920
922
 
921
923
    if (share->avg_row_length)
922
924
    {
 
925
      char *end;
923
926
      packet->append(STRING_WITH_LEN(" AVG_ROW_LENGTH="));
924
 
      buff= to_string(share->avg_row_length);
925
 
      packet->append(buff.c_str(), buff.length());
 
927
      end= int64_t10_to_str(share->avg_row_length, buff,10);
 
928
      packet->append(buff, (uint) (end - buff));
926
929
    }
927
930
 
928
931
    if (share->db_create_options & HA_OPTION_PACK_KEYS)
951
954
    }
952
955
    if (table->s->key_block_size)
953
956
    {
 
957
      char *end;
954
958
      packet->append(STRING_WITH_LEN(" KEY_BLOCK_SIZE="));
955
 
      buff= to_string(table->s->key_block_size);
956
 
      packet->append(buff.c_str(), buff.length());
957
 
    }
958
 
    if (share->block_size)
959
 
    {
960
 
      packet->append(STRING_WITH_LEN(" BLOCK_SIZE="));
961
 
      buff= to_string(share->block_size);
962
 
      packet->append(buff.c_str(), buff.length());
 
959
      end= int64_t10_to_str(table->s->key_block_size, buff, 10);
 
960
      packet->append(buff, (uint) (end - buff));
963
961
    }
964
962
    table->file->append_create_info(packet);
965
963
    if (share->comment.length)
975
973
    append_directory(thd, packet, "DATA",  create_info.data_file_name);
976
974
    append_directory(thd, packet, "INDEX", create_info.index_file_name);
977
975
  }
978
 
  table->restore_column_map(old_map);
 
976
  tmp_restore_column_map(table->read_set, old_map);
979
977
  return(0);
980
978
}
981
979
 
1005
1003
                          HA_CREATE_INFO *create_info)
1006
1004
{
1007
1005
  HA_CREATE_INFO create;
1008
 
  uint32_t create_options = create_info ? create_info->options : 0;
 
1006
  uint create_options = create_info ? create_info->options : 0;
1009
1007
 
1010
1008
  if (!my_strcasecmp(system_charset_info, dbname,
1011
1009
                     INFORMATION_SCHEMA_NAME.str))
1047
1045
  return(false);
1048
1046
}
1049
1047
 
1050
 
static void store_key_options(THD *thd __attribute__((unused)),
1051
 
                              String *packet, Table *table,
 
1048
static void store_key_options(THD *thd __attribute__((__unused__)),
 
1049
                              String *packet, TABLE *table,
1052
1050
                              KEY *key_info)
1053
1051
{
1054
1052
  char *end, buff[32];
1095
1093
 
1096
1094
  ulong thread_id;
1097
1095
  time_t start_time;
1098
 
  uint32_t   command;
 
1096
  uint   command;
1099
1097
  const char *user,*host,*db,*proc_info,*state_info;
1100
1098
  char *query;
1101
1099
};
1119
1117
  field_list.push_back(field=new Item_empty_string("db",NAME_CHAR_LEN));
1120
1118
  field->maybe_null=1;
1121
1119
  field_list.push_back(new Item_empty_string("Command",16));
1122
 
  field_list.push_back(new Item_return_int("Time",7, DRIZZLE_TYPE_LONG));
 
1120
  field_list.push_back(new Item_return_int("Time",7, MYSQL_TYPE_LONG));
1123
1121
  field_list.push_back(field=new Item_empty_string("State",30));
1124
1122
  field->maybe_null=1;
1125
1123
  field_list.push_back(field=new Item_empty_string("Info",max_query_length));
1128
1126
                            Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
1129
1127
    return;
1130
1128
 
1131
 
  pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
 
1129
  VOID(pthread_mutex_lock(&LOCK_thread_count)); // For unlink from list
1132
1130
  if (!thd->killed)
1133
1131
  {
1134
1132
    I_List_iterator<THD> it(threads);
1145
1143
        thd_info->user= thd->strdup(tmp_sctx->user ? tmp_sctx->user :
1146
1144
                                    (tmp->system_thread ?
1147
1145
                                     "system user" : "unauthenticated user"));
1148
 
        thd_info->host= thd->strdup(tmp_sctx->ip);
 
1146
        thd_info->host= thd->strdup(tmp_sctx->host_or_ip[0] ? 
 
1147
                                    tmp_sctx->host_or_ip : 
 
1148
                                    tmp_sctx->host ? tmp_sctx->host : "");
1149
1149
        if ((thd_info->db=tmp->db))             // Safe test
1150
1150
          thd_info->db=thd->strdup(thd_info->db);
1151
1151
        thd_info->command=(int) tmp->command;
1155
1155
        thd_info->state_info= (char*) (tmp->net.reading_or_writing ?
1156
1156
                                       (tmp->net.reading_or_writing == 2 ?
1157
1157
                                        "Writing to net" :
1158
 
                                        thd_info->command == COM_SLEEP ? NULL :
 
1158
                                        thd_info->command == COM_SLEEP ? NullS :
1159
1159
                                        "Reading from net") :
1160
 
                                       tmp->get_proc_info() ? tmp->get_proc_info() :
 
1160
                                       tmp->proc_info ? tmp->proc_info :
1161
1161
                                       tmp->mysys_var &&
1162
1162
                                       tmp->mysys_var->current_cond ?
1163
 
                                       "Waiting on cond" : NULL);
 
1163
                                       "Waiting on cond" : NullS);
1164
1164
        if (mysys_var)
1165
1165
          pthread_mutex_unlock(&mysys_var->mutex);
1166
1166
 
1173
1173
            the comment in sql_class.h why this prevents crashes in possible
1174
1174
            races with query_length
1175
1175
          */
1176
 
          uint32_t length= cmin((uint32_t)max_query_length, tmp->query_length);
 
1176
          uint length= min(max_query_length, tmp->query_length);
1177
1177
          thd_info->query=(char*) thd->strmake(tmp->query,length);
1178
1178
        }
1179
1179
        thread_infos.append(thd_info);
1180
1180
      }
1181
1181
    }
1182
1182
  }
1183
 
  pthread_mutex_unlock(&LOCK_thread_count);
 
1183
  VOID(pthread_mutex_unlock(&LOCK_thread_count));
1184
1184
 
1185
1185
  thread_info *thd_info;
1186
1186
  time_t now= my_time(0);
1208
1208
  return;
1209
1209
}
1210
1210
 
1211
 
int fill_schema_processlist(THD* thd, TableList* tables,
1212
 
                            COND* cond __attribute__((unused)))
 
1211
int fill_schema_processlist(THD* thd, TABLE_LIST* tables,
 
1212
                            COND* cond __attribute__((__unused__)))
1213
1213
{
1214
 
  Table *table= tables->table;
1215
 
  const CHARSET_INFO * const cs= system_charset_info;
 
1214
  TABLE *table= tables->table;
 
1215
  CHARSET_INFO *cs= system_charset_info;
1216
1216
  char *user;
1217
1217
  time_t now= my_time(0);
1218
1218
 
1219
 
  user= NULL;
 
1219
  user= NullS;
1220
1220
 
1221
 
  pthread_mutex_lock(&LOCK_thread_count);
 
1221
  VOID(pthread_mutex_lock(&LOCK_thread_count));
1222
1222
 
1223
1223
  if (!thd->killed)
1224
1224
  {
1242
1242
            (tmp->system_thread ? "system user" : "unauthenticated user");
1243
1243
      table->field[1]->store(val, strlen(val), cs);
1244
1244
      /* HOST */
1245
 
      table->field[2]->store(tmp_sctx->ip, strlen(tmp_sctx->ip), cs);
 
1245
      table->field[2]->store(tmp_sctx->host_or_ip,
 
1246
                             strlen(tmp_sctx->host_or_ip), cs);
1246
1247
      /* DB */
1247
1248
      if (tmp->db)
1248
1249
      {
1258
1259
      else
1259
1260
        table->field[4]->store(command_name[tmp->command].str,
1260
1261
                               command_name[tmp->command].length, cs);
1261
 
      /* DRIZZLE_TIME */
 
1262
      /* MYSQL_TIME */
1262
1263
      table->field[5]->store((uint32_t)(tmp->start_time ?
1263
1264
                                      now - tmp->start_time : 0), true);
1264
1265
      /* STATE */
1265
1266
      val= (char*) (tmp->net.reading_or_writing ?
1266
1267
                    (tmp->net.reading_or_writing == 2 ?
1267
1268
                     "Writing to net" :
1268
 
                     tmp->command == COM_SLEEP ? NULL :
 
1269
                     tmp->command == COM_SLEEP ? NullS :
1269
1270
                     "Reading from net") :
1270
 
                    tmp->get_proc_info() ? tmp->get_proc_info() :
 
1271
                    tmp->proc_info ? tmp->proc_info :
1271
1272
                    tmp->mysys_var &&
1272
1273
                    tmp->mysys_var->current_cond ?
1273
 
                    "Waiting on cond" : NULL);
 
1274
                    "Waiting on cond" : NullS);
1274
1275
      if (val)
1275
1276
      {
1276
1277
        table->field[6]->store(val, strlen(val), cs);
1284
1285
      if (tmp->query)
1285
1286
      {
1286
1287
        table->field[7]->store(tmp->query,
1287
 
                               cmin((uint32_t)PROCESS_LIST_INFO_WIDTH,
 
1288
                               min(PROCESS_LIST_INFO_WIDTH,
1288
1289
                                   tmp->query_length), cs);
1289
1290
        table->field[7]->set_notnull();
1290
1291
      }
1291
1292
 
1292
1293
      if (schema_table_store_record(thd, table))
1293
1294
      {
1294
 
        pthread_mutex_unlock(&LOCK_thread_count);
 
1295
        VOID(pthread_mutex_unlock(&LOCK_thread_count));
1295
1296
        return(1);
1296
1297
      }
1297
1298
    }
1298
1299
  }
1299
1300
 
1300
 
  pthread_mutex_unlock(&LOCK_thread_count);
 
1301
  VOID(pthread_mutex_unlock(&LOCK_thread_count));
1301
1302
  return(0);
1302
1303
}
1303
1304
 
1318
1319
*/
1319
1320
static void shrink_var_array(DYNAMIC_ARRAY *array)
1320
1321
{
1321
 
  uint32_t a,b;
 
1322
  uint a,b;
1322
1323
  SHOW_VAR *all= dynamic_element(array, 0, SHOW_VAR *);
1323
1324
 
1324
1325
  for (a= b= 0; b < array->elements; b++)
1326
1327
      all[a++]= all[b];
1327
1328
  if (a)
1328
1329
  {
1329
 
    memset(all+a, 0, sizeof(SHOW_VAR)); // writing NULL-element to the end
 
1330
    bzero(all+a, sizeof(SHOW_VAR)); // writing NULL-element to the end
1330
1331
    array->elements= a;
1331
1332
  }
1332
1333
  else // array is completely empty - delete it
1364
1365
    goto err;
1365
1366
  }
1366
1367
  while (list->name)
1367
 
    res|= insert_dynamic(&all_status_vars, (unsigned char*)list++);
1368
 
  res|= insert_dynamic(&all_status_vars, (unsigned char*)list); // appending NULL-element
 
1368
    res|= insert_dynamic(&all_status_vars, (uchar*)list++);
 
1369
  res|= insert_dynamic(&all_status_vars, (uchar*)list); // appending NULL-element
1369
1370
  all_status_vars.elements--; // but next insert_dynamic should overwite it
1370
1371
  if (status_vars_inited)
1371
1372
    sort_dynamic(&all_status_vars, show_var_cmp);
1459
1460
  else
1460
1461
  {
1461
1462
    SHOW_VAR *all= dynamic_element(&all_status_vars, 0, SHOW_VAR *);
1462
 
    uint32_t i;
 
1463
    uint i;
1463
1464
    for (; list->name; list++)
1464
1465
    {
1465
1466
      for (i= 0; i < all_status_vars.elements; i++)
1484
1485
                              SHOW_VAR *variables,
1485
1486
                              enum enum_var_type value_type,
1486
1487
                              struct system_status_var *status_var,
1487
 
                              const char *prefix, Table *table,
 
1488
                              const char *prefix, TABLE *table,
1488
1489
                              bool ucase_names)
1489
1490
{
1490
1491
  MY_ALIGNED_BYTE_ARRAY(buff_data, SHOW_VAR_FUNC_BUFF_SIZE, long);
1499
1500
  null_lex_str.str= 0;                          // For sys_var->value_ptr()
1500
1501
  null_lex_str.length= 0;
1501
1502
 
1502
 
  prefix_end=my_stpncpy(name_buffer, prefix, sizeof(name_buffer)-1);
 
1503
  prefix_end=strnmov(name_buffer, prefix, sizeof(name_buffer)-1);
1503
1504
  if (*prefix)
1504
1505
    *prefix_end++= '_';
1505
1506
  len=name_buffer + sizeof(name_buffer) - prefix_end;
1506
1507
 
1507
1508
  for (; variables->name; variables++)
1508
1509
  {
1509
 
    my_stpncpy(prefix_end, variables->name, len);
 
1510
    strnmov(prefix_end, variables->name, len);
1510
1511
    name_buffer[sizeof(name_buffer)-1]=0;       /* Safety */
1511
1512
    if (ucase_names)
1512
1513
      make_upper(name_buffer);
1571
1572
          end= int64_t10_to_str((int64_t) *(ha_rows*) value, buff, 10);
1572
1573
          break;
1573
1574
        case SHOW_BOOL:
1574
 
          end= my_stpcpy(buff, *(bool*) value ? "ON" : "OFF");
 
1575
          end= strmov(buff, *(bool*) value ? "ON" : "OFF");
1575
1576
          break;
1576
1577
        case SHOW_MY_BOOL:
1577
 
          end= my_stpcpy(buff, *(bool*) value ? "ON" : "OFF");
 
1578
          end= strmov(buff, *(bool*) value ? "ON" : "OFF");
1578
1579
          break;
1579
1580
        case SHOW_INT:
1580
1581
          end= int10_to_str((long) *(uint32_t*) value, buff, 10);
1583
1584
        {
1584
1585
          SHOW_COMP_OPTION tmp= *(SHOW_COMP_OPTION*) value;
1585
1586
          pos= show_comp_option_name[(int) tmp];
1586
 
          end= strchr(pos, '\0');
 
1587
          end= strend(pos);
1587
1588
          break;
1588
1589
        }
1589
1590
        case SHOW_CHAR:
1590
1591
        {
1591
1592
          if (!(pos= value))
1592
1593
            pos= "";
1593
 
          end= strchr(pos, '\0');
 
1594
          end= strend(pos);
1594
1595
          break;
1595
1596
        }
1596
1597
       case SHOW_CHAR_PTR:
1597
1598
        {
1598
1599
          if (!(pos= *(char**) value))
1599
1600
            pos= "";
1600
 
          end= strchr(pos, '\0');
 
1601
          end= strend(pos);
1601
1602
          break;
1602
1603
        }
1603
1604
        case SHOW_KEY_CACHE_LONG:
1639
1640
{
1640
1641
 
1641
1642
  /* Ensure that thread id not killed during loop */
1642
 
  pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
 
1643
  VOID(pthread_mutex_lock(&LOCK_thread_count)); // For unlink from list
1643
1644
 
1644
1645
  I_List_iterator<THD> it(threads);
1645
1646
  THD *tmp;
1651
1652
  while ((tmp= it++))
1652
1653
    add_to_status(to, &tmp->status_var);
1653
1654
  
1654
 
  pthread_mutex_unlock(&LOCK_thread_count);
 
1655
  VOID(pthread_mutex_unlock(&LOCK_thread_count));
1655
1656
  return;
1656
1657
}
1657
1658
 
1680
1681
    1                     error
1681
1682
*/
1682
1683
 
1683
 
bool schema_table_store_record(THD *thd, Table *table)
 
1684
bool schema_table_store_record(THD *thd, TABLE *table)
1684
1685
{
1685
1686
  int error;
1686
1687
  if ((error= table->file->ha_write_row(table->record[0])))
1726
1727
*/
1727
1728
 
1728
1729
bool get_lookup_value(THD *thd, Item_func *item_func,
1729
 
                      TableList *table, 
 
1730
                      TABLE_LIST *table, 
1730
1731
                      LOOKUP_FIELD_VALUES *lookup_field_vals)
1731
1732
{
1732
1733
  ST_SCHEMA_TABLE *schema_table= table->schema_table;
1743
1744
    char tmp[MAX_FIELD_WIDTH];
1744
1745
    String *tmp_str, str_buff(tmp, sizeof(tmp), system_charset_info);
1745
1746
    Item_field *item_field;
1746
 
    const CHARSET_INFO * const cs= system_charset_info;
 
1747
    CHARSET_INFO *cs= system_charset_info;
1747
1748
 
1748
1749
    if (item_func->arguments()[0]->type() == Item::FIELD_ITEM &&
1749
1750
        item_func->arguments()[1]->const_item())
1770
1771
      return 1;
1771
1772
 
1772
1773
    /* Lookup value is database name */
1773
 
    if (!cs->coll->strnncollsp(cs, (unsigned char *) field_name1, strlen(field_name1),
1774
 
                               (unsigned char *) item_field->field_name,
 
1774
    if (!cs->coll->strnncollsp(cs, (uchar *) field_name1, strlen(field_name1),
 
1775
                               (uchar *) item_field->field_name,
1775
1776
                               strlen(item_field->field_name), 0))
1776
1777
    {
1777
1778
      thd->make_lex_string(&lookup_field_vals->db_value, tmp_str->ptr(),
1778
1779
                           tmp_str->length(), false);
1779
1780
    }
1780
1781
    /* Lookup value is table name */
1781
 
    else if (!cs->coll->strnncollsp(cs, (unsigned char *) field_name2,
 
1782
    else if (!cs->coll->strnncollsp(cs, (uchar *) field_name2,
1782
1783
                                    strlen(field_name2),
1783
 
                                    (unsigned char *) item_field->field_name,
 
1784
                                    (uchar *) item_field->field_name,
1784
1785
                                    strlen(item_field->field_name), 0))
1785
1786
    {
1786
1787
      thd->make_lex_string(&lookup_field_vals->table_value, tmp_str->ptr(),
1808
1809
    1             error, there can be no matching records for the condition
1809
1810
*/
1810
1811
 
1811
 
bool calc_lookup_values_from_cond(THD *thd, COND *cond, TableList *table,
 
1812
bool calc_lookup_values_from_cond(THD *thd, COND *cond, TABLE_LIST *table,
1812
1813
                                  LOOKUP_FIELD_VALUES *lookup_field_vals)
1813
1814
{
1814
1815
  if (!cond)
1843
1844
}
1844
1845
 
1845
1846
 
1846
 
bool uses_only_table_name_fields(Item *item, TableList *table)
 
1847
bool uses_only_table_name_fields(Item *item, TABLE_LIST *table)
1847
1848
{
1848
1849
  if (item->type() == Item::FUNC_ITEM)
1849
1850
  {
1850
1851
    Item_func *item_func= (Item_func*)item;
1851
 
    for (uint32_t i=0; i<item_func->argument_count(); i++)
 
1852
    for (uint i=0; i<item_func->argument_count(); i++)
1852
1853
    {
1853
1854
      if (!uses_only_table_name_fields(item_func->arguments()[i], table))
1854
1855
        return 0;
1857
1858
  else if (item->type() == Item::FIELD_ITEM)
1858
1859
  {
1859
1860
    Item_field *item_field= (Item_field*)item;
1860
 
    const CHARSET_INFO * const cs= system_charset_info;
 
1861
    CHARSET_INFO *cs= system_charset_info;
1861
1862
    ST_SCHEMA_TABLE *schema_table= table->schema_table;
1862
1863
    ST_FIELD_INFO *field_info= schema_table->fields_info;
1863
1864
    const char *field_name1= schema_table->idx_field1 >= 0 ?
1865
1866
    const char *field_name2= schema_table->idx_field2 >= 0 ?
1866
1867
      field_info[schema_table->idx_field2].field_name : "";
1867
1868
    if (table->table != item_field->field->table ||
1868
 
        (cs->coll->strnncollsp(cs, (unsigned char *) field_name1, strlen(field_name1),
1869
 
                               (unsigned char *) item_field->field_name,
 
1869
        (cs->coll->strnncollsp(cs, (uchar *) field_name1, strlen(field_name1),
 
1870
                               (uchar *) item_field->field_name,
1870
1871
                               strlen(item_field->field_name), 0) &&
1871
 
         cs->coll->strnncollsp(cs, (unsigned char *) field_name2, strlen(field_name2),
1872
 
                               (unsigned char *) item_field->field_name,
 
1872
         cs->coll->strnncollsp(cs, (uchar *) field_name2, strlen(field_name2),
 
1873
                               (uchar *) item_field->field_name,
1873
1874
                               strlen(item_field->field_name), 0)))
1874
1875
      return 0;
1875
1876
  }
1883
1884
}
1884
1885
 
1885
1886
 
1886
 
static COND * make_cond_for_info_schema(COND *cond, TableList *table)
 
1887
static COND * make_cond_for_info_schema(COND *cond, TABLE_LIST *table)
1887
1888
{
1888
1889
  if (!cond)
1889
1890
    return (COND*) 0;
1957
1958
    1             error, there can be no matching records for the condition
1958
1959
*/
1959
1960
 
1960
 
bool get_lookup_field_values(THD *thd, COND *cond, TableList *tables,
 
1961
bool get_lookup_field_values(THD *thd, COND *cond, TABLE_LIST *tables,
1961
1962
                             LOOKUP_FIELD_VALUES *lookup_field_values)
1962
1963
{
1963
1964
  LEX *lex= thd->lex;
1964
 
  const char *wild= lex->wild ? lex->wild->ptr() : NULL;
1965
 
  memset(lookup_field_values, 0, sizeof(LOOKUP_FIELD_VALUES));
 
1965
  const char *wild= lex->wild ? lex->wild->ptr() : NullS;
 
1966
  bzero((char*) lookup_field_values, sizeof(LOOKUP_FIELD_VALUES));
1966
1967
  switch (lex->sql_command) {
1967
1968
  case SQLCOM_SHOW_DATABASES:
1968
1969
    if (wild)
2042
2043
      if (files->push_back(i_s_name_copy))
2043
2044
        return 1;
2044
2045
    }
2045
 
    return (find_files(thd, files, NULL, mysql_data_home,
 
2046
    return (find_files(thd, files, NullS, mysql_data_home,
2046
2047
                       lookup_field_vals->db_value.str, 1) != FIND_FILES_OK);
2047
2048
  }
2048
2049
 
2073
2074
  if (files->push_back(i_s_name_copy))
2074
2075
    return 1;
2075
2076
  *with_i_schema= 1;
2076
 
  return (find_files(thd, files, NULL,
2077
 
                     mysql_data_home, NULL, 1) != FIND_FILES_OK);
 
2077
  return (find_files(thd, files, NullS,
 
2078
                     mysql_data_home, NullS, 1) != FIND_FILES_OK);
2078
2079
}
2079
2080
 
2080
2081
 
2151
2152
  add_data.files= files;
2152
2153
  add_data.wild= wild;
2153
2154
  if (plugin_foreach(thd, add_schema_table,
2154
 
                     DRIZZLE_INFORMATION_SCHEMA_PLUGIN, &add_data))
2155
 
    return(1);
 
2155
                     MYSQL_INFORMATION_SCHEMA_PLUGIN, &add_data))
 
2156
      return(1);
2156
2157
 
2157
2158
  return(0);
2158
2159
}
2238
2239
  @brief          Fill I_S table for SHOW COLUMNS|INDEX commands
2239
2240
 
2240
2241
  @param[in]      thd                      thread handler
2241
 
  @param[in]      tables                   TableList for I_S table
 
2242
  @param[in]      tables                   TABLE_LIST for I_S table
2242
2243
  @param[in]      schema_table             pointer to I_S structure
2243
2244
  @param[in]      open_tables_state_backup pointer to Open_tables_state object
2244
2245
                                           which is used to save|restore original
2251
2252
*/
2252
2253
 
2253
2254
static int 
2254
 
fill_schema_show_cols_or_idxs(THD *thd, TableList *tables,
 
2255
fill_schema_show_cols_or_idxs(THD *thd, TABLE_LIST *tables,
2255
2256
                              ST_SCHEMA_TABLE *schema_table,
2256
2257
                              Open_tables_state *open_tables_state_backup)
2257
2258
{
2259
2260
  bool res;
2260
2261
  LEX_STRING tmp_lex_string, tmp_lex_string1, *db_name, *table_name;
2261
2262
  enum_sql_command save_sql_command= lex->sql_command;
2262
 
  TableList *show_table_list= (TableList*) tables->schema_select_lex->
 
2263
  TABLE_LIST *show_table_list= (TABLE_LIST*) tables->schema_select_lex->
2263
2264
    table_list.first;
2264
 
  Table *table= tables->table;
 
2265
  TABLE *table= tables->table;
2265
2266
  int error= 1;
2266
2267
 
2267
2268
  lex->all_selects_list= tables->schema_select_lex;
2280
2281
  */
2281
2282
  lex->sql_command= SQLCOM_SHOW_FIELDS;
2282
2283
  res= open_normal_and_derived_tables(thd, show_table_list,
2283
 
                                      DRIZZLE_LOCK_IGNORE_FLUSH);
 
2284
                                      MYSQL_LOCK_IGNORE_FLUSH);
2284
2285
  lex->sql_command= save_sql_command;
2285
2286
  /*
2286
2287
    get_all_tables() returns 1 on failure and 0 on success thus
2309
2310
 
2310
2311
 
2311
2312
/**
2312
 
  @brief          Fill I_S table for SHOW Table NAMES commands
 
2313
  @brief          Fill I_S table for SHOW TABLE NAMES commands
2313
2314
 
2314
2315
  @param[in]      thd                      thread handler
2315
 
  @param[in]      table                    Table struct for I_S table
 
2316
  @param[in]      table                    TABLE struct for I_S table
2316
2317
  @param[in]      db_name                  database name
2317
2318
  @param[in]      table_name               table name
2318
2319
  @param[in]      with_i_schema            I_S table if true
2322
2323
    @retval       1           error
2323
2324
*/
2324
2325
 
2325
 
static int fill_schema_table_names(THD *thd, Table *table,
 
2326
static int fill_schema_table_names(THD *thd, TABLE *table,
2326
2327
                                   LEX_STRING *db_name, LEX_STRING *table_name,
2327
2328
                                   bool with_i_schema)
2328
2329
{
2337
2338
    char path[FN_REFLEN];
2338
2339
    (void) build_table_filename(path, sizeof(path), db_name->str, 
2339
2340
                                table_name->str, reg_ext, 0);
2340
 
    if (mysql_frm_type(thd, path, &not_used)) 
2341
 
    {
2342
 
      table->field[3]->store(STRING_WITH_LEN("BASE Table"),
2343
 
                             system_charset_info);
2344
 
    }
2345
 
    else
2346
 
    {
 
2341
    switch (mysql_frm_type(thd, path, &not_used)) {
 
2342
    case FRMTYPE_ERROR:
2347
2343
      table->field[3]->store(STRING_WITH_LEN("ERROR"),
2348
2344
                             system_charset_info);
 
2345
      break;
 
2346
    case FRMTYPE_TABLE:
 
2347
      table->field[3]->store(STRING_WITH_LEN("BASE TABLE"),
 
2348
                             system_charset_info);
 
2349
      break;
 
2350
    default:
 
2351
      assert(0);
2349
2352
    }
2350
 
 
2351
2353
    if (thd->is_error() && thd->main_da.sql_errno() == ER_NO_SUCH_TABLE)
2352
2354
    {
2353
2355
      thd->clear_error();
2376
2378
    @retval       SKIP_OPEN_TABLE | OPEN_FRM_ONLY | OPEN_FULL_TABLE
2377
2379
*/
2378
2380
 
2379
 
static uint32_t get_table_open_method(TableList *tables,
 
2381
static uint get_table_open_method(TABLE_LIST *tables,
2380
2382
                                  ST_SCHEMA_TABLE *schema_table,
2381
 
                                  enum enum_schema_tables schema_table_idx __attribute__((unused)))
 
2383
                                  enum enum_schema_tables schema_table_idx __attribute__((__unused__)))
2382
2384
{
2383
2385
  /*
2384
2386
    determine which method will be used for table opening
2404
2406
  @brief          Fill I_S table with data from FRM file only
2405
2407
 
2406
2408
  @param[in]      thd                      thread handler
2407
 
  @param[in]      table                    Table struct for I_S table
 
2409
  @param[in]      table                    TABLE struct for I_S table
2408
2410
  @param[in]      schema_table             I_S table struct
2409
2411
  @param[in]      db_name                  database name
2410
2412
  @param[in]      table_name               table name
2417
2419
                              open_tables function for this table
2418
2420
*/
2419
2421
 
2420
 
static int fill_schema_table_from_frm(THD *thd,TableList *tables,
 
2422
static int fill_schema_table_from_frm(THD *thd,TABLE_LIST *tables,
2421
2423
                                      ST_SCHEMA_TABLE *schema_table,
2422
2424
                                      LEX_STRING *db_name,
2423
2425
                                      LEX_STRING *table_name,
2424
 
                                      enum enum_schema_tables schema_table_idx __attribute__((unused)))
 
2426
                                      enum enum_schema_tables schema_table_idx __attribute__((__unused__)))
2425
2427
{
2426
 
  Table *table= tables->table;
 
2428
  TABLE *table= tables->table;
2427
2429
  TABLE_SHARE *share;
2428
 
  Table tbl;
2429
 
  TableList table_list;
2430
 
  uint32_t res= 0;
 
2430
  TABLE tbl;
 
2431
  TABLE_LIST table_list;
 
2432
  uint res= 0;
2431
2433
  int error;
2432
2434
  char key[MAX_DBKEY_LENGTH];
2433
 
  uint32_t key_length;
 
2435
  uint key_length;
2434
2436
 
2435
 
  memset(&table_list, 0, sizeof(TableList));
2436
 
  memset(&tbl, 0, sizeof(Table));
 
2437
  bzero((char*) &table_list, sizeof(TABLE_LIST));
 
2438
  bzero((char*) &tbl, sizeof(TABLE));
2437
2439
 
2438
2440
  table_list.table_name= table_name->str;
2439
2441
  table_list.db= db_name->str;
2441
2443
  key_length= create_table_def_key(thd, key, &table_list, 0);
2442
2444
  pthread_mutex_lock(&LOCK_open);
2443
2445
  share= get_table_share(thd, &table_list, key,
2444
 
                         key_length, 0, &error);
 
2446
                         key_length, OPEN_VIEW, &error);
2445
2447
  if (!share)
2446
2448
  {
2447
2449
    res= 0;
2484
2486
    @retval       1                        error
2485
2487
*/
2486
2488
 
2487
 
int get_all_tables(THD *thd, TableList *tables, COND *cond)
 
2489
int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
2488
2490
{
2489
2491
  LEX *lex= thd->lex;
2490
 
  Table *table= tables->table;
 
2492
  TABLE *table= tables->table;
2491
2493
  SELECT_LEX *old_all_select_lex= lex->all_selects_list;
2492
2494
  enum_sql_command save_sql_command= lex->sql_command;
2493
2495
  SELECT_LEX *lsel= tables->schema_select_lex;
2500
2502
  List<LEX_STRING> db_names;
2501
2503
  List_iterator_fast<LEX_STRING> it(db_names);
2502
2504
  COND *partial_cond= 0;
2503
 
  uint32_t derived_tables= lex->derived_tables; 
 
2505
  uint derived_tables= lex->derived_tables; 
2504
2506
  int error= 1;
2505
2507
  Open_tables_state open_tables_state_backup;
2506
2508
  Query_tables_list query_tables_list_backup;
2507
 
  uint32_t table_open_method;
 
2509
  uint table_open_method;
2508
2510
  bool old_value= thd->no_warnings_for_error;
2509
2511
 
2510
2512
  lex->reset_n_backup_query_tables_list(&query_tables_list_backup);
2612
2614
            continue;
2613
2615
          }
2614
2616
 
2615
 
          /* SHOW Table NAMES command */
 
2617
          /* SHOW TABLE NAMES command */
2616
2618
          if (schema_table_idx == SCH_TABLE_NAMES)
2617
2619
          {
2618
2620
            if (fill_schema_table_names(thd, tables->table, db_name,
2643
2645
              goto err;
2644
2646
            if (make_table_list(thd, &sel, db_name, table_name))
2645
2647
              goto err;
2646
 
            TableList *show_table_list= (TableList*) sel.table_list.first;
 
2648
            TABLE_LIST *show_table_list= (TABLE_LIST*) sel.table_list.first;
2647
2649
            lex->all_selects_list= &sel;
2648
2650
            lex->derived_tables= 0;
2649
2651
            lex->sql_command= SQLCOM_SHOW_FIELDS;
2650
2652
            show_table_list->i_s_requested_object=
2651
2653
              schema_table->i_s_requested_object;
2652
2654
            res= open_normal_and_derived_tables(thd, show_table_list,
2653
 
                                                DRIZZLE_LOCK_IGNORE_FLUSH);
 
2655
                                                MYSQL_LOCK_IGNORE_FLUSH);
2654
2656
            lex->sql_command= save_sql_command;
2655
2657
            /*
2656
2658
              XXX:  show_table_list has a flag i_is_requested,
2714
2716
}
2715
2717
 
2716
2718
 
2717
 
bool store_schema_shemata(THD* thd, Table *table, LEX_STRING *db_name,
2718
 
                          const CHARSET_INFO * const cs)
 
2719
bool store_schema_shemata(THD* thd, TABLE *table, LEX_STRING *db_name,
 
2720
                          CHARSET_INFO *cs)
2719
2721
{
2720
2722
  restore_record(table, s->default_values);
2721
2723
  table->field[1]->store(db_name->str, db_name->length, system_charset_info);
2725
2727
}
2726
2728
 
2727
2729
 
2728
 
int fill_schema_schemata(THD *thd, TableList *tables, COND *cond)
 
2730
int fill_schema_schemata(THD *thd, TABLE_LIST *tables, COND *cond)
2729
2731
{
2730
2732
  /*
2731
2733
    TODO: fill_schema_shemata() is called when new client is connected.
2737
2739
  LEX_STRING *db_name;
2738
2740
  bool with_i_schema;
2739
2741
  HA_CREATE_INFO create;
2740
 
  Table *table= tables->table;
 
2742
  TABLE *table= tables->table;
2741
2743
 
2742
2744
  if (get_lookup_field_values(thd, cond, tables, &lookup_field_vals))
2743
2745
    return(0);
2752
2754
     !with_i_schema)
2753
2755
  {
2754
2756
    char path[FN_REFLEN+16];
2755
 
    uint32_t path_len;
 
2757
    uint path_len;
2756
2758
    struct stat stat_info;
2757
2759
    if (!lookup_field_vals.db_value.str[0])
2758
2760
      return(0);
2785
2787
}
2786
2788
 
2787
2789
 
2788
 
static int get_schema_tables_record(THD *thd, TableList *tables,
2789
 
                                    Table *table, bool res,
 
2790
static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
 
2791
                                    TABLE *table, bool res,
2790
2792
                                    LEX_STRING *db_name,
2791
2793
                                    LEX_STRING *table_name)
2792
2794
{
2793
2795
  const char *tmp_buff;
2794
 
  DRIZZLE_TIME time;
2795
 
  const CHARSET_INFO * const cs= system_charset_info;
 
2796
  MYSQL_TIME time;
 
2797
  CHARSET_INFO *cs= system_charset_info;
2796
2798
 
2797
2799
  restore_record(table, s->default_values);
2798
2800
  table->field[1]->store(db_name->str, db_name->length, cs);
2806
2808
    if (tables->schema_table)
2807
2809
      table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"), cs);
2808
2810
    else
2809
 
      table->field[3]->store(STRING_WITH_LEN("BASE Table"), cs);
 
2811
      table->field[3]->store(STRING_WITH_LEN("BASE TABLE"), cs);
2810
2812
    table->field[20]->store(error, strlen(error), cs);
2811
2813
    thd->clear_error();
2812
2814
  }
2813
2815
  else
2814
2816
  {
2815
 
    char option_buff[400],*ptr;
2816
 
    Table *show_table= tables->table;
 
2817
    char option_buff[350],*ptr;
 
2818
    TABLE *show_table= tables->table;
2817
2819
    TABLE_SHARE *share= show_table->s;
2818
2820
    handler *file= show_table->file;
2819
2821
    handlerton *tmp_db_type= share->db_type();
2822
2824
    else if (share->tmp_table)
2823
2825
      table->field[3]->store(STRING_WITH_LEN("LOCAL TEMPORARY"), cs);
2824
2826
    else
2825
 
      table->field[3]->store(STRING_WITH_LEN("BASE Table"), cs);
 
2827
      table->field[3]->store(STRING_WITH_LEN("BASE TABLE"), cs);
2826
2828
 
2827
2829
    for (int i= 4; i < 20; i++)
2828
2830
    {
2837
2839
    ptr=option_buff;
2838
2840
    if (share->min_rows)
2839
2841
    {
2840
 
      ptr=my_stpcpy(ptr," min_rows=");
 
2842
      ptr=strmov(ptr," min_rows=");
2841
2843
      ptr=int64_t10_to_str(share->min_rows,ptr,10);
2842
2844
    }
2843
2845
    if (share->max_rows)
2844
2846
    {
2845
 
      ptr=my_stpcpy(ptr," max_rows=");
 
2847
      ptr=strmov(ptr," max_rows=");
2846
2848
      ptr=int64_t10_to_str(share->max_rows,ptr,10);
2847
2849
    }
2848
2850
    if (share->avg_row_length)
2849
2851
    {
2850
 
      ptr=my_stpcpy(ptr," avg_row_length=");
 
2852
      ptr=strmov(ptr," avg_row_length=");
2851
2853
      ptr=int64_t10_to_str(share->avg_row_length,ptr,10);
2852
2854
    }
2853
2855
    if (share->db_create_options & HA_OPTION_PACK_KEYS)
2854
 
      ptr=my_stpcpy(ptr," pack_keys=1");
 
2856
      ptr=strmov(ptr," pack_keys=1");
2855
2857
    if (share->db_create_options & HA_OPTION_NO_PACK_KEYS)
2856
 
      ptr=my_stpcpy(ptr," pack_keys=0");
 
2858
      ptr=strmov(ptr," pack_keys=0");
2857
2859
    /* We use CHECKSUM, instead of TABLE_CHECKSUM, for backward compability */
2858
2860
    if (share->db_create_options & HA_OPTION_CHECKSUM)
2859
 
      ptr=my_stpcpy(ptr," checksum=1");
 
2861
      ptr=strmov(ptr," checksum=1");
2860
2862
    if (share->page_checksum != HA_CHOICE_UNDEF)
2861
2863
      ptr= strxmov(ptr, " page_checksum=",
2862
 
                   ha_choice_values[(uint) share->page_checksum], NULL);
 
2864
                   ha_choice_values[(uint) share->page_checksum], NullS);
2863
2865
    if (share->db_create_options & HA_OPTION_DELAY_KEY_WRITE)
2864
 
      ptr=my_stpcpy(ptr," delay_key_write=1");
 
2866
      ptr=strmov(ptr," delay_key_write=1");
2865
2867
    if (share->row_type != ROW_TYPE_DEFAULT)
2866
2868
      ptr=strxmov(ptr, " row_format=", 
2867
2869
                  ha_row_type[(uint) share->row_type],
2868
 
                  NULL);
2869
 
    if (share->block_size)
2870
 
    {
2871
 
      ptr= my_stpcpy(ptr, " block_size=");
2872
 
      ptr= int64_t10_to_str(share->block_size, ptr, 10);
2873
 
    }
2874
 
    
 
2870
                  NullS);
2875
2871
    if (share->transactional != HA_CHOICE_UNDEF)
2876
2872
    {
2877
2873
      ptr= strxmov(ptr, " TRANSACTIONAL=",
2878
2874
                   (share->transactional == HA_CHOICE_YES ? "1" : "0"),
2879
 
                   NULL);
 
2875
                   NullS);
2880
2876
    }
2881
2877
    if (share->transactional != HA_CHOICE_UNDEF)
2882
2878
      ptr= strxmov(ptr, " transactional=",
2883
 
                   ha_choice_values[(uint) share->transactional], NULL);
 
2879
                   ha_choice_values[(uint) share->transactional], NullS);
2884
2880
    table->field[19]->store(option_buff+1,
2885
2881
                            (ptr == option_buff ? 0 : 
2886
2882
                             (uint) (ptr-option_buff)-1), cs);
2949
2945
      {
2950
2946
        thd->variables.time_zone->gmt_sec_to_TIME(&time,
2951
2947
                                                  (my_time_t) file->stats.create_time);
2952
 
        table->field[14]->store_time(&time, DRIZZLE_TIMESTAMP_DATETIME);
 
2948
        table->field[14]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
2953
2949
        table->field[14]->set_notnull();
2954
2950
      }
2955
2951
      if (file->stats.update_time)
2956
2952
      {
2957
2953
        thd->variables.time_zone->gmt_sec_to_TIME(&time,
2958
2954
                                                  (my_time_t) file->stats.update_time);
2959
 
        table->field[15]->store_time(&time, DRIZZLE_TIMESTAMP_DATETIME);
 
2955
        table->field[15]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
2960
2956
        table->field[15]->set_notnull();
2961
2957
      }
2962
2958
      if (file->stats.check_time)
2963
2959
      {
2964
2960
        thd->variables.time_zone->gmt_sec_to_TIME(&time,
2965
2961
                                                  (my_time_t) file->stats.check_time);
2966
 
        table->field[16]->store_time(&time, DRIZZLE_TIMESTAMP_DATETIME);
 
2962
        table->field[16]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
2967
2963
        table->field[16]->set_notnull();
2968
2964
      }
2969
2965
      if (file->ha_table_flags() & (ulong) HA_HAS_CHECKSUM)
2989
2985
  @return         void
2990
2986
*/
2991
2987
 
2992
 
void store_column_type(Table *table, Field *field, const CHARSET_INFO * const cs,
2993
 
                       uint32_t offset)
 
2988
void store_column_type(TABLE *table, Field *field, CHARSET_INFO *cs,
 
2989
                       uint offset)
2994
2990
{
2995
2991
  bool is_blob;
2996
2992
  int decimals, field_length;
3007
3003
  table->field[offset]->store(column_type.ptr(),
3008
3004
                         (tmp_buff ? tmp_buff - column_type.ptr() :
3009
3005
                          column_type.length()), cs);
3010
 
  is_blob= (field->type() == DRIZZLE_TYPE_BLOB);
 
3006
  is_blob= (field->type() == MYSQL_TYPE_BLOB);
3011
3007
  if (field->has_charset() || is_blob ||
3012
 
      field->real_type() == DRIZZLE_TYPE_VARCHAR)  // For varbinary type
 
3008
      field->real_type() == MYSQL_TYPE_VARCHAR ||  // For varbinary type
 
3009
      field->real_type() == MYSQL_TYPE_STRING)     // For binary type
3013
3010
  {
3014
3011
    uint32_t octet_max_length= field->max_display_length();
3015
3012
    if (is_blob && octet_max_length != (uint32_t) 4294967295U)
3032
3029
 
3033
3030
  decimals= field->decimals();
3034
3031
  switch (field->type()) {
3035
 
  case DRIZZLE_TYPE_NEWDECIMAL:
 
3032
  case MYSQL_TYPE_NEWDECIMAL:
3036
3033
    field_length= ((Field_new_decimal*) field)->precision;
3037
3034
    break;
3038
 
  case DRIZZLE_TYPE_TINY:
3039
 
  case DRIZZLE_TYPE_LONG:
3040
 
  case DRIZZLE_TYPE_LONGLONG:
 
3035
  case MYSQL_TYPE_TINY:
 
3036
  case MYSQL_TYPE_SHORT:
 
3037
  case MYSQL_TYPE_LONG:
 
3038
  case MYSQL_TYPE_LONGLONG:
3041
3039
    field_length= field->max_display_length() - 1;
3042
3040
    break;
3043
 
  case DRIZZLE_TYPE_DOUBLE:
 
3041
  case MYSQL_TYPE_DOUBLE:
3044
3042
    field_length= field->field_length;
3045
3043
    if (decimals == NOT_FIXED_DEC)
3046
3044
      decimals= -1;                           // return NULL
3076
3074
}
3077
3075
 
3078
3076
 
3079
 
static int get_schema_column_record(THD *thd, TableList *tables,
3080
 
                                    Table *table, bool res,
 
3077
static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
 
3078
                                    TABLE *table, bool res,
3081
3079
                                    LEX_STRING *db_name,
3082
3080
                                    LEX_STRING *table_name)
3083
3081
{
3084
3082
  LEX *lex= thd->lex;
3085
 
  const char *wild= lex->wild ? lex->wild->ptr() : NULL;
3086
 
  const CHARSET_INFO * const cs= system_charset_info;
3087
 
  Table *show_table;
 
3083
  const char *wild= lex->wild ? lex->wild->ptr() : NullS;
 
3084
  CHARSET_INFO *cs= system_charset_info;
 
3085
  TABLE *show_table;
3088
3086
  TABLE_SHARE *show_table_share;
3089
3087
  Field **ptr, *field, *timestamp_field;
3090
3088
  int count;
3098
3096
        rather than in SHOW COLUMNS
3099
3097
      */ 
3100
3098
      if (thd->is_error())
3101
 
        push_warning(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
3099
        push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
3102
3100
                     thd->main_da.sql_errno(), thd->main_da.message());
3103
3101
      thd->clear_error();
3104
3102
      res= 0;
3127
3125
    if (!show_table->read_set)
3128
3126
    {
3129
3127
      /* to satisfy 'field->val_str' ASSERTs */
3130
 
      unsigned char *bitmaps;
3131
 
      uint32_t bitmap_size= show_table_share->column_bitmap_size;
3132
 
      if (!(bitmaps= (unsigned char*) alloc_root(thd->mem_root, bitmap_size)))
 
3128
      uchar *bitmaps;
 
3129
      uint bitmap_size= show_table_share->column_bitmap_size;
 
3130
      if (!(bitmaps= (uchar*) alloc_root(thd->mem_root, bitmap_size)))
3133
3131
        return(0);
3134
3132
      bitmap_init(&show_table->def_read_set,
3135
3133
                  (my_bitmap_map*) bitmaps, show_table_share->fields, false);
3141
3139
 
3142
3140
  for (; (field= *ptr) ; ptr++)
3143
3141
  {
3144
 
    unsigned char *pos;
 
3142
    uchar *pos;
3145
3143
    char tmp[MAX_FIELD_WIDTH];
3146
3144
    String type(tmp,sizeof(tmp), system_charset_info);
3147
3145
    char *end;
3169
3167
      table->field[5]->store(type.ptr(), type.length(), cs);
3170
3168
      table->field[5]->set_notnull();
3171
3169
    }
3172
 
    pos=(unsigned char*) ((field->flags & NOT_NULL_FLAG) ?  "NO" : "YES");
 
3170
    pos=(uchar*) ((field->flags & NOT_NULL_FLAG) ?  "NO" : "YES");
3173
3171
    table->field[6]->store((const char*) pos,
3174
3172
                           strlen((const char*) pos), cs);
3175
3173
    store_column_type(table, field, cs, 7);
3176
3174
 
3177
 
    pos=(unsigned char*) ((field->flags & PRI_KEY_FLAG) ? "PRI" :
 
3175
    pos=(uchar*) ((field->flags & PRI_KEY_FLAG) ? "PRI" :
3178
3176
                 (field->flags & UNIQUE_KEY_FLAG) ? "UNI" :
3179
3177
                 (field->flags & MULTIPLE_KEY_FLAG) ? "MUL":"");
3180
3178
    table->field[15]->store((const char*) pos,
3187
3185
        field->unireg_check != Field::TIMESTAMP_DN_FIELD)
3188
3186
      table->field[16]->store(STRING_WITH_LEN("on update CURRENT_TIMESTAMP"),
3189
3187
                              cs);
3190
 
    if (field->vcol_info)
3191
 
          table->field[16]->store(STRING_WITH_LEN("VIRTUAL"), cs);
 
3188
 
3192
3189
    table->field[18]->store(field->comment.str, field->comment.length, cs);
3193
3190
    {
3194
3191
      enum column_format_type column_format= (enum column_format_type)
3195
3192
        ((field->flags >> COLUMN_FORMAT_FLAGS) & COLUMN_FORMAT_MASK);
3196
 
      pos=(unsigned char*)"Default";
 
3193
      pos=(uchar*)"Default";
3197
3194
      table->field[19]->store((const char*) pos,
3198
3195
                              strlen((const char*) pos), cs);
3199
 
      pos=(unsigned char*)(column_format == COLUMN_FORMAT_TYPE_DEFAULT ? "Default" :
 
3196
      pos=(uchar*)(column_format == COLUMN_FORMAT_TYPE_DEFAULT ? "Default" :
3200
3197
                   column_format == COLUMN_FORMAT_TYPE_FIXED ? "Fixed" :
3201
3198
                                                             "Dynamic");
3202
3199
      table->field[20]->store((const char*) pos,
3210
3207
 
3211
3208
 
3212
3209
 
3213
 
int fill_schema_charsets(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
 
3210
int fill_schema_charsets(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((__unused__)))
3214
3211
{
3215
3212
  CHARSET_INFO **cs;
3216
 
  const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NULL;
3217
 
  Table *table= tables->table;
3218
 
  const CHARSET_INFO * const scs= system_charset_info;
 
3213
  const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
 
3214
  TABLE *table= tables->table;
 
3215
  CHARSET_INFO *scs= system_charset_info;
3219
3216
 
3220
3217
  for (cs= all_charsets ; cs < all_charsets+255 ; cs++)
3221
3218
  {
3222
 
    const CHARSET_INFO * const tmp_cs= cs[0];
 
3219
    CHARSET_INFO *tmp_cs= cs[0];
3223
3220
    if (tmp_cs && (tmp_cs->state & MY_CS_PRIMARY) && 
3224
3221
        (tmp_cs->state & MY_CS_AVAILABLE) &&
3225
3222
        !(tmp_cs->state & MY_CS_HIDDEN) &&
3226
3223
        !(wild && wild[0] &&
3227
 
          wild_case_compare(scs, tmp_cs->csname,wild)))
 
3224
          wild_case_compare(scs, tmp_cs->csname,wild)))
3228
3225
    {
3229
3226
      const char *comment;
3230
3227
      restore_record(table, s->default_values);
3241
3238
}
3242
3239
 
3243
3240
 
3244
 
int fill_schema_collation(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
 
3241
int fill_schema_collation(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((__unused__)))
3245
3242
{
3246
3243
  CHARSET_INFO **cs;
3247
 
  const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NULL;
3248
 
  Table *table= tables->table;
3249
 
  const CHARSET_INFO * const scs= system_charset_info;
 
3244
  const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
 
3245
  TABLE *table= tables->table;
 
3246
  CHARSET_INFO *scs= system_charset_info;
3250
3247
  for (cs= all_charsets ; cs < all_charsets+255 ; cs++ )
3251
3248
  {
3252
3249
    CHARSET_INFO **cl;
3253
 
    const CHARSET_INFO *tmp_cs= cs[0];
 
3250
    CHARSET_INFO *tmp_cs= cs[0];
3254
3251
    if (!tmp_cs || !(tmp_cs->state & MY_CS_AVAILABLE) ||
3255
3252
         (tmp_cs->state & MY_CS_HIDDEN) ||
3256
3253
        !(tmp_cs->state & MY_CS_PRIMARY))
3257
3254
      continue;
3258
3255
    for (cl= all_charsets; cl < all_charsets+255 ;cl ++)
3259
3256
    {
3260
 
      const CHARSET_INFO *tmp_cl= cl[0];
 
3257
      CHARSET_INFO *tmp_cl= cl[0];
3261
3258
      if (!tmp_cl || !(tmp_cl->state & MY_CS_AVAILABLE) || 
3262
3259
          !my_charset_same(tmp_cs, tmp_cl))
3263
 
        continue;
 
3260
        continue;
3264
3261
      if (!(wild && wild[0] &&
3265
 
          wild_case_compare(scs, tmp_cl->name,wild)))
 
3262
          wild_case_compare(scs, tmp_cl->name,wild)))
3266
3263
      {
3267
 
        const char *tmp_buff;
3268
 
        restore_record(table, s->default_values);
3269
 
        table->field[0]->store(tmp_cl->name, strlen(tmp_cl->name), scs);
 
3264
        const char *tmp_buff;
 
3265
        restore_record(table, s->default_values);
 
3266
        table->field[0]->store(tmp_cl->name, strlen(tmp_cl->name), scs);
3270
3267
        table->field[1]->store(tmp_cl->csname , strlen(tmp_cl->csname), scs);
3271
3268
        table->field[2]->store((int64_t) tmp_cl->number, true);
3272
3269
        tmp_buff= (tmp_cl->state & MY_CS_PRIMARY) ? "Yes" : "";
3273
 
        table->field[3]->store(tmp_buff, strlen(tmp_buff), scs);
 
3270
        table->field[3]->store(tmp_buff, strlen(tmp_buff), scs);
3274
3271
        tmp_buff= (tmp_cl->state & MY_CS_COMPILED)? "Yes" : "";
3275
 
        table->field[4]->store(tmp_buff, strlen(tmp_buff), scs);
 
3272
        table->field[4]->store(tmp_buff, strlen(tmp_buff), scs);
3276
3273
        table->field[5]->store((int64_t) tmp_cl->strxfrm_multiply, true);
3277
3274
        if (schema_table_store_record(thd, table))
3278
3275
          return 1;
3283
3280
}
3284
3281
 
3285
3282
 
3286
 
int fill_schema_coll_charset_app(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
 
3283
int fill_schema_coll_charset_app(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((__unused__)))
3287
3284
{
3288
3285
  CHARSET_INFO **cs;
3289
 
  Table *table= tables->table;
3290
 
  const CHARSET_INFO * const scs= system_charset_info;
 
3286
  TABLE *table= tables->table;
 
3287
  CHARSET_INFO *scs= system_charset_info;
3291
3288
  for (cs= all_charsets ; cs < all_charsets+255 ; cs++ )
3292
3289
  {
3293
3290
    CHARSET_INFO **cl;
3294
 
    const CHARSET_INFO *tmp_cs= cs[0];
 
3291
    CHARSET_INFO *tmp_cs= cs[0];
3295
3292
    if (!tmp_cs || !(tmp_cs->state & MY_CS_AVAILABLE) || 
3296
3293
        !(tmp_cs->state & MY_CS_PRIMARY))
3297
3294
      continue;
3298
3295
    for (cl= all_charsets; cl < all_charsets+255 ;cl ++)
3299
3296
    {
3300
 
      const CHARSET_INFO *tmp_cl= cl[0];
 
3297
      CHARSET_INFO *tmp_cl= cl[0];
3301
3298
      if (!tmp_cl || !(tmp_cl->state & MY_CS_AVAILABLE) || 
3302
3299
          !my_charset_same(tmp_cs,tmp_cl))
3303
3300
        continue;
3312
3309
}
3313
3310
 
3314
3311
 
3315
 
static int get_schema_stat_record(THD *thd, TableList *tables,
3316
 
                                  Table *table, bool res,
 
3312
static int get_schema_stat_record(THD *thd, TABLE_LIST *tables,
 
3313
                                  TABLE *table, bool res,
3317
3314
                                  LEX_STRING *db_name,
3318
3315
                                  LEX_STRING *table_name)
3319
3316
{
3320
 
  const CHARSET_INFO * const cs= system_charset_info;
 
3317
  CHARSET_INFO *cs= system_charset_info;
3321
3318
  if (res)
3322
3319
  {
3323
3320
    if (thd->lex->sql_command != SQLCOM_SHOW_KEYS)
3327
3324
        rather than in SHOW KEYS
3328
3325
      */
3329
3326
      if (thd->is_error())
3330
 
        push_warning(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
3327
        push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
3331
3328
                     thd->main_da.sql_errno(), thd->main_da.message());
3332
3329
      thd->clear_error();
3333
3330
      res= 0;
3336
3333
  }
3337
3334
  else
3338
3335
  {
3339
 
    Table *show_table= tables->table;
 
3336
    TABLE *show_table= tables->table;
3340
3337
    KEY *key_info=show_table->s->key_info;
3341
3338
    if (show_table->file)
3342
3339
      show_table->file->info(HA_STATUS_VARIABLE |
3343
3340
                             HA_STATUS_NO_LOCK |
3344
3341
                             HA_STATUS_TIME);
3345
 
    for (uint32_t i=0 ; i < show_table->s->keys ; i++,key_info++)
 
3342
    for (uint i=0 ; i < show_table->s->keys ; i++,key_info++)
3346
3343
    {
3347
3344
      KEY_PART_INFO *key_part= key_info->key_part;
3348
3345
      const char *str;
3349
 
      for (uint32_t j=0 ; j < key_info->key_parts ; j++,key_part++)
 
3346
      for (uint j=0 ; j < key_info->key_parts ; j++,key_part++)
3350
3347
      {
3351
3348
        restore_record(table, s->default_values);
3352
3349
        table->field[1]->store(db_name->str, db_name->length, cs);
3387
3384
                                  key_part->field->charset()->mbmaxlen, true);
3388
3385
          table->field[10]->set_notnull();
3389
3386
        }
3390
 
        uint32_t flags= key_part->field ? key_part->field->flags : 0;
 
3387
        uint flags= key_part->field ? key_part->field->flags : 0;
3391
3388
        const char *pos=(char*) ((flags & NOT_NULL_FLAG) ? "" : "YES");
3392
3389
        table->field[12]->store(pos, strlen(pos), cs);
3393
3390
        if (!show_table->s->keys_in_use.is_set(i))
3409
3406
}
3410
3407
 
3411
3408
 
3412
 
bool store_constraints(THD *thd, Table *table, LEX_STRING *db_name,
 
3409
bool store_constraints(THD *thd, TABLE *table, LEX_STRING *db_name,
3413
3410
                       LEX_STRING *table_name, const char *key_name,
3414
 
                       uint32_t key_len, const char *con_type, uint32_t con_len)
 
3411
                       uint key_len, const char *con_type, uint con_len)
3415
3412
{
3416
 
  const CHARSET_INFO * const cs= system_charset_info;
 
3413
  CHARSET_INFO *cs= system_charset_info;
3417
3414
  restore_record(table, s->default_values);
3418
3415
  table->field[1]->store(db_name->str, db_name->length, cs);
3419
3416
  table->field[2]->store(key_name, key_len, cs);
3424
3421
}
3425
3422
 
3426
3423
 
3427
 
static int get_schema_constraints_record(THD *thd, TableList *tables,
3428
 
                                         Table *table, bool res,
 
3424
static int get_schema_constraints_record(THD *thd, TABLE_LIST *tables,
 
3425
                                         TABLE *table, bool res,
3429
3426
                                         LEX_STRING *db_name,
3430
3427
                                         LEX_STRING *table_name)
3431
3428
{
3432
3429
  if (res)
3433
3430
  {
3434
3431
    if (thd->is_error())
3435
 
      push_warning(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
3432
      push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
3436
3433
                   thd->main_da.sql_errno(), thd->main_da.message());
3437
3434
    thd->clear_error();
3438
3435
    return(0);
3440
3437
  else
3441
3438
  {
3442
3439
    List<FOREIGN_KEY_INFO> f_key_list;
3443
 
    Table *show_table= tables->table;
 
3440
    TABLE *show_table= tables->table;
3444
3441
    KEY *key_info=show_table->key_info;
3445
 
    uint32_t primary_key= show_table->s->primary_key;
 
3442
    uint primary_key= show_table->s->primary_key;
3446
3443
    show_table->file->info(HA_STATUS_VARIABLE | 
3447
3444
                           HA_STATUS_NO_LOCK |
3448
3445
                           HA_STATUS_TIME);
3449
 
    for (uint32_t i=0 ; i < show_table->s->keys ; i++, key_info++)
 
3446
    for (uint i=0 ; i < show_table->s->keys ; i++, key_info++)
3450
3447
    {
3451
3448
      if (i != primary_key && !(key_info->flags & HA_NOSAME))
3452
3449
        continue;
3483
3480
}
3484
3481
 
3485
3482
 
3486
 
void store_key_column_usage(Table *table, LEX_STRING *db_name,
 
3483
void store_key_column_usage(TABLE *table, LEX_STRING *db_name,
3487
3484
                            LEX_STRING *table_name, const char *key_name,
3488
 
                            uint32_t key_len, const char *con_type, uint32_t con_len,
 
3485
                            uint key_len, const char *con_type, uint con_len,
3489
3486
                            int64_t idx)
3490
3487
{
3491
 
  const CHARSET_INFO * const cs= system_charset_info;
 
3488
  CHARSET_INFO *cs= system_charset_info;
3492
3489
  table->field[1]->store(db_name->str, db_name->length, cs);
3493
3490
  table->field[2]->store(key_name, key_len, cs);
3494
3491
  table->field[4]->store(db_name->str, db_name->length, cs);
3499
3496
 
3500
3497
 
3501
3498
static int get_schema_key_column_usage_record(THD *thd,
3502
 
                                              TableList *tables,
3503
 
                                              Table *table, bool res,
 
3499
                                              TABLE_LIST *tables,
 
3500
                                              TABLE *table, bool res,
3504
3501
                                              LEX_STRING *db_name,
3505
3502
                                              LEX_STRING *table_name)
3506
3503
{
3507
3504
  if (res)
3508
3505
  {
3509
3506
    if (thd->is_error())
3510
 
      push_warning(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
3507
      push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
3511
3508
                   thd->main_da.sql_errno(), thd->main_da.message());
3512
3509
    thd->clear_error();
3513
3510
    return(0);
3515
3512
  else
3516
3513
  {
3517
3514
    List<FOREIGN_KEY_INFO> f_key_list;
3518
 
    Table *show_table= tables->table;
 
3515
    TABLE *show_table= tables->table;
3519
3516
    KEY *key_info=show_table->key_info;
3520
 
    uint32_t primary_key= show_table->s->primary_key;
 
3517
    uint primary_key= show_table->s->primary_key;
3521
3518
    show_table->file->info(HA_STATUS_VARIABLE | 
3522
3519
                           HA_STATUS_NO_LOCK |
3523
3520
                           HA_STATUS_TIME);
3524
 
    for (uint32_t i=0 ; i < show_table->s->keys ; i++, key_info++)
 
3521
    for (uint i=0 ; i < show_table->s->keys ; i++, key_info++)
3525
3522
    {
3526
3523
      if (i != primary_key && !(key_info->flags & HA_NOSAME))
3527
3524
        continue;
3528
 
      uint32_t f_idx= 0;
 
3525
      uint f_idx= 0;
3529
3526
      KEY_PART_INFO *key_part= key_info->key_part;
3530
 
      for (uint32_t j=0 ; j < key_info->key_parts ; j++,key_part++)
 
3527
      for (uint j=0 ; j < key_info->key_parts ; j++,key_part++)
3531
3528
      {
3532
3529
        if (key_part->field)
3533
3530
        {
3554
3551
      LEX_STRING *r_info;
3555
3552
      List_iterator_fast<LEX_STRING> it(f_key_info->foreign_fields),
3556
3553
        it1(f_key_info->referenced_fields);
3557
 
      uint32_t f_idx= 0;
 
3554
      uint f_idx= 0;
3558
3555
      while ((f_info= it++))
3559
3556
      {
3560
3557
        r_info= it1++;
3587
3584
}
3588
3585
 
3589
3586
 
3590
 
int fill_open_tables(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
 
3587
int fill_open_tables(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((__unused__)))
3591
3588
{
3592
 
  const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NULL;
3593
 
  Table *table= tables->table;
3594
 
  const CHARSET_INFO * const cs= system_charset_info;
3595
 
  OPEN_TableList *open_list;
 
3589
  const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
 
3590
  TABLE *table= tables->table;
 
3591
  CHARSET_INFO *cs= system_charset_info;
 
3592
  OPEN_TABLE_LIST *open_list;
3596
3593
  if (!(open_list=list_open_tables(thd,thd->lex->select_lex.db, wild))
3597
3594
            && thd->is_fatal_error)
3598
3595
    return(1);
3611
3608
}
3612
3609
 
3613
3610
 
3614
 
int fill_variables(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
 
3611
int fill_variables(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((__unused__)))
3615
3612
{
3616
3613
  int res= 0;
3617
3614
  LEX *lex= thd->lex;
3618
 
  const char *wild= lex->wild ? lex->wild->ptr() : NULL;
 
3615
  const char *wild= lex->wild ? lex->wild->ptr() : NullS;
3619
3616
  enum enum_schema_tables schema_table_idx=
3620
3617
    get_schema_table_idx(tables->schema_table);
3621
3618
  enum enum_var_type option_type= OPT_SESSION;
3634
3631
}
3635
3632
 
3636
3633
 
3637
 
int fill_status(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
 
3634
int fill_status(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((__unused__)))
3638
3635
{
3639
3636
  LEX *lex= thd->lex;
3640
 
  const char *wild= lex->wild ? lex->wild->ptr() : NULL;
 
3637
  const char *wild= lex->wild ? lex->wild->ptr() : NullS;
3641
3638
  int res= 0;
3642
3639
  STATUS_VAR *tmp1, tmp;
3643
3640
  enum enum_schema_tables schema_table_idx=
3695
3692
*/
3696
3693
 
3697
3694
static int
3698
 
get_referential_constraints_record(THD *thd, TableList *tables,
3699
 
                                   Table *table, bool res,
 
3695
get_referential_constraints_record(THD *thd, TABLE_LIST *tables,
 
3696
                                   TABLE *table, bool res,
3700
3697
                                   LEX_STRING *db_name, LEX_STRING *table_name)
3701
3698
{
3702
 
  const CHARSET_INFO * const cs= system_charset_info;
 
3699
  CHARSET_INFO *cs= system_charset_info;
3703
3700
 
3704
3701
  if (res)
3705
3702
  {
3706
3703
    if (thd->is_error())
3707
 
      push_warning(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
3704
      push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
3708
3705
                   thd->main_da.sql_errno(), thd->main_da.message());
3709
3706
    thd->clear_error();
3710
3707
    return(0);
3712
3709
 
3713
3710
  {
3714
3711
    List<FOREIGN_KEY_INFO> f_key_list;
3715
 
    Table *show_table= tables->table;
 
3712
    TABLE *show_table= tables->table;
3716
3713
    show_table->file->info(HA_STATUS_VARIABLE | 
3717
3714
                           HA_STATUS_NO_LOCK |
3718
3715
                           HA_STATUS_TIME);
3772
3769
    0   table not found
3773
3770
    1   found the schema table
3774
3771
*/
3775
 
static bool find_schema_table_in_plugin(THD *thd __attribute__((unused)),
 
3772
static bool find_schema_table_in_plugin(THD *thd __attribute__((__unused__)),
3776
3773
                                           plugin_ref plugin,
3777
3774
                                           void* p_table)
3778
3775
{
3819
3816
 
3820
3817
  schema_table_a.table_name= table_name;
3821
3818
  if (plugin_foreach(thd, find_schema_table_in_plugin, 
3822
 
                     DRIZZLE_INFORMATION_SCHEMA_PLUGIN, &schema_table_a))
 
3819
                     MYSQL_INFORMATION_SCHEMA_PLUGIN, &schema_table_a))
3823
3820
    return(schema_table_a.schema_table);
3824
3821
 
3825
3822
  return(NULL);
3847
3844
  @retval  NULL           Can't create table
3848
3845
*/
3849
3846
 
3850
 
Table *create_schema_table(THD *thd, TableList *table_list)
 
3847
TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
3851
3848
{
3852
3849
  int field_count= 0;
3853
3850
  Item *item;
3854
 
  Table *table;
 
3851
  TABLE *table;
3855
3852
  List<Item> field_list;
3856
3853
  ST_SCHEMA_TABLE *schema_table= table_list->schema_table;
3857
3854
  ST_FIELD_INFO *fields_info= schema_table->fields_info;
3858
 
  const CHARSET_INFO * const cs= system_charset_info;
 
3855
  CHARSET_INFO *cs= system_charset_info;
3859
3856
 
3860
3857
  for (; fields_info->field_name; fields_info++)
3861
3858
  {
3862
3859
    switch (fields_info->field_type) {
3863
 
    case DRIZZLE_TYPE_TINY:
3864
 
    case DRIZZLE_TYPE_LONG:
3865
 
    case DRIZZLE_TYPE_LONGLONG:
 
3860
    case MYSQL_TYPE_TINY:
 
3861
    case MYSQL_TYPE_LONG:
 
3862
    case MYSQL_TYPE_SHORT:
 
3863
    case MYSQL_TYPE_LONGLONG:
3866
3864
      if (!(item= new Item_return_int(fields_info->field_name,
3867
3865
                                      fields_info->field_length,
3868
3866
                                      fields_info->field_type,
3872
3870
      }
3873
3871
      item->unsigned_flag= (fields_info->field_flags & MY_I_S_UNSIGNED);
3874
3872
      break;
3875
 
    case DRIZZLE_TYPE_NEWDATE:
3876
 
    case DRIZZLE_TYPE_TIME:
3877
 
    case DRIZZLE_TYPE_TIMESTAMP:
3878
 
    case DRIZZLE_TYPE_DATETIME:
 
3873
    case MYSQL_TYPE_NEWDATE:
 
3874
    case MYSQL_TYPE_TIME:
 
3875
    case MYSQL_TYPE_TIMESTAMP:
 
3876
    case MYSQL_TYPE_DATETIME:
3879
3877
      if (!(item=new Item_return_date_time(fields_info->field_name,
3880
3878
                                           fields_info->field_type)))
3881
3879
      {
3882
3880
        return(0);
3883
3881
      }
3884
3882
      break;
3885
 
    case DRIZZLE_TYPE_DOUBLE:
 
3883
    case MYSQL_TYPE_DOUBLE:
3886
3884
      if ((item= new Item_float(fields_info->field_name, 0.0, NOT_FIXED_DEC, 
3887
3885
                           fields_info->field_length)) == NULL)
3888
3886
        return(NULL);
3889
3887
      break;
3890
 
    case DRIZZLE_TYPE_NEWDECIMAL:
 
3888
    case MYSQL_TYPE_NEWDECIMAL:
3891
3889
      if (!(item= new Item_decimal((int64_t) fields_info->value, false)))
3892
3890
      {
3893
3891
        return(0);
3902
3900
      item->set_name(fields_info->field_name,
3903
3901
                     strlen(fields_info->field_name), cs);
3904
3902
      break;
3905
 
    case DRIZZLE_TYPE_BLOB:
 
3903
    case MYSQL_TYPE_BLOB:
3906
3904
      if (!(item= new Item_blob(fields_info->field_name,
3907
3905
                                fields_info->field_length)))
3908
3906
      {
3910
3908
      }
3911
3909
      break;
3912
3910
    default:
 
3911
      /* Don't let unimplemented types pass through. Could be a grave error. */
 
3912
      assert(fields_info->field_type == MYSQL_TYPE_STRING);
 
3913
 
3913
3914
      if (!(item= new Item_empty_string("", fields_info->field_length, cs)))
3914
3915
      {
3915
3916
        return(0);
3930
3931
  tmp_table_param->schema_table= 1;
3931
3932
  SELECT_LEX *select_lex= thd->lex->current_select;
3932
3933
  if (!(table= create_tmp_table(thd, tmp_table_param,
3933
 
                                field_list, (order_st*) 0, 0, 0, 
 
3934
                                field_list, (ORDER*) 0, 0, 0, 
3934
3935
                                (select_lex->options | thd->options |
3935
3936
                                 TMP_TABLE_ALL_COLUMNS),
3936
3937
                                HA_POS_ERROR, table_list->alias)))
3970
3971
    if (field_info->old_name)
3971
3972
    {
3972
3973
      Item_field *field= new Item_field(context,
3973
 
                                        NULL, NULL, field_info->field_name);
 
3974
                                        NullS, NullS, field_info->field_name);
3974
3975
      if (field)
3975
3976
      {
3976
3977
        field->set_name(field_info->old_name,
3997
3998
    ST_FIELD_INFO *field_info= &schema_table->fields_info[1];
3998
3999
    String buffer(tmp,sizeof(tmp), system_charset_info);
3999
4000
    Item_field *field= new Item_field(context,
4000
 
                                      NULL, NULL, field_info->field_name);
 
4001
                                      NullS, NullS, field_info->field_name);
4001
4002
    if (!field || add_item_to_list(thd, field))
4002
4003
      return 1;
4003
4004
    buffer.length(0);
4032
4033
    buffer.append(')');
4033
4034
  }
4034
4035
  Item_field *field= new Item_field(context,
4035
 
                                    NULL, NULL, field_info->field_name);
 
4036
                                    NullS, NullS, field_info->field_name);
4036
4037
  if (add_item_to_list(thd, field))
4037
4038
    return 1;
4038
4039
  field->set_name(buffer.ptr(), buffer.length(), system_charset_info);
4040
4041
  {
4041
4042
    field->set_name(buffer.ptr(), buffer.length(), system_charset_info);
4042
4043
    field_info= &schema_table->fields_info[3];
4043
 
    field= new Item_field(context, NULL, NULL, field_info->field_name);
 
4044
    field= new Item_field(context, NullS, NullS, field_info->field_name);
4044
4045
    if (add_item_to_list(thd, field))
4045
4046
      return 1;
4046
4047
    field->set_name(field_info->old_name, strlen(field_info->old_name),
4065
4066
                               *field_num == 18))
4066
4067
      continue;
4067
4068
    Item_field *field= new Item_field(context,
4068
 
                                      NULL, NULL, field_info->field_name);
 
4069
                                      NullS, NullS, field_info->field_name);
4069
4070
    if (field)
4070
4071
    {
4071
4072
      field->set_name(field_info->old_name,
4090
4091
  {
4091
4092
    field_info= &schema_table->fields_info[*field_num];
4092
4093
    Item_field *field= new Item_field(context,
4093
 
                                      NULL, NULL, field_info->field_name);
 
4094
                                      NullS, NullS, field_info->field_name);
4094
4095
    if (field)
4095
4096
    {
4096
4097
      field->set_name(field_info->old_name,
4118
4119
    1   error
4119
4120
*/
4120
4121
 
4121
 
int mysql_schema_table(THD *thd, LEX *lex, TableList *table_list)
 
4122
int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list)
4122
4123
{
4123
 
  Table *table;
 
4124
  TABLE *table;
4124
4125
  if (!(table= table_list->schema_table->create_table(thd, table_list)))
4125
4126
    return(1);
4126
4127
  table->s->tmp_table= SYSTEM_TMP_TABLE;
4161
4162
    }
4162
4163
    List_iterator_fast<Item> it(sel->item_list);
4163
4164
    if (!(transl=
4164
 
          (Field_translator*)(thd->alloc(sel->item_list.elements *
 
4165
          (Field_translator*)(thd->stmt_arena->
 
4166
                              alloc(sel->item_list.elements *
4165
4167
                                    sizeof(Field_translator)))))
4166
4168
    {
4167
4169
      return(1);
4247
4249
    if (!tab->table || !tab->table->pos_in_table_list)
4248
4250
      break;
4249
4251
 
4250
 
    TableList *table_list= tab->table->pos_in_table_list;
 
4252
    TABLE_LIST *table_list= tab->table->pos_in_table_list;
4251
4253
    if (table_list->schema_table)
4252
4254
    {
4253
4255
      bool is_subselect= (&lex->unit != lex->current_select->master_unit() &&
4308
4310
 
4309
4311
ST_FIELD_INFO schema_fields_info[]=
4310
4312
{
4311
 
  {"CATALOG_NAME", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, SKIP_OPEN_TABLE},
4312
 
  {"SCHEMA_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Database",
4313
 
   SKIP_OPEN_TABLE},
4314
 
  {"DEFAULT_CHARACTER_SET_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4315
 
   SKIP_OPEN_TABLE},
4316
 
  {"DEFAULT_COLLATION_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE},
4317
 
  {"SQL_PATH", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, SKIP_OPEN_TABLE},
4318
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4313
  {"CATALOG_NAME", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
 
4314
  {"SCHEMA_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Database",
 
4315
   SKIP_OPEN_TABLE},
 
4316
  {"DEFAULT_CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 0, 0,
 
4317
   SKIP_OPEN_TABLE},
 
4318
  {"DEFAULT_COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4319
  {"SQL_PATH", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
 
4320
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4319
4321
};
4320
4322
 
4321
4323
 
4322
4324
ST_FIELD_INFO tables_fields_info[]=
4323
4325
{
4324
 
  {"TABLE_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, SKIP_OPEN_TABLE},
4325
 
  {"TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE},
4326
 
  {"TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Name",
 
4326
  {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
 
4327
  {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4328
  {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Name",
4327
4329
   SKIP_OPEN_TABLE},
4328
 
  {"TABLE_TYPE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FRM_ONLY},
4329
 
  {"ENGINE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, "Engine", OPEN_FRM_ONLY},
4330
 
  {"VERSION", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
 
4330
  {"TABLE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
 
4331
  {"ENGINE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, "Engine", OPEN_FRM_ONLY},
 
4332
  {"VERSION", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
4331
4333
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Version", OPEN_FRM_ONLY},
4332
 
  {"ROW_FORMAT", 10, DRIZZLE_TYPE_VARCHAR, 0, 1, "Row_format", OPEN_FULL_TABLE},
4333
 
  {"TABLE_ROWS", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
 
4334
  {"ROW_FORMAT", 10, MYSQL_TYPE_STRING, 0, 1, "Row_format", OPEN_FULL_TABLE},
 
4335
  {"TABLE_ROWS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
4334
4336
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Rows", OPEN_FULL_TABLE},
4335
 
  {"AVG_ROW_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0, 
 
4337
  {"AVG_ROW_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 
4336
4338
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Avg_row_length", OPEN_FULL_TABLE},
4337
 
  {"DATA_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0, 
 
4339
  {"DATA_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 
4338
4340
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Data_length", OPEN_FULL_TABLE},
4339
 
  {"MAX_DATA_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
 
4341
  {"MAX_DATA_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
4340
4342
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Max_data_length", OPEN_FULL_TABLE},
4341
 
  {"INDEX_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0, 
 
4343
  {"INDEX_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 
4342
4344
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Index_length", OPEN_FULL_TABLE},
4343
 
  {"DATA_FREE", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
 
4345
  {"DATA_FREE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
4344
4346
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Data_free", OPEN_FULL_TABLE},
4345
 
  {"AUTO_INCREMENT", MY_INT64_NUM_DECIMAL_DIGITS , DRIZZLE_TYPE_LONGLONG, 0, 
 
4347
  {"AUTO_INCREMENT", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONGLONG, 0, 
4346
4348
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Auto_increment", OPEN_FULL_TABLE},
4347
 
  {"CREATE_TIME", 0, DRIZZLE_TYPE_DATETIME, 0, 1, "Create_time", OPEN_FULL_TABLE},
4348
 
  {"UPDATE_TIME", 0, DRIZZLE_TYPE_DATETIME, 0, 1, "Update_time", OPEN_FULL_TABLE},
4349
 
  {"CHECK_TIME", 0, DRIZZLE_TYPE_DATETIME, 0, 1, "Check_time", OPEN_FULL_TABLE},
4350
 
  {"TABLE_COLLATION", 64, DRIZZLE_TYPE_VARCHAR, 0, 1, "Collation", OPEN_FRM_ONLY},
4351
 
  {"CHECKSUM", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
 
4349
  {"CREATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, "Create_time", OPEN_FULL_TABLE},
 
4350
  {"UPDATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, "Update_time", OPEN_FULL_TABLE},
 
4351
  {"CHECK_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, "Check_time", OPEN_FULL_TABLE},
 
4352
  {"TABLE_COLLATION", 64, MYSQL_TYPE_STRING, 0, 1, "Collation", OPEN_FRM_ONLY},
 
4353
  {"CHECKSUM", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
4352
4354
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Checksum", OPEN_FULL_TABLE},
4353
 
  {"CREATE_OPTIONS", 255, DRIZZLE_TYPE_VARCHAR, 0, 1, "Create_options",
 
4355
  {"CREATE_OPTIONS", 255, MYSQL_TYPE_STRING, 0, 1, "Create_options",
4354
4356
   OPEN_FRM_ONLY},
4355
 
  {"TABLE_COMMENT", TABLE_COMMENT_MAXLEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Comment", OPEN_FRM_ONLY},
4356
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4357
  {"TABLE_COMMENT", TABLE_COMMENT_MAXLEN, MYSQL_TYPE_STRING, 0, 0, "Comment", OPEN_FRM_ONLY},
 
4358
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4357
4359
};
4358
4360
 
4359
4361
 
4360
4362
ST_FIELD_INFO columns_fields_info[]=
4361
4363
{
4362
 
  {"TABLE_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, OPEN_FRM_ONLY},
4363
 
  {"TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FRM_ONLY},
4364
 
  {"TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FRM_ONLY},
4365
 
  {"COLUMN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Field",
 
4364
  {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FRM_ONLY},
 
4365
  {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
 
4366
  {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
 
4367
  {"COLUMN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Field",
4366
4368
   OPEN_FRM_ONLY},
4367
 
  {"ORDINAL_POSITION", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
 
4369
  {"ORDINAL_POSITION", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
4368
4370
   MY_I_S_UNSIGNED, 0, OPEN_FRM_ONLY},
4369
 
  {"COLUMN_DEFAULT", MAX_FIELD_VARCHARLENGTH, DRIZZLE_TYPE_VARCHAR, 0,
 
4371
  {"COLUMN_DEFAULT", MAX_FIELD_VARCHARLENGTH, MYSQL_TYPE_STRING, 0,
4370
4372
   1, "Default", OPEN_FRM_ONLY},
4371
 
  {"IS_NULLABLE", 3, DRIZZLE_TYPE_VARCHAR, 0, 0, "Null", OPEN_FRM_ONLY},
4372
 
  {"DATA_TYPE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FRM_ONLY},
4373
 
  {"CHARACTER_MAXIMUM_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG,
4374
 
   0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
4375
 
  {"CHARACTER_OCTET_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS , DRIZZLE_TYPE_LONGLONG,
4376
 
   0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
4377
 
  {"NUMERIC_PRECISION", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG,
4378
 
   0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
4379
 
  {"NUMERIC_SCALE", MY_INT64_NUM_DECIMAL_DIGITS , DRIZZLE_TYPE_LONGLONG,
4380
 
   0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
4381
 
  {"CHARACTER_SET_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, OPEN_FRM_ONLY},
4382
 
  {"COLLATION_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 1, "Collation", OPEN_FRM_ONLY},
4383
 
  {"COLUMN_TYPE", 65535, DRIZZLE_TYPE_VARCHAR, 0, 0, "Type", OPEN_FRM_ONLY},
4384
 
  {"COLUMN_KEY", 3, DRIZZLE_TYPE_VARCHAR, 0, 0, "Key", OPEN_FRM_ONLY},
4385
 
  {"EXTRA", 27, DRIZZLE_TYPE_VARCHAR, 0, 0, "Extra", OPEN_FRM_ONLY},
4386
 
  {"PRIVILEGES", 80, DRIZZLE_TYPE_VARCHAR, 0, 0, "Privileges", OPEN_FRM_ONLY},
4387
 
  {"COLUMN_COMMENT", COLUMN_COMMENT_MAXLEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Comment", OPEN_FRM_ONLY},
4388
 
  {"STORAGE", 8, DRIZZLE_TYPE_VARCHAR, 0, 0, "Storage", OPEN_FRM_ONLY},
4389
 
  {"FORMAT", 8, DRIZZLE_TYPE_VARCHAR, 0, 0, "Format", OPEN_FRM_ONLY},
4390
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4373
  {"IS_NULLABLE", 3, MYSQL_TYPE_STRING, 0, 0, "Null", OPEN_FRM_ONLY},
 
4374
  {"DATA_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
 
4375
  {"CHARACTER_MAXIMUM_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG,
 
4376
   0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
 
4377
  {"CHARACTER_OCTET_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONGLONG,
 
4378
   0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
 
4379
  {"NUMERIC_PRECISION", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG,
 
4380
   0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
 
4381
  {"NUMERIC_SCALE", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONGLONG,
 
4382
   0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
 
4383
  {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FRM_ONLY},
 
4384
  {"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 1, "Collation", OPEN_FRM_ONLY},
 
4385
  {"COLUMN_TYPE", 65535, MYSQL_TYPE_STRING, 0, 0, "Type", OPEN_FRM_ONLY},
 
4386
  {"COLUMN_KEY", 3, MYSQL_TYPE_STRING, 0, 0, "Key", OPEN_FRM_ONLY},
 
4387
  {"EXTRA", 27, MYSQL_TYPE_STRING, 0, 0, "Extra", OPEN_FRM_ONLY},
 
4388
  {"PRIVILEGES", 80, MYSQL_TYPE_STRING, 0, 0, "Privileges", OPEN_FRM_ONLY},
 
4389
  {"COLUMN_COMMENT", COLUMN_COMMENT_MAXLEN, MYSQL_TYPE_STRING, 0, 0, "Comment", OPEN_FRM_ONLY},
 
4390
  {"STORAGE", 8, MYSQL_TYPE_STRING, 0, 0, "Storage", OPEN_FRM_ONLY},
 
4391
  {"FORMAT", 8, MYSQL_TYPE_STRING, 0, 0, "Format", OPEN_FRM_ONLY},
 
4392
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4391
4393
};
4392
4394
 
4393
4395
 
4394
4396
ST_FIELD_INFO charsets_fields_info[]=
4395
4397
{
4396
 
  {"CHARACTER_SET_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, "Charset",
4397
 
   SKIP_OPEN_TABLE},
4398
 
  {"DEFAULT_COLLATE_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, "Default collation",
4399
 
   SKIP_OPEN_TABLE},
4400
 
  {"DESCRIPTION", 60, DRIZZLE_TYPE_VARCHAR, 0, 0, "Description",
4401
 
   SKIP_OPEN_TABLE},
4402
 
  {"MAXLEN", 3, DRIZZLE_TYPE_LONGLONG, 0, 0, "Maxlen", SKIP_OPEN_TABLE},
4403
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4398
  {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Charset",
 
4399
   SKIP_OPEN_TABLE},
 
4400
  {"DEFAULT_COLLATE_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Default collation",
 
4401
   SKIP_OPEN_TABLE},
 
4402
  {"DESCRIPTION", 60, MYSQL_TYPE_STRING, 0, 0, "Description",
 
4403
   SKIP_OPEN_TABLE},
 
4404
  {"MAXLEN", 3, MYSQL_TYPE_LONGLONG, 0, 0, "Maxlen", SKIP_OPEN_TABLE},
 
4405
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4404
4406
};
4405
4407
 
4406
4408
 
4407
4409
ST_FIELD_INFO collation_fields_info[]=
4408
4410
{
4409
 
  {"COLLATION_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, "Collation", SKIP_OPEN_TABLE},
4410
 
  {"CHARACTER_SET_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, "Charset",
4411
 
   SKIP_OPEN_TABLE},
4412
 
  {"ID", MY_INT32_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0, 0, "Id",
4413
 
   SKIP_OPEN_TABLE},
4414
 
  {"IS_DEFAULT", 3, DRIZZLE_TYPE_VARCHAR, 0, 0, "Default", SKIP_OPEN_TABLE},
4415
 
  {"IS_COMPILED", 3, DRIZZLE_TYPE_VARCHAR, 0, 0, "Compiled", SKIP_OPEN_TABLE},
4416
 
  {"SORTLEN", 3, DRIZZLE_TYPE_LONGLONG, 0, 0, "Sortlen", SKIP_OPEN_TABLE},
4417
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4411
  {"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Collation", SKIP_OPEN_TABLE},
 
4412
  {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Charset",
 
4413
   SKIP_OPEN_TABLE},
 
4414
  {"ID", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Id",
 
4415
   SKIP_OPEN_TABLE},
 
4416
  {"IS_DEFAULT", 3, MYSQL_TYPE_STRING, 0, 0, "Default", SKIP_OPEN_TABLE},
 
4417
  {"IS_COMPILED", 3, MYSQL_TYPE_STRING, 0, 0, "Compiled", SKIP_OPEN_TABLE},
 
4418
  {"SORTLEN", 3, MYSQL_TYPE_LONGLONG, 0, 0, "Sortlen", SKIP_OPEN_TABLE},
 
4419
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
 
4420
};
 
4421
 
 
4422
 
 
4423
ST_FIELD_INFO events_fields_info[]=
 
4424
{
 
4425
  {"EVENT_CATALOG", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
 
4426
  {"EVENT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Db",
 
4427
   SKIP_OPEN_TABLE},
 
4428
  {"EVENT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Name",
 
4429
   SKIP_OPEN_TABLE},
 
4430
  {"DEFINER", 77, MYSQL_TYPE_STRING, 0, 0, "Definer", SKIP_OPEN_TABLE},
 
4431
  {"TIME_ZONE", 64, MYSQL_TYPE_STRING, 0, 0, "Time zone", SKIP_OPEN_TABLE},
 
4432
  {"EVENT_BODY", 8, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4433
  {"EVENT_DEFINITION", 65535, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4434
  {"EVENT_TYPE", 9, MYSQL_TYPE_STRING, 0, 0, "Type", SKIP_OPEN_TABLE},
 
4435
  {"EXECUTE_AT", 0, MYSQL_TYPE_DATETIME, 0, 1, "Execute at", SKIP_OPEN_TABLE},
 
4436
  {"INTERVAL_VALUE", 256, MYSQL_TYPE_STRING, 0, 1, "Interval value",
 
4437
   SKIP_OPEN_TABLE},
 
4438
  {"INTERVAL_FIELD", 18, MYSQL_TYPE_STRING, 0, 1, "Interval field",
 
4439
   SKIP_OPEN_TABLE},
 
4440
  {"SQL_MODE", 65535, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4441
  {"STARTS", 0, MYSQL_TYPE_DATETIME, 0, 1, "Starts", SKIP_OPEN_TABLE},
 
4442
  {"ENDS", 0, MYSQL_TYPE_DATETIME, 0, 1, "Ends", SKIP_OPEN_TABLE},
 
4443
  {"STATUS", 18, MYSQL_TYPE_STRING, 0, 0, "Status", SKIP_OPEN_TABLE},
 
4444
  {"ON_COMPLETION", 12, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4445
  {"CREATED", 0, MYSQL_TYPE_DATETIME, 0, 0, 0, SKIP_OPEN_TABLE},
 
4446
  {"LAST_ALTERED", 0, MYSQL_TYPE_DATETIME, 0, 0, 0, SKIP_OPEN_TABLE},
 
4447
  {"LAST_EXECUTED", 0, MYSQL_TYPE_DATETIME, 0, 1, 0, SKIP_OPEN_TABLE},
 
4448
  {"EVENT_COMMENT", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4449
  {"ORIGINATOR", 10, MYSQL_TYPE_LONGLONG, 0, 0, "Originator", SKIP_OPEN_TABLE},
 
4450
  {"CHARACTER_SET_CLIENT", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
 
4451
   "character_set_client", SKIP_OPEN_TABLE},
 
4452
  {"COLLATION_CONNECTION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
 
4453
   "collation_connection", SKIP_OPEN_TABLE},
 
4454
  {"DATABASE_COLLATION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
 
4455
   "Database Collation", SKIP_OPEN_TABLE},
 
4456
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4418
4457
};
4419
4458
 
4420
4459
 
4421
4460
 
4422
4461
ST_FIELD_INFO coll_charset_app_fields_info[]=
4423
4462
{
4424
 
  {"COLLATION_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE},
4425
 
  {"CHARACTER_SET_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE},
4426
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4463
  {"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4464
  {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4465
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4427
4466
};
4428
4467
 
4429
4468
 
4430
4469
ST_FIELD_INFO stat_fields_info[]=
4431
4470
{
4432
 
  {"TABLE_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, OPEN_FRM_ONLY},
4433
 
  {"TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FRM_ONLY},
4434
 
  {"TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Table", OPEN_FRM_ONLY},
4435
 
  {"NON_UNIQUE", 1, DRIZZLE_TYPE_LONGLONG, 0, 0, "Non_unique", OPEN_FRM_ONLY},
4436
 
  {"INDEX_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FRM_ONLY},
4437
 
  {"INDEX_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Key_name",
4438
 
   OPEN_FRM_ONLY},
4439
 
  {"SEQ_IN_INDEX", 2, DRIZZLE_TYPE_LONGLONG, 0, 0, "Seq_in_index", OPEN_FRM_ONLY},
4440
 
  {"COLUMN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Column_name",
4441
 
   OPEN_FRM_ONLY},
4442
 
  {"COLLATION", 1, DRIZZLE_TYPE_VARCHAR, 0, 1, "Collation", OPEN_FRM_ONLY},
4443
 
  {"CARDINALITY", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0, 1,
 
4471
  {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FRM_ONLY},
 
4472
  {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
 
4473
  {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Table", OPEN_FRM_ONLY},
 
4474
  {"NON_UNIQUE", 1, MYSQL_TYPE_LONGLONG, 0, 0, "Non_unique", OPEN_FRM_ONLY},
 
4475
  {"INDEX_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
 
4476
  {"INDEX_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Key_name",
 
4477
   OPEN_FRM_ONLY},
 
4478
  {"SEQ_IN_INDEX", 2, MYSQL_TYPE_LONGLONG, 0, 0, "Seq_in_index", OPEN_FRM_ONLY},
 
4479
  {"COLUMN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Column_name",
 
4480
   OPEN_FRM_ONLY},
 
4481
  {"COLLATION", 1, MYSQL_TYPE_STRING, 0, 1, "Collation", OPEN_FRM_ONLY},
 
4482
  {"CARDINALITY", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 1,
4444
4483
   "Cardinality", OPEN_FULL_TABLE},
4445
 
  {"SUB_PART", 3, DRIZZLE_TYPE_LONGLONG, 0, 1, "Sub_part", OPEN_FRM_ONLY},
4446
 
  {"PACKED", 10, DRIZZLE_TYPE_VARCHAR, 0, 1, "Packed", OPEN_FRM_ONLY},
4447
 
  {"NULLABLE", 3, DRIZZLE_TYPE_VARCHAR, 0, 0, "Null", OPEN_FRM_ONLY},
4448
 
  {"INDEX_TYPE", 16, DRIZZLE_TYPE_VARCHAR, 0, 0, "Index_type", OPEN_FULL_TABLE},
4449
 
  {"COMMENT", 16, DRIZZLE_TYPE_VARCHAR, 0, 1, "Comment", OPEN_FRM_ONLY},
4450
 
  {"INDEX_COMMENT", INDEX_COMMENT_MAXLEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Index_Comment", OPEN_FRM_ONLY},
4451
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4484
  {"SUB_PART", 3, MYSQL_TYPE_LONGLONG, 0, 1, "Sub_part", OPEN_FRM_ONLY},
 
4485
  {"PACKED", 10, MYSQL_TYPE_STRING, 0, 1, "Packed", OPEN_FRM_ONLY},
 
4486
  {"NULLABLE", 3, MYSQL_TYPE_STRING, 0, 0, "Null", OPEN_FRM_ONLY},
 
4487
  {"INDEX_TYPE", 16, MYSQL_TYPE_STRING, 0, 0, "Index_type", OPEN_FULL_TABLE},
 
4488
  {"COMMENT", 16, MYSQL_TYPE_STRING, 0, 1, "Comment", OPEN_FRM_ONLY},
 
4489
  {"INDEX_COMMENT", INDEX_COMMENT_MAXLEN, MYSQL_TYPE_STRING, 0, 0, "Index_Comment", OPEN_FRM_ONLY},
 
4490
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
 
4491
};
 
4492
 
 
4493
 
 
4494
ST_FIELD_INFO user_privileges_fields_info[]=
 
4495
{
 
4496
  {"GRANTEE", 81, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4497
  {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
 
4498
  {"PRIVILEGE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4499
  {"IS_GRANTABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4500
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
 
4501
};
 
4502
 
 
4503
 
 
4504
ST_FIELD_INFO schema_privileges_fields_info[]=
 
4505
{
 
4506
  {"GRANTEE", 81, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4507
  {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
 
4508
  {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4509
  {"PRIVILEGE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4510
  {"IS_GRANTABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4511
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
 
4512
};
 
4513
 
 
4514
 
 
4515
ST_FIELD_INFO table_privileges_fields_info[]=
 
4516
{
 
4517
  {"GRANTEE", 81, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4518
  {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
 
4519
  {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4520
  {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4521
  {"PRIVILEGE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4522
  {"IS_GRANTABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4523
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
 
4524
};
 
4525
 
 
4526
 
 
4527
ST_FIELD_INFO column_privileges_fields_info[]=
 
4528
{
 
4529
  {"GRANTEE", 81, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4530
  {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
 
4531
  {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4532
  {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4533
  {"COLUMN_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}
4452
4537
};
4453
4538
 
4454
4539
 
4455
4540
ST_FIELD_INFO table_constraints_fields_info[]=
4456
4541
{
4457
 
  {"CONSTRAINT_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, OPEN_FULL_TABLE},
4458
 
  {"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4459
 
   OPEN_FULL_TABLE},
4460
 
  {"CONSTRAINT_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4461
 
   OPEN_FULL_TABLE},
4462
 
  {"TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4463
 
  {"TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4464
 
  {"CONSTRAINT_TYPE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4465
 
   OPEN_FULL_TABLE},
4466
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4542
  {"CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
 
4543
  {"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
 
4544
   OPEN_FULL_TABLE},
 
4545
  {"CONSTRAINT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
 
4546
   OPEN_FULL_TABLE},
 
4547
  {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4548
  {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4549
  {"CONSTRAINT_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
 
4550
   OPEN_FULL_TABLE},
 
4551
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4467
4552
};
4468
4553
 
4469
4554
 
4470
4555
ST_FIELD_INFO key_column_usage_fields_info[]=
4471
4556
{
4472
 
  {"CONSTRAINT_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, OPEN_FULL_TABLE},
4473
 
  {"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4474
 
   OPEN_FULL_TABLE},
4475
 
  {"CONSTRAINT_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4476
 
   OPEN_FULL_TABLE},
4477
 
  {"TABLE_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, OPEN_FULL_TABLE},
4478
 
  {"TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4479
 
  {"TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4480
 
  {"COLUMN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4481
 
  {"ORDINAL_POSITION", 10 ,DRIZZLE_TYPE_LONGLONG, 0, 0, 0, OPEN_FULL_TABLE},
4482
 
  {"POSITION_IN_UNIQUE_CONSTRAINT", 10 ,DRIZZLE_TYPE_LONGLONG, 0, 1, 0,
4483
 
   OPEN_FULL_TABLE},
4484
 
  {"REFERENCED_TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0,
4485
 
   OPEN_FULL_TABLE},
4486
 
  {"REFERENCED_TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0,
4487
 
   OPEN_FULL_TABLE},
4488
 
  {"REFERENCED_COLUMN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0,
4489
 
   OPEN_FULL_TABLE},
4490
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4557
  {"CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
 
4558
  {"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
 
4559
   OPEN_FULL_TABLE},
 
4560
  {"CONSTRAINT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
 
4561
   OPEN_FULL_TABLE},
 
4562
  {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
 
4563
  {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4564
  {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4565
  {"COLUMN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4566
  {"ORDINAL_POSITION", 10 ,MYSQL_TYPE_LONGLONG, 0, 0, 0, OPEN_FULL_TABLE},
 
4567
  {"POSITION_IN_UNIQUE_CONSTRAINT", 10 ,MYSQL_TYPE_LONGLONG, 0, 1, 0,
 
4568
   OPEN_FULL_TABLE},
 
4569
  {"REFERENCED_TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0,
 
4570
   OPEN_FULL_TABLE},
 
4571
  {"REFERENCED_TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0,
 
4572
   OPEN_FULL_TABLE},
 
4573
  {"REFERENCED_COLUMN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0,
 
4574
   OPEN_FULL_TABLE},
 
4575
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4491
4576
};
4492
4577
 
4493
4578
 
4494
4579
ST_FIELD_INFO table_names_fields_info[]=
4495
4580
{
4496
 
  {"TABLE_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, SKIP_OPEN_TABLE},
4497
 
  {"TABLE_SCHEMA",NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE},
4498
 
  {"TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Tables_in_",
 
4581
  {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
 
4582
  {"TABLE_SCHEMA",NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4583
  {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Tables_in_",
4499
4584
   SKIP_OPEN_TABLE},
4500
 
  {"TABLE_TYPE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Table_type",
 
4585
  {"TABLE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_type",
4501
4586
   OPEN_FRM_ONLY},
4502
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4587
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4503
4588
};
4504
4589
 
4505
4590
 
4506
4591
ST_FIELD_INFO open_tables_fields_info[]=
4507
4592
{
4508
 
  {"Database", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Database",
 
4593
  {"Database", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Database",
4509
4594
   SKIP_OPEN_TABLE},
4510
 
  {"Table",NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Table", SKIP_OPEN_TABLE},
4511
 
  {"In_use", 1, DRIZZLE_TYPE_LONGLONG, 0, 0, "In_use", SKIP_OPEN_TABLE},
4512
 
  {"Name_locked", 4, DRIZZLE_TYPE_LONGLONG, 0, 0, "Name_locked", SKIP_OPEN_TABLE},
4513
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4595
  {"Table",NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Table", SKIP_OPEN_TABLE},
 
4596
  {"In_use", 1, MYSQL_TYPE_LONGLONG, 0, 0, "In_use", SKIP_OPEN_TABLE},
 
4597
  {"Name_locked", 4, MYSQL_TYPE_LONGLONG, 0, 0, "Name_locked", SKIP_OPEN_TABLE},
 
4598
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4514
4599
};
4515
4600
 
4516
4601
 
4517
4602
ST_FIELD_INFO variables_fields_info[]=
4518
4603
{
4519
 
  {"VARIABLE_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, "Variable_name",
 
4604
  {"VARIABLE_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Variable_name",
4520
4605
   SKIP_OPEN_TABLE},
4521
 
  {"VARIABLE_VALUE", 16300, DRIZZLE_TYPE_VARCHAR, 0, 1, "Value", SKIP_OPEN_TABLE},
4522
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4606
  {"VARIABLE_VALUE", 16300, MYSQL_TYPE_STRING, 0, 1, "Value", SKIP_OPEN_TABLE},
 
4607
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4523
4608
};
4524
4609
 
4525
4610
 
4526
4611
ST_FIELD_INFO processlist_fields_info[]=
4527
4612
{
4528
 
  {"ID", 4, DRIZZLE_TYPE_LONGLONG, 0, 0, "Id", SKIP_OPEN_TABLE},
4529
 
  {"USER", 16, DRIZZLE_TYPE_VARCHAR, 0, 0, "User", SKIP_OPEN_TABLE},
4530
 
  {"HOST", LIST_PROCESS_HOST_LEN,  DRIZZLE_TYPE_VARCHAR, 0, 0, "Host",
4531
 
   SKIP_OPEN_TABLE},
4532
 
  {"DB", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, "Db", SKIP_OPEN_TABLE},
4533
 
  {"COMMAND", 16, DRIZZLE_TYPE_VARCHAR, 0, 0, "Command", SKIP_OPEN_TABLE},
4534
 
  {"TIME", 7, DRIZZLE_TYPE_LONGLONG, 0, 0, "Time", SKIP_OPEN_TABLE},
4535
 
  {"STATE", 64, DRIZZLE_TYPE_VARCHAR, 0, 1, "State", SKIP_OPEN_TABLE},
4536
 
  {"INFO", PROCESS_LIST_INFO_WIDTH, DRIZZLE_TYPE_VARCHAR, 0, 1, "Info",
4537
 
   SKIP_OPEN_TABLE},
4538
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4613
  {"ID", 4, MYSQL_TYPE_LONGLONG, 0, 0, "Id", SKIP_OPEN_TABLE},
 
4614
  {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User", SKIP_OPEN_TABLE},
 
4615
  {"HOST", LIST_PROCESS_HOST_LEN,  MYSQL_TYPE_STRING, 0, 0, "Host",
 
4616
   SKIP_OPEN_TABLE},
 
4617
  {"DB", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, "Db", SKIP_OPEN_TABLE},
 
4618
  {"COMMAND", 16, MYSQL_TYPE_STRING, 0, 0, "Command", SKIP_OPEN_TABLE},
 
4619
  {"TIME", 7, MYSQL_TYPE_LONGLONG, 0, 0, "Time", SKIP_OPEN_TABLE},
 
4620
  {"STATE", 64, MYSQL_TYPE_STRING, 0, 1, "State", SKIP_OPEN_TABLE},
 
4621
  {"INFO", PROCESS_LIST_INFO_WIDTH, MYSQL_TYPE_STRING, 0, 1, "Info",
 
4622
   SKIP_OPEN_TABLE},
 
4623
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4539
4624
};
4540
4625
 
4541
4626
 
4542
4627
ST_FIELD_INFO plugin_fields_info[]=
4543
4628
{
4544
 
  {"PLUGIN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Name", 
4545
 
   SKIP_OPEN_TABLE},
4546
 
  {"PLUGIN_VERSION", 20, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE},
4547
 
  {"PLUGIN_STATUS", 10, DRIZZLE_TYPE_VARCHAR, 0, 0, "Status", SKIP_OPEN_TABLE},
4548
 
  {"PLUGIN_TYPE", 80, DRIZZLE_TYPE_VARCHAR, 0, 0, "Type", SKIP_OPEN_TABLE},
4549
 
  {"PLUGIN_LIBRARY", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, "Library",
4550
 
   SKIP_OPEN_TABLE},
4551
 
  {"PLUGIN_AUTHOR", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, SKIP_OPEN_TABLE},
4552
 
  {"PLUGIN_DESCRIPTION", 65535, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, SKIP_OPEN_TABLE},
4553
 
  {"PLUGIN_LICENSE", 80, DRIZZLE_TYPE_VARCHAR, 0, 1, "License", SKIP_OPEN_TABLE},
4554
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4629
  {"PLUGIN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Name", 
 
4630
   SKIP_OPEN_TABLE},
 
4631
  {"PLUGIN_VERSION", 20, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
 
4632
  {"PLUGIN_STATUS", 10, MYSQL_TYPE_STRING, 0, 0, "Status", SKIP_OPEN_TABLE},
 
4633
  {"PLUGIN_TYPE", 80, MYSQL_TYPE_STRING, 0, 0, "Type", SKIP_OPEN_TABLE},
 
4634
  {"PLUGIN_LIBRARY", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, "Library",
 
4635
   SKIP_OPEN_TABLE},
 
4636
  {"PLUGIN_AUTHOR", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
 
4637
  {"PLUGIN_DESCRIPTION", 65535, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
 
4638
  {"PLUGIN_LICENSE", 80, MYSQL_TYPE_STRING, 0, 1, "License", SKIP_OPEN_TABLE},
 
4639
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
4555
4640
};
4556
4641
 
4557
4642
ST_FIELD_INFO referential_constraints_fields_info[]=
4558
4643
{
4559
 
  {"CONSTRAINT_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0, OPEN_FULL_TABLE},
4560
 
  {"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4561
 
   OPEN_FULL_TABLE},
4562
 
  {"CONSTRAINT_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4563
 
   OPEN_FULL_TABLE},
4564
 
  {"UNIQUE_CONSTRAINT_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, 0,
4565
 
   OPEN_FULL_TABLE},
4566
 
  {"UNIQUE_CONSTRAINT_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
4567
 
   OPEN_FULL_TABLE},
4568
 
  {"UNIQUE_CONSTRAINT_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0,
 
4644
  {"CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
 
4645
  {"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
 
4646
   OPEN_FULL_TABLE},
 
4647
  {"CONSTRAINT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
 
4648
   OPEN_FULL_TABLE},
 
4649
  {"UNIQUE_CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0,
 
4650
   OPEN_FULL_TABLE},
 
4651
  {"UNIQUE_CONSTRAINT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
 
4652
   OPEN_FULL_TABLE},
 
4653
  {"UNIQUE_CONSTRAINT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0,
4569
4654
   MY_I_S_MAYBE_NULL, 0, OPEN_FULL_TABLE},
4570
 
  {"MATCH_OPTION", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4571
 
  {"UPDATE_RULE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4572
 
  {"DELETE_RULE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4573
 
  {"TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, OPEN_FULL_TABLE},
4574
 
  {"REFERENCED_TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 0,
 
4655
  {"MATCH_OPTION", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4656
  {"UPDATE_RULE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4657
  {"DELETE_RULE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4658
  {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4659
  {"REFERENCED_TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
4575
4660
   OPEN_FULL_TABLE},
4576
 
  {0, 0, DRIZZLE_TYPE_VARCHAR, 0, 0, 0, SKIP_OPEN_TABLE}
 
4661
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
 
4662
};
 
4663
 
 
4664
 
 
4665
ST_FIELD_INFO parameters_fields_info[]=
 
4666
{
 
4667
  {"SPECIFIC_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
 
4668
  {"SPECIFIC_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4669
  {"SPECIFIC_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4670
  {"ORDINAL_POSITION", 21 , MYSQL_TYPE_LONG, 0, 0, 0, OPEN_FULL_TABLE},
 
4671
  {"PARAMETER_MODE", 5, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
 
4672
  {"PARAMETER_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
 
4673
  {"DATA_TYPE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4674
  {"CHARACTER_MAXIMUM_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, 0, OPEN_FULL_TABLE},
 
4675
  {"CHARACTER_OCTET_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, 0, OPEN_FULL_TABLE},
 
4676
  {"NUMERIC_PRECISION", 21 , MYSQL_TYPE_LONG, 0, 1, 0, OPEN_FULL_TABLE},
 
4677
  {"NUMERIC_SCALE", 21 , MYSQL_TYPE_LONG, 0, 1, 0, OPEN_FULL_TABLE},
 
4678
  {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
 
4679
  {"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
 
4680
  {"DTD_IDENTIFIER", 65535, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4681
  {"ROUTINE_TYPE", 9, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
 
4682
  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}
4577
4683
};
4578
4684
 
4579
4685
 
4594
4700
   create_schema_table, fill_schema_coll_charset_app, 0, 0, -1, -1, 0, 0},
4595
4701
  {"COLUMNS", columns_fields_info, create_schema_table, 
4596
4702
   get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0,
4597
 
   OPTIMIZE_I_S_TABLE},
 
4703
   OPTIMIZE_I_S_TABLE|OPEN_VIEW_FULL},
4598
4704
  {"GLOBAL_STATUS", variables_fields_info, create_schema_table,
4599
4705
   fill_status, make_old_format, 0, -1, -1, 0, 0},
4600
4706
  {"GLOBAL_VARIABLES", variables_fields_info, create_schema_table,
4661
4767
 
4662
4768
    if (plugin->plugin->init(schema_table))
4663
4769
    {
4664
 
      sql_print_error(_("Plugin '%s' init function returned error."),
 
4770
      sql_print_error("Plugin '%s' init function returned error.",
4665
4771
                      plugin->name.str);
4666
4772
      goto err;
4667
4773
    }
4672
4778
 
4673
4779
  return(0);
4674
4780
err:
4675
 
  free(schema_table);
 
4781
  my_free(schema_table, MYF(0));
4676
4782
  return(1);
4677
4783
}
4678
4784
 
4681
4787
  ST_SCHEMA_TABLE *schema_table= (ST_SCHEMA_TABLE *)plugin->data;
4682
4788
 
4683
4789
  if (schema_table && plugin->plugin->deinit)
4684
 
    free(schema_table);
 
4790
    my_free(schema_table, MYF(0));
4685
4791
 
4686
4792
  return(0);
4687
4793
}