~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/show.cc

  • Committer: Stewart Smith
  • Date: 2009-07-02 17:18:18 UTC
  • mfrom: (1085 staging)
  • mto: This revision was merged to the branch mainline in revision 1089.
  • Revision ID: stewart@flamingspork.com-20090702171818-qrp4d403iw8tazlg
mergeĀ mainline

Show diffs side-by-side

added added

removed removed

Lines of Context:
137
137
** List all table types supported
138
138
***************************************************************************/
139
139
 
140
 
class ShowPlugins : public unary_function<st_plugin_int *, bool>
141
 
{
142
 
  Session *session;
143
 
  Table *table;
144
 
public:
145
 
  ShowPlugins(Session *session_arg, Table *table_arg)
146
 
    : session(session_arg), table(table_arg) {}
147
 
 
148
 
  result_type operator() (argument_type plugin)
149
 
  {
150
 
    struct drizzled_plugin_manifest *plug= plugin_decl(plugin);
151
 
    const CHARSET_INFO * const cs= system_charset_info;
152
 
  
153
 
    table->restoreRecordAsDefault();
154
 
  
155
 
    table->field[0]->store(plugin_name(plugin)->str,
156
 
                           plugin_name(plugin)->length, cs);
157
 
  
158
 
    if (plug->version)
159
 
    {
160
 
      table->field[1]->store(plug->version, strlen(plug->version), cs);
161
 
      table->field[1]->set_notnull();
162
 
    }
163
 
    else
164
 
      table->field[1]->set_null();
165
 
  
166
 
    if (plugin->isInited)
167
 
      table->field[2]->store(STRING_WITH_LEN("ACTIVE"), cs);
168
 
    else
169
 
      table->field[2]->store(STRING_WITH_LEN("INACTIVE"), cs);
170
 
  
171
 
    if (plug->author)
172
 
    {
173
 
      table->field[3]->store(plug->author, strlen(plug->author), cs);
174
 
      table->field[3]->set_notnull();
175
 
    }
176
 
    else
177
 
      table->field[3]->set_null();
178
 
  
179
 
    if (plug->descr)
180
 
    {
181
 
      table->field[4]->store(plug->descr, strlen(plug->descr), cs);
182
 
      table->field[4]->set_notnull();
183
 
    }
184
 
    else
185
 
      table->field[4]->set_null();
186
 
  
187
 
    switch (plug->license) {
188
 
    case PLUGIN_LICENSE_GPL:
189
 
      table->field[5]->store(PLUGIN_LICENSE_GPL_STRING,
190
 
                             strlen(PLUGIN_LICENSE_GPL_STRING), cs);
191
 
      break;
192
 
    case PLUGIN_LICENSE_BSD:
193
 
      table->field[5]->store(PLUGIN_LICENSE_BSD_STRING,
194
 
                             strlen(PLUGIN_LICENSE_BSD_STRING), cs);
195
 
      break;
196
 
    case PLUGIN_LICENSE_LGPL:
197
 
      table->field[5]->store(PLUGIN_LICENSE_LGPL_STRING,
198
 
                             strlen(PLUGIN_LICENSE_LGPL_STRING), cs);
199
 
      break;
200
 
    default:
201
 
      table->field[5]->store(PLUGIN_LICENSE_PROPRIETARY_STRING,
202
 
                             strlen(PLUGIN_LICENSE_PROPRIETARY_STRING), cs);
203
 
      break;
204
 
    }
205
 
    table->field[5]->set_notnull();
206
 
  
207
 
    return schema_table_store_record(session, table);
208
 
  }
209
 
};
210
 
 
211
 
 
212
 
int PluginsISMethods::fillTable(Session *session, TableList *tables, COND *)
213
 
{
214
 
  Table *table= tables->table;
215
 
 
216
 
  PluginRegistry &registry= PluginRegistry::getPluginRegistry();
217
 
  vector<st_plugin_int *> plugins= registry.get_list(true);
218
 
  vector<st_plugin_int *>::iterator iter=
219
 
    find_if(plugins.begin(), plugins.end(), ShowPlugins(session, table));
220
 
  if (iter != plugins.end())
221
 
    return 1;
222
 
  return(0);
223
 
}
224
 
 
225
 
 
226
140
/*
227
141
  find_files() - find files in a given directory.
228
142
 
365
279
    field_list.push_back(new Item_empty_string("Table",NAME_CHAR_LEN));
366
280
    // 1024 is for not to confuse old clients
367
281
    field_list.push_back(new Item_empty_string("Create Table",
368
 
                                               cmax(buffer.length(),(uint32_t)1024)));
 
282
                                               max(buffer.length(),(uint32_t)1024)));
369
283
  }
370
284
 
371
285
  if (protocol->sendFields(&field_list,
1441
1355
/* This is only used internally, but we need it here as a forward reference */
1442
1356
extern InfoSchemaTable schema_tables[];
1443
1357
 
1444
 
typedef struct st_lookup_field_values
1445
 
{
1446
 
  LEX_STRING db_value, table_value;
1447
 
  bool wild_db_value, wild_table_value;
1448
 
} LOOKUP_FIELD_VALUES;
1449
 
 
1450
 
 
1451
1358
/*
1452
1359
  Store record to I_S table, convert HEAP table
1453
1360
  to MyISAM if necessary
1773
1680
}
1774
1681
 
1775
1682
 
1776
 
enum enum_schema_tables get_schema_table_idx(InfoSchemaTable *schema_table)
1777
 
{
1778
 
  return (enum enum_schema_tables) (schema_table - &schema_tables[0]);
1779
 
}
1780
 
 
1781
 
 
1782
1683
/*
1783
1684
  Create db names list. Information schema name always is first in list
1784
1685
 
2261
2162
  LOOKUP_FIELD_VALUES lookup_field_vals;
2262
2163
  LEX_STRING *db_name, *table_name;
2263
2164
  bool with_i_schema;
2264
 
  enum enum_schema_tables schema_table_idx;
2265
2165
  List<LEX_STRING> db_names;
2266
2166
  List_iterator_fast<LEX_STRING> it(db_names);
2267
2167
  COND *partial_cond= 0;
2279
2179
  */
2280
2180
  session->reset_n_backup_open_tables_state(&open_tables_state_backup);
2281
2181
 
2282
 
  schema_table_idx= get_schema_table_idx(schema_table);
2283
2182
  tables->table_open_method= table_open_method=
2284
2183
    get_table_open_method(tables, schema_table);
2285
2184
  /*
2366
2265
            table name or lookup value is wild string(table name list is
2367
2266
            already created by make_table_name_list() function).
2368
2267
          */
2369
 
          if (!table_open_method && schema_table_idx == SCH_TABLES &&
2370
 
              (!lookup_field_vals.table_value.length ||
 
2268
          if (! table_open_method &&
 
2269
              schema_table->getTableName().compare("TABLES") == 0 &&
 
2270
              (! lookup_field_vals.table_value.length ||
2371
2271
               lookup_field_vals.wild_table_value))
2372
2272
          {
2373
2273
            if (schema_table_store_record(session, table))
2376
2276
          }
2377
2277
 
2378
2278
          /* SHOW Table NAMES command */
2379
 
          if (schema_table_idx == SCH_TABLE_NAMES)
 
2279
          if (schema_table->getTableName().compare("TABLE_NAMES") == 0)
2380
2280
          {
2381
2281
            if (fill_schema_table_names(session, tables->table, db_name,
2382
2282
                                        table_name, with_i_schema))
2474
2374
}
2475
2375
 
2476
2376
 
2477
 
bool store_schema_shemata(Session* session, Table *table, LEX_STRING *db_name,
2478
 
                          const CHARSET_INFO * const cs)
2479
 
{
2480
 
  table->restoreRecordAsDefault();
2481
 
  table->field[1]->store(db_name->str, db_name->length, system_charset_info);
2482
 
  table->field[2]->store(cs->csname, strlen(cs->csname), system_charset_info);
2483
 
  table->field[3]->store(cs->name, strlen(cs->name), system_charset_info);
2484
 
  return schema_table_store_record(session, table);
2485
 
}
2486
 
 
2487
 
 
2488
 
int SchemataISMethods::fillTable(Session *session, TableList *tables, COND *cond)
2489
 
{
2490
 
  /*
2491
 
    TODO: fill_schema_shemata() is called when new client is connected.
2492
 
    Returning error status in this case leads to client hangup.
2493
 
  */
2494
 
 
2495
 
  LOOKUP_FIELD_VALUES lookup_field_vals;
2496
 
  List<LEX_STRING> db_names;
2497
 
  LEX_STRING *db_name;
2498
 
  bool with_i_schema;
2499
 
  Table *table= tables->table;
2500
 
 
2501
 
  if (get_lookup_field_values(session, cond, tables, &lookup_field_vals))
2502
 
    return(0);
2503
 
  if (make_db_list(session, &db_names, &lookup_field_vals,
2504
 
                   &with_i_schema))
2505
 
    return(1);
2506
 
 
2507
 
  /*
2508
 
    If we have lookup db value we should check that the database exists
2509
 
  */
2510
 
  if(lookup_field_vals.db_value.str && !lookup_field_vals.wild_db_value &&
2511
 
     !with_i_schema)
2512
 
  {
2513
 
    char path[FN_REFLEN+16];
2514
 
    uint32_t path_len;
2515
 
    struct stat stat_info;
2516
 
    if (!lookup_field_vals.db_value.str[0])
2517
 
      return(0);
2518
 
    path_len= build_table_filename(path, sizeof(path),
2519
 
                                   lookup_field_vals.db_value.str, "", false);
2520
 
    path[path_len-1]= 0;
2521
 
    if (stat(path,&stat_info))
2522
 
      return(0);
2523
 
  }
2524
 
 
2525
 
  List_iterator_fast<LEX_STRING> it(db_names);
2526
 
  while ((db_name=it++))
2527
 
  {
2528
 
    if (with_i_schema)       // information schema name is always first in list
2529
 
    {
2530
 
      if (store_schema_shemata(session, table, db_name,
2531
 
                               system_charset_info))
2532
 
        return(1);
2533
 
      with_i_schema= 0;
2534
 
      continue;
2535
 
    }
2536
 
    {
2537
 
      HA_CREATE_INFO create;
2538
 
      load_db_opt_by_name(db_name->str, &create);
2539
 
 
2540
 
      if (store_schema_shemata(session, table, db_name,
2541
 
                               create.default_table_charset))
2542
 
        return(1);
2543
 
    }
2544
 
  }
2545
 
  return(0);
2546
 
}
2547
 
 
2548
 
 
2549
 
int TablesISMethods::processTable(Session *session, TableList *tables,
2550
 
                                    Table *table, bool res,
2551
 
                                    LEX_STRING *db_name,
2552
 
                                    LEX_STRING *table_name) const
2553
 
{
2554
 
  const char *tmp_buff;
2555
 
  DRIZZLE_TIME time;
2556
 
  const CHARSET_INFO * const cs= system_charset_info;
2557
 
 
2558
 
  table->restoreRecordAsDefault();
2559
 
  table->field[1]->store(db_name->str, db_name->length, cs);
2560
 
  table->field[2]->store(table_name->str, table_name->length, cs);
2561
 
  if (res)
2562
 
  {
2563
 
    /*
2564
 
      there was errors during opening tables
2565
 
    */
2566
 
    const char *error= session->is_error() ? session->main_da.message() : "";
2567
 
    if (tables->schema_table)
2568
 
      table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"), cs);
2569
 
    else
2570
 
      table->field[3]->store(STRING_WITH_LEN("BASE Table"), cs);
2571
 
    table->field[20]->store(error, strlen(error), cs);
2572
 
    session->clear_error();
2573
 
  }
2574
 
  else
2575
 
  {
2576
 
    char option_buff[400],*ptr;
2577
 
    Table *show_table= tables->table;
2578
 
    TableShare *share= show_table->s;
2579
 
    handler *file= show_table->file;
2580
 
    StorageEngine *tmp_db_type= share->db_type();
2581
 
    if (share->tmp_table == SYSTEM_TMP_TABLE)
2582
 
      table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"), cs);
2583
 
    else if (share->tmp_table)
2584
 
      table->field[3]->store(STRING_WITH_LEN("LOCAL TEMPORARY"), cs);
2585
 
    else
2586
 
      table->field[3]->store(STRING_WITH_LEN("BASE Table"), cs);
2587
 
 
2588
 
    for (int i= 4; i < 20; i++)
2589
 
    {
2590
 
      if (i == 7 || (i > 12 && i < 17) || i == 18)
2591
 
        continue;
2592
 
      table->field[i]->set_notnull();
2593
 
    }
2594
 
    string engine_name= ha_resolve_storage_engine_name(tmp_db_type);
2595
 
    table->field[4]->store(engine_name.c_str(), engine_name.size(), cs);
2596
 
    table->field[5]->store((int64_t) 0, true);
2597
 
 
2598
 
    ptr=option_buff;
2599
 
    if (share->min_rows)
2600
 
    {
2601
 
      ptr= strcpy(ptr," min_rows=")+10;
2602
 
      ptr= int64_t10_to_str(share->min_rows,ptr,10);
2603
 
    }
2604
 
    if (share->max_rows)
2605
 
    {
2606
 
      ptr= strcpy(ptr," max_rows=")+10;
2607
 
      ptr= int64_t10_to_str(share->max_rows,ptr,10);
2608
 
    }
2609
 
    if (share->avg_row_length)
2610
 
    {
2611
 
      ptr= strcpy(ptr," avg_row_length=")+16;
2612
 
      ptr= int64_t10_to_str(share->avg_row_length,ptr,10);
2613
 
    }
2614
 
    if (share->db_create_options & HA_OPTION_PACK_KEYS)
2615
 
      ptr= strcpy(ptr," pack_keys=1")+12;
2616
 
    if (share->db_create_options & HA_OPTION_NO_PACK_KEYS)
2617
 
      ptr= strcpy(ptr," pack_keys=0")+12;
2618
 
    /* We use CHECKSUM, instead of TABLE_CHECKSUM, for backward compability */
2619
 
    if (share->db_create_options & HA_OPTION_CHECKSUM)
2620
 
      ptr= strcpy(ptr," checksum=1")+11;
2621
 
    if (share->page_checksum != HA_CHOICE_UNDEF)
2622
 
      ptr+= sprintf(ptr, " page_checksum=%s",
2623
 
                    ha_choice_values[(uint32_t) share->page_checksum]);
2624
 
    if (share->db_create_options & HA_OPTION_DELAY_KEY_WRITE)
2625
 
      ptr= strcpy(ptr," delay_key_write=1")+18;
2626
 
    if (share->row_type != ROW_TYPE_DEFAULT)
2627
 
      ptr+= sprintf(ptr, " row_format=%s", ha_row_type[(uint32_t)share->row_type]);
2628
 
    if (share->block_size)
2629
 
    {
2630
 
      ptr= strcpy(ptr, " block_size=")+12;
2631
 
      ptr= int64_t10_to_str(share->block_size, ptr, 10);
2632
 
    }
2633
 
 
2634
 
    table->field[19]->store(option_buff+1,
2635
 
                            (ptr == option_buff ? 0 :
2636
 
                             (uint32_t) (ptr-option_buff)-1), cs);
2637
 
 
2638
 
    tmp_buff= (share->table_charset ?
2639
 
               share->table_charset->name : "default");
2640
 
    table->field[17]->store(tmp_buff, strlen(tmp_buff), cs);
2641
 
 
2642
 
    if (share->comment.str)
2643
 
      table->field[20]->store(share->comment.str, share->comment.length, cs);
2644
 
 
2645
 
    if(file)
2646
 
    {
2647
 
      file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_AUTO |
2648
 
                 HA_STATUS_NO_LOCK);
2649
 
      enum row_type row_type = file->get_row_type();
2650
 
      switch (row_type) {
2651
 
      case ROW_TYPE_NOT_USED:
2652
 
      case ROW_TYPE_DEFAULT:
2653
 
        tmp_buff= ((share->db_options_in_use &
2654
 
                    HA_OPTION_COMPRESS_RECORD) ? "Compressed" :
2655
 
                   (share->db_options_in_use & HA_OPTION_PACK_RECORD) ?
2656
 
                   "Dynamic" : "Fixed");
2657
 
        break;
2658
 
      case ROW_TYPE_FIXED:
2659
 
        tmp_buff= "Fixed";
2660
 
        break;
2661
 
      case ROW_TYPE_DYNAMIC:
2662
 
        tmp_buff= "Dynamic";
2663
 
        break;
2664
 
      case ROW_TYPE_COMPRESSED:
2665
 
        tmp_buff= "Compressed";
2666
 
        break;
2667
 
      case ROW_TYPE_REDUNDANT:
2668
 
        tmp_buff= "Redundant";
2669
 
        break;
2670
 
      case ROW_TYPE_COMPACT:
2671
 
        tmp_buff= "Compact";
2672
 
        break;
2673
 
      case ROW_TYPE_PAGE:
2674
 
        tmp_buff= "Paged";
2675
 
        break;
2676
 
      }
2677
 
      table->field[6]->store(tmp_buff, strlen(tmp_buff), cs);
2678
 
      if (!tables->schema_table)
2679
 
      {
2680
 
        table->field[7]->store((int64_t) file->stats.records, true);
2681
 
        table->field[7]->set_notnull();
2682
 
      }
2683
 
      table->field[8]->store((int64_t) file->stats.mean_rec_length, true);
2684
 
      table->field[9]->store((int64_t) file->stats.data_file_length, true);
2685
 
      if (file->stats.max_data_file_length)
2686
 
      {
2687
 
        table->field[10]->store((int64_t) file->stats.max_data_file_length,
2688
 
                                true);
2689
 
      }
2690
 
      table->field[11]->store((int64_t) file->stats.index_file_length, true);
2691
 
      table->field[12]->store((int64_t) file->stats.delete_length, true);
2692
 
      if (show_table->found_next_number_field)
2693
 
      {
2694
 
        table->field[13]->store((int64_t) file->stats.auto_increment_value,
2695
 
                                true);
2696
 
        table->field[13]->set_notnull();
2697
 
      }
2698
 
      if (file->stats.create_time)
2699
 
      {
2700
 
        session->variables.time_zone->gmt_sec_to_TIME(&time,
2701
 
                                                  (time_t) file->stats.create_time);
2702
 
        table->field[14]->store_time(&time, DRIZZLE_TIMESTAMP_DATETIME);
2703
 
        table->field[14]->set_notnull();
2704
 
      }
2705
 
      if (file->stats.update_time)
2706
 
      {
2707
 
        session->variables.time_zone->gmt_sec_to_TIME(&time,
2708
 
                                                  (time_t) file->stats.update_time);
2709
 
        table->field[15]->store_time(&time, DRIZZLE_TIMESTAMP_DATETIME);
2710
 
        table->field[15]->set_notnull();
2711
 
      }
2712
 
      if (file->stats.check_time)
2713
 
      {
2714
 
        session->variables.time_zone->gmt_sec_to_TIME(&time,
2715
 
                                                  (time_t) file->stats.check_time);
2716
 
        table->field[16]->store_time(&time, DRIZZLE_TIMESTAMP_DATETIME);
2717
 
        table->field[16]->set_notnull();
2718
 
      }
2719
 
      if (file->ha_table_flags() & (ulong) HA_HAS_CHECKSUM)
2720
 
      {
2721
 
        table->field[18]->store((int64_t) file->checksum(), true);
2722
 
        table->field[18]->set_notnull();
2723
 
      }
2724
 
    }
2725
 
  }
2726
 
  return(schema_table_store_record(session, table));
2727
 
}
2728
 
 
2729
 
 
2730
2377
/**
2731
2378
  @brief    Store field characteristics into appropriate I_S table columns
2732
2379
 
2956
2603
}
2957
2604
 
2958
2605
 
2959
 
int StatsISMethods::processTable(Session *session, TableList *tables,
2960
 
                                  Table *table, bool res,
2961
 
                                  LEX_STRING *db_name,
2962
 
                                  LEX_STRING *table_name) const
2963
 
{
2964
 
  const CHARSET_INFO * const cs= system_charset_info;
2965
 
  if (res)
2966
 
  {
2967
 
    if (session->lex->sql_command != SQLCOM_SHOW_KEYS)
2968
 
    {
2969
 
      /*
2970
 
        I.e. we are in SELECT FROM INFORMATION_SCHEMA.STATISTICS
2971
 
        rather than in SHOW KEYS
2972
 
      */
2973
 
      if (session->is_error())
2974
 
        push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
2975
 
                     session->main_da.sql_errno(), session->main_da.message());
2976
 
      session->clear_error();
2977
 
      res= 0;
2978
 
    }
2979
 
    return(res);
2980
 
  }
2981
 
  else
2982
 
  {
2983
 
    Table *show_table= tables->table;
2984
 
    KEY *key_info=show_table->s->key_info;
2985
 
    if (show_table->file)
2986
 
      show_table->file->info(HA_STATUS_VARIABLE |
2987
 
                             HA_STATUS_NO_LOCK |
2988
 
                             HA_STATUS_TIME);
2989
 
    for (uint32_t i=0 ; i < show_table->s->keys ; i++,key_info++)
2990
 
    {
2991
 
      KEY_PART_INFO *key_part= key_info->key_part;
2992
 
      const char *str;
2993
 
      for (uint32_t j=0 ; j < key_info->key_parts ; j++,key_part++)
2994
 
      {
2995
 
        table->restoreRecordAsDefault();
2996
 
        table->field[1]->store(db_name->str, db_name->length, cs);
2997
 
        table->field[2]->store(table_name->str, table_name->length, cs);
2998
 
        table->field[3]->store((int64_t) ((key_info->flags &
2999
 
                                            HA_NOSAME) ? 0 : 1), true);
3000
 
        table->field[4]->store(db_name->str, db_name->length, cs);
3001
 
        table->field[5]->store(key_info->name, strlen(key_info->name), cs);
3002
 
        table->field[6]->store((int64_t) (j+1), true);
3003
 
        str=(key_part->field ? key_part->field->field_name :
3004
 
             "?unknown field?");
3005
 
        table->field[7]->store(str, strlen(str), cs);
3006
 
        if (show_table->file)
3007
 
        {
3008
 
          if (show_table->file->index_flags(i, j, 0) & HA_READ_ORDER)
3009
 
          {
3010
 
            table->field[8]->store(((key_part->key_part_flag &
3011
 
                                     HA_REVERSE_SORT) ?
3012
 
                                    "D" : "A"), 1, cs);
3013
 
            table->field[8]->set_notnull();
3014
 
          }
3015
 
          KEY *key=show_table->key_info+i;
3016
 
          if (key->rec_per_key[j])
3017
 
          {
3018
 
            ha_rows records=(show_table->file->stats.records /
3019
 
                             key->rec_per_key[j]);
3020
 
            table->field[9]->store((int64_t) records, true);
3021
 
            table->field[9]->set_notnull();
3022
 
          }
3023
 
          str= show_table->file->index_type(i);
3024
 
          table->field[13]->store(str, strlen(str), cs);
3025
 
        }
3026
 
        if ((key_part->field &&
3027
 
             key_part->length !=
3028
 
             show_table->s->field[key_part->fieldnr-1]->key_length()))
3029
 
        {
3030
 
          table->field[10]->store((int64_t) key_part->length /
3031
 
                                  key_part->field->charset()->mbmaxlen, true);
3032
 
          table->field[10]->set_notnull();
3033
 
        }
3034
 
        uint32_t flags= key_part->field ? key_part->field->flags : 0;
3035
 
        const char *pos=(char*) ((flags & NOT_NULL_FLAG) ? "" : "YES");
3036
 
        table->field[12]->store(pos, strlen(pos), cs);
3037
 
        if (!show_table->s->keys_in_use.test(i))
3038
 
          table->field[14]->store(STRING_WITH_LEN("disabled"), cs);
3039
 
        else
3040
 
          table->field[14]->store("", 0, cs);
3041
 
        table->field[14]->set_notnull();
3042
 
        assert(test(key_info->flags & HA_USES_COMMENT) ==
3043
 
                   (key_info->comment.length > 0));
3044
 
        if (key_info->flags & HA_USES_COMMENT)
3045
 
          table->field[15]->store(key_info->comment.str,
3046
 
                                  key_info->comment.length, cs);
3047
 
        if (schema_table_store_record(session, table))
3048
 
          return(1);
3049
 
      }
3050
 
    }
3051
 
  }
3052
 
  return(res);
3053
 
}
3054
 
 
3055
 
 
3056
 
bool store_constraints(Session *session, Table *table, LEX_STRING *db_name,
3057
 
                       LEX_STRING *table_name, const char *key_name,
3058
 
                       uint32_t key_len, const char *con_type, uint32_t con_len)
3059
 
{
3060
 
  const CHARSET_INFO * const cs= system_charset_info;
3061
 
  table->restoreRecordAsDefault();
3062
 
  table->field[1]->store(db_name->str, db_name->length, cs);
3063
 
  table->field[2]->store(key_name, key_len, cs);
3064
 
  table->field[3]->store(db_name->str, db_name->length, cs);
3065
 
  table->field[4]->store(table_name->str, table_name->length, cs);
3066
 
  table->field[5]->store(con_type, con_len, cs);
3067
 
  return schema_table_store_record(session, table);
3068
 
}
3069
 
 
3070
 
 
3071
 
int TabConstraintsISMethods::processTable(Session *session, TableList *tables,
3072
 
                                         Table *table, bool res,
3073
 
                                         LEX_STRING *db_name,
3074
 
                                         LEX_STRING *table_name) const
3075
 
{
3076
 
  if (res)
3077
 
  {
3078
 
    if (session->is_error())
3079
 
      push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
3080
 
                   session->main_da.sql_errno(), session->main_da.message());
3081
 
    session->clear_error();
3082
 
    return(0);
3083
 
  }
3084
 
  else
3085
 
  {
3086
 
    List<FOREIGN_KEY_INFO> f_key_list;
3087
 
    Table *show_table= tables->table;
3088
 
    KEY *key_info=show_table->key_info;
3089
 
    uint32_t primary_key= show_table->s->primary_key;
3090
 
    show_table->file->info(HA_STATUS_VARIABLE |
3091
 
                           HA_STATUS_NO_LOCK |
3092
 
                           HA_STATUS_TIME);
3093
 
    for (uint32_t i=0 ; i < show_table->s->keys ; i++, key_info++)
3094
 
    {
3095
 
      if (i != primary_key && !(key_info->flags & HA_NOSAME))
3096
 
        continue;
3097
 
 
3098
 
      if (i == primary_key && is_primary_key(key_info))
3099
 
      {
3100
 
        if (store_constraints(session, table, db_name, table_name, key_info->name,
3101
 
                              strlen(key_info->name),
3102
 
                              STRING_WITH_LEN("PRIMARY KEY")))
3103
 
          return(1);
3104
 
      }
3105
 
      else if (key_info->flags & HA_NOSAME)
3106
 
      {
3107
 
        if (store_constraints(session, table, db_name, table_name, key_info->name,
3108
 
                              strlen(key_info->name),
3109
 
                              STRING_WITH_LEN("UNIQUE")))
3110
 
          return(1);
3111
 
      }
3112
 
    }
3113
 
 
3114
 
    show_table->file->get_foreign_key_list(session, &f_key_list);
3115
 
    FOREIGN_KEY_INFO *f_key_info;
3116
 
    List_iterator_fast<FOREIGN_KEY_INFO> it(f_key_list);
3117
 
    while ((f_key_info=it++))
3118
 
    {
3119
 
      if (store_constraints(session, table, db_name, table_name,
3120
 
                            f_key_info->forein_id->str,
3121
 
                            strlen(f_key_info->forein_id->str),
3122
 
                            "FOREIGN KEY", 11))
3123
 
        return(1);
3124
 
    }
3125
 
  }
3126
 
  return(res);
3127
 
}
3128
 
 
3129
 
 
3130
 
void store_key_column_usage(Table *table, LEX_STRING *db_name,
3131
 
                            LEX_STRING *table_name, const char *key_name,
3132
 
                            uint32_t key_len, const char *con_type, uint32_t con_len,
3133
 
                            int64_t idx)
3134
 
{
3135
 
  const CHARSET_INFO * const cs= system_charset_info;
3136
 
  table->field[1]->store(db_name->str, db_name->length, cs);
3137
 
  table->field[2]->store(key_name, key_len, cs);
3138
 
  table->field[4]->store(db_name->str, db_name->length, cs);
3139
 
  table->field[5]->store(table_name->str, table_name->length, cs);
3140
 
  table->field[6]->store(con_type, con_len, cs);
3141
 
  table->field[7]->store((int64_t) idx, true);
3142
 
}
3143
 
 
3144
 
 
3145
 
int KeyColUsageISMethods::processTable(Session *session,
3146
 
                                              TableList *tables,
3147
 
                                              Table *table, bool res,
3148
 
                                              LEX_STRING *db_name,
3149
 
                                              LEX_STRING *table_name) const
3150
 
{
3151
 
  if (res)
3152
 
  {
3153
 
    if (session->is_error())
3154
 
      push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
3155
 
                   session->main_da.sql_errno(), session->main_da.message());
3156
 
    session->clear_error();
3157
 
    return(0);
3158
 
  }
3159
 
  else
3160
 
  {
3161
 
    List<FOREIGN_KEY_INFO> f_key_list;
3162
 
    Table *show_table= tables->table;
3163
 
    KEY *key_info=show_table->key_info;
3164
 
    uint32_t primary_key= show_table->s->primary_key;
3165
 
    show_table->file->info(HA_STATUS_VARIABLE |
3166
 
                           HA_STATUS_NO_LOCK |
3167
 
                           HA_STATUS_TIME);
3168
 
    for (uint32_t i=0 ; i < show_table->s->keys ; i++, key_info++)
3169
 
    {
3170
 
      if (i != primary_key && !(key_info->flags & HA_NOSAME))
3171
 
        continue;
3172
 
      uint32_t f_idx= 0;
3173
 
      KEY_PART_INFO *key_part= key_info->key_part;
3174
 
      for (uint32_t j=0 ; j < key_info->key_parts ; j++,key_part++)
3175
 
      {
3176
 
        if (key_part->field)
3177
 
        {
3178
 
          f_idx++;
3179
 
          table->restoreRecordAsDefault();
3180
 
          store_key_column_usage(table, db_name, table_name,
3181
 
                                 key_info->name,
3182
 
                                 strlen(key_info->name),
3183
 
                                 key_part->field->field_name,
3184
 
                                 strlen(key_part->field->field_name),
3185
 
                                 (int64_t) f_idx);
3186
 
          if (schema_table_store_record(session, table))
3187
 
            return(1);
3188
 
        }
3189
 
      }
3190
 
    }
3191
 
 
3192
 
    show_table->file->get_foreign_key_list(session, &f_key_list);
3193
 
    FOREIGN_KEY_INFO *f_key_info;
3194
 
    List_iterator_fast<FOREIGN_KEY_INFO> fkey_it(f_key_list);
3195
 
    while ((f_key_info= fkey_it++))
3196
 
    {
3197
 
      LEX_STRING *f_info;
3198
 
      LEX_STRING *r_info;
3199
 
      List_iterator_fast<LEX_STRING> it(f_key_info->foreign_fields),
3200
 
        it1(f_key_info->referenced_fields);
3201
 
      uint32_t f_idx= 0;
3202
 
      while ((f_info= it++))
3203
 
      {
3204
 
        r_info= it1++;
3205
 
        f_idx++;
3206
 
        table->restoreRecordAsDefault();
3207
 
        store_key_column_usage(table, db_name, table_name,
3208
 
                               f_key_info->forein_id->str,
3209
 
                               f_key_info->forein_id->length,
3210
 
                               f_info->str, f_info->length,
3211
 
                               (int64_t) f_idx);
3212
 
        table->field[8]->store((int64_t) f_idx, true);
3213
 
        table->field[8]->set_notnull();
3214
 
        table->field[9]->store(f_key_info->referenced_db->str,
3215
 
                               f_key_info->referenced_db->length,
3216
 
                               system_charset_info);
3217
 
        table->field[9]->set_notnull();
3218
 
        table->field[10]->store(f_key_info->referenced_table->str,
3219
 
                                f_key_info->referenced_table->length,
3220
 
                                system_charset_info);
3221
 
        table->field[10]->set_notnull();
3222
 
        table->field[11]->store(r_info->str, r_info->length,
3223
 
                                system_charset_info);
3224
 
        table->field[11]->set_notnull();
3225
 
        if (schema_table_store_record(session, table))
3226
 
          return(1);
3227
 
      }
3228
 
    }
3229
 
  }
3230
 
  return(res);
3231
 
}
3232
 
 
3233
 
 
3234
 
int OpenTablesISMethods::fillTable(Session *session, TableList *tables, COND *)
3235
 
{
3236
 
  const char *wild= session->lex->wild ? session->lex->wild->ptr() : NULL;
3237
 
  Table *table= tables->table;
3238
 
  const CHARSET_INFO * const cs= system_charset_info;
3239
 
  OPEN_TableList *open_list;
3240
 
  if (!(open_list=list_open_tables(session->lex->select_lex.db, wild))
3241
 
            && session->is_fatal_error)
3242
 
    return(1);
3243
 
 
3244
 
  for (; open_list ; open_list=open_list->next)
3245
 
  {
3246
 
    table->restoreRecordAsDefault();
3247
 
    table->field[0]->store(open_list->db, strlen(open_list->db), cs);
3248
 
    table->field[1]->store(open_list->table, strlen(open_list->table), cs);
3249
 
    table->field[2]->store((int64_t) open_list->in_use, true);
3250
 
    table->field[3]->store((int64_t) open_list->locked, true);
3251
 
    if (schema_table_store_record(session, table))
3252
 
      return(1);
3253
 
  }
3254
 
  return(0);
3255
 
}
3256
 
 
3257
 
 
3258
2606
int VariablesISMethods::fillTable(Session *session, TableList *tables, COND *)
3259
2607
{
3260
2608
  int res= 0;
3261
2609
  LEX *lex= session->lex;
3262
2610
  const char *wild= lex->wild ? lex->wild->ptr() : NULL;
3263
 
  enum enum_schema_tables schema_table_idx=
3264
 
    get_schema_table_idx(tables->schema_table);
 
2611
  const string schema_table_name= tables->schema_table->getTableName();
3265
2612
  enum enum_var_type option_type= OPT_SESSION;
3266
 
  bool upper_case_names= (schema_table_idx != SCH_VARIABLES);
3267
 
  bool sorted_vars= (schema_table_idx == SCH_VARIABLES);
 
2613
  bool upper_case_names= (schema_table_name.compare("VARIABLES") != 0);
 
2614
  bool sorted_vars= (schema_table_name.compare("VARIABLES") == 0);
3268
2615
 
3269
2616
  if (lex->option_type == OPT_GLOBAL ||
3270
 
      schema_table_idx == SCH_GLOBAL_VARIABLES)
 
2617
      schema_table_name.compare("GLOBAL_VARIABLES") == 0)
 
2618
  {
3271
2619
    option_type= OPT_GLOBAL;
 
2620
  }
3272
2621
 
3273
2622
  pthread_rwlock_rdlock(&LOCK_system_variables_hash);
3274
2623
  res= show_status_array(session, wild, enumerate_sys_vars(session, sorted_vars),
3284
2633
  const char *wild= lex->wild ? lex->wild->ptr() : NULL;
3285
2634
  int res= 0;
3286
2635
  STATUS_VAR *tmp1, tmp;
3287
 
  enum enum_schema_tables schema_table_idx=
3288
 
    get_schema_table_idx(tables->schema_table);
 
2636
  const string schema_table_name= tables->schema_table->getTableName();
3289
2637
  enum enum_var_type option_type;
3290
 
  bool upper_case_names= (schema_table_idx != SCH_STATUS);
 
2638
  bool upper_case_names= (schema_table_name.compare("STATUS") != 0);
3291
2639
 
3292
 
  if (schema_table_idx == SCH_STATUS)
 
2640
  if (schema_table_name.compare("STATUS") == 0)
3293
2641
  {
3294
2642
    option_type= lex->option_type;
3295
2643
    if (option_type == OPT_GLOBAL)
3297
2645
    else
3298
2646
      tmp1= session->initial_status_var;
3299
2647
  }
3300
 
  else if (schema_table_idx == SCH_GLOBAL_STATUS)
 
2648
  else if (schema_table_name.compare("GLOBAL_STATUS") == 0)
3301
2649
  {
3302
2650
    option_type= OPT_GLOBAL;
3303
2651
    tmp1= &tmp;
3320
2668
}
3321
2669
 
3322
2670
 
3323
 
/*
3324
 
  Fill and store records into I_S.referential_constraints table
3325
 
 
3326
 
  SYNOPSIS
3327
 
    RefConstraintsISMethods::processTable()
3328
 
    session                 thread handle
3329
 
    tables              table list struct(processed table)
3330
 
    table               I_S table
3331
 
    res                 1 means the error during opening of the processed table
3332
 
                        0 means processed table is opened without error
3333
 
    base_name           db name
3334
 
    file_name           table name
3335
 
 
3336
 
  RETURN
3337
 
    0   ok
3338
 
    #   error
3339
 
*/
3340
 
 
3341
 
int
3342
 
RefConstraintsISMethods::processTable(Session *session, TableList *tables,
3343
 
                                      Table *table, bool res,
3344
 
                                      LEX_STRING *db_name, LEX_STRING *table_name)
3345
 
  const
3346
 
{
3347
 
  const CHARSET_INFO * const cs= system_charset_info;
3348
 
 
3349
 
  if (res)
3350
 
  {
3351
 
    if (session->is_error())
3352
 
      push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
3353
 
                   session->main_da.sql_errno(), session->main_da.message());
3354
 
    session->clear_error();
3355
 
    return(0);
3356
 
  }
3357
 
 
3358
 
  {
3359
 
    List<FOREIGN_KEY_INFO> f_key_list;
3360
 
    Table *show_table= tables->table;
3361
 
    show_table->file->info(HA_STATUS_VARIABLE |
3362
 
                           HA_STATUS_NO_LOCK |
3363
 
                           HA_STATUS_TIME);
3364
 
 
3365
 
    show_table->file->get_foreign_key_list(session, &f_key_list);
3366
 
    FOREIGN_KEY_INFO *f_key_info;
3367
 
    List_iterator_fast<FOREIGN_KEY_INFO> it(f_key_list);
3368
 
    while ((f_key_info= it++))
3369
 
    {
3370
 
      table->restoreRecordAsDefault();
3371
 
      table->field[1]->store(db_name->str, db_name->length, cs);
3372
 
      table->field[9]->store(table_name->str, table_name->length, cs);
3373
 
      table->field[2]->store(f_key_info->forein_id->str,
3374
 
                             f_key_info->forein_id->length, cs);
3375
 
      table->field[4]->store(f_key_info->referenced_db->str,
3376
 
                             f_key_info->referenced_db->length, cs);
3377
 
      table->field[10]->store(f_key_info->referenced_table->str,
3378
 
                             f_key_info->referenced_table->length, cs);
3379
 
      if (f_key_info->referenced_key_name)
3380
 
      {
3381
 
        table->field[5]->store(f_key_info->referenced_key_name->str,
3382
 
                               f_key_info->referenced_key_name->length, cs);
3383
 
        table->field[5]->set_notnull();
3384
 
      }
3385
 
      else
3386
 
        table->field[5]->set_null();
3387
 
      table->field[6]->store(STRING_WITH_LEN("NONE"), cs);
3388
 
      table->field[7]->store(f_key_info->update_method->str,
3389
 
                             f_key_info->update_method->length, cs);
3390
 
      table->field[8]->store(f_key_info->delete_method->str,
3391
 
                             f_key_info->delete_method->length, cs);
3392
 
      if (schema_table_store_record(session, table))
3393
 
        return(1);
3394
 
    }
3395
 
  }
3396
 
  return(0);
3397
 
}
3398
 
 
3399
 
 
3400
2671
class FindSchemaTableByName : public unary_function<InfoSchemaTable *, bool>
3401
2672
{
3402
2673
  const char *table_name;
3445
2716
}
3446
2717
 
3447
2718
 
3448
 
InfoSchemaTable *get_schema_table(enum enum_schema_tables schema_table_idx)
3449
 
{
3450
 
  return &schema_tables[schema_table_idx];
3451
 
}
3452
 
 
3453
 
 
3454
2719
Table *InfoSchemaMethods::createSchemaTable(Session *session, TableList *table_list)
3455
2720
  const
3456
2721
{
3595
2860
}
3596
2861
 
3597
2862
 
3598
 
int SchemataISMethods::oldFormat(Session *session, InfoSchemaTable *schema_table)
3599
 
  const
3600
 
{
3601
 
  char tmp[128];
3602
 
  LEX *lex= session->lex;
3603
 
  Select_Lex *sel= lex->current_select;
3604
 
  Name_resolution_context *context= &sel->context;
3605
 
  const InfoSchemaTable::Columns columns= schema_table->getColumns();
3606
 
 
3607
 
  if (!sel->item_list.elements)
3608
 
  {
3609
 
    const ColumnInfo *column= columns[1];
3610
 
    String buffer(tmp,sizeof(tmp), system_charset_info);
3611
 
    Item_field *field= new Item_field(context,
3612
 
                                      NULL, NULL, column->getName().c_str());
3613
 
    if (!field || session->add_item_to_list(field))
3614
 
      return 1;
3615
 
    buffer.length(0);
3616
 
    buffer.append(column->getOldName().c_str());
3617
 
    if (lex->wild && lex->wild->ptr())
3618
 
    {
3619
 
      buffer.append(STRING_WITH_LEN(" ("));
3620
 
      buffer.append(lex->wild->ptr());
3621
 
      buffer.append(')');
3622
 
    }
3623
 
    field->set_name(buffer.ptr(), buffer.length(), system_charset_info);
3624
 
  }
3625
 
  return 0;
3626
 
}
3627
 
 
3628
 
 
3629
 
int TabNamesISMethods::oldFormat(Session *session, InfoSchemaTable *schema_table)
3630
 
  const
3631
 
{
3632
 
  char tmp[128];
3633
 
  String buffer(tmp,sizeof(tmp), session->charset());
3634
 
  LEX *lex= session->lex;
3635
 
  Name_resolution_context *context= &lex->select_lex.context;
3636
 
  const InfoSchemaTable::Columns columns= schema_table->getColumns();
3637
 
 
3638
 
  const ColumnInfo *column= columns[2];
3639
 
  buffer.length(0);
3640
 
  buffer.append(column->getOldName().c_str());
3641
 
  buffer.append(lex->select_lex.db);
3642
 
  if (lex->wild && lex->wild->ptr())
3643
 
  {
3644
 
    buffer.append(STRING_WITH_LEN(" ("));
3645
 
    buffer.append(lex->wild->ptr());
3646
 
    buffer.append(')');
3647
 
  }
3648
 
  Item_field *field= new Item_field(context,
3649
 
                                    NULL, NULL, column->getName().c_str());
3650
 
  if (session->add_item_to_list(field))
3651
 
    return 1;
3652
 
  field->set_name(buffer.ptr(), buffer.length(), system_charset_info);
3653
 
  if (session->lex->verbose)
3654
 
  {
3655
 
    field->set_name(buffer.ptr(), buffer.length(), system_charset_info);
3656
 
    column= columns[3];
3657
 
    field= new Item_field(context, NULL, NULL, column->getName().c_str());
3658
 
    if (session->add_item_to_list(field))
3659
 
      return 1;
3660
 
    field->set_name(column->getOldName().c_str(), 
3661
 
                    column->getOldName().length(),
3662
 
                    system_charset_info);
3663
 
  }
3664
 
  return 0;
3665
 
}
3666
 
 
3667
 
 
3668
 
int ColumnsISMethods::oldFormat(Session *session, InfoSchemaTable *schema_table)
3669
 
  const
3670
 
{
3671
 
  int fields_arr[]= {3, 14, 13, 6, 15, 5, 16, 17, 18, -1};
3672
 
  int *field_num= fields_arr;
3673
 
  const InfoSchemaTable::Columns columns= schema_table->getColumns();
3674
 
  const ColumnInfo *column;
3675
 
  Name_resolution_context *context= &session->lex->select_lex.context;
3676
 
 
3677
 
  for (; *field_num >= 0; field_num++)
3678
 
  {
3679
 
    column= columns[*field_num];
3680
 
    if (!session->lex->verbose && (*field_num == 13 ||
3681
 
                               *field_num == 17 ||
3682
 
                               *field_num == 18))
3683
 
      continue;
3684
 
    Item_field *field= new Item_field(context,
3685
 
                                      NULL, NULL, column->getName().c_str());
3686
 
    if (field)
3687
 
    {
3688
 
      field->set_name(column->getOldName().c_str(),
3689
 
                      column->getOldName().length(),
3690
 
                      system_charset_info);
3691
 
      if (session->add_item_to_list(field))
3692
 
        return 1;
3693
 
    }
3694
 
  }
3695
 
  return 0;
3696
 
}
3697
 
 
3698
 
 
3699
2863
/*
3700
2864
  Create information_schema table
3701
2865
 
3744
2908
    make_schema_select()
3745
2909
    session                  thread handler
3746
2910
    sel                  pointer to Select_Lex
3747
 
    schema_table_idx     index of 'schema_tables' element
 
2911
    schema_table_name    name of 'schema_tables' element
3748
2912
 
3749
2913
  RETURN
3750
2914
    true on error
3751
2915
*/
3752
2916
 
3753
2917
bool make_schema_select(Session *session, Select_Lex *sel,
3754
 
                        enum enum_schema_tables schema_table_idx)
 
2918
                        const string& schema_table_name)
3755
2919
{
3756
 
  InfoSchemaTable *schema_table= get_schema_table(schema_table_idx);
 
2920
  InfoSchemaTable *schema_table= find_schema_table(schema_table_name.c_str());
3757
2921
  LEX_STRING db, table;
3758
2922
  /*
3759
2923
     We have to make non const db_name & table_name
3861
3025
  return(result);
3862
3026
}
3863
3027
 
3864
 
ColumnInfo schema_fields_info[]=
3865
 
{
3866
 
  ColumnInfo("CATALOG_NAME",
3867
 
            FN_REFLEN,
3868
 
            DRIZZLE_TYPE_VARCHAR,
3869
 
            0, 1, "", SKIP_OPEN_TABLE),
3870
 
  ColumnInfo("SCHEMA_NAME",
3871
 
            NAME_CHAR_LEN,
3872
 
            DRIZZLE_TYPE_VARCHAR,
3873
 
            0, 0, "Database", SKIP_OPEN_TABLE),
3874
 
  ColumnInfo("DEFAULT_CHARACTER_SET_NAME", 
3875
 
            64, DRIZZLE_TYPE_VARCHAR, 0, 0, "",
3876
 
            SKIP_OPEN_TABLE),
3877
 
  ColumnInfo("DEFAULT_COLLATION_NAME",
3878
 
            64, DRIZZLE_TYPE_VARCHAR, 0, 0, "",
3879
 
            SKIP_OPEN_TABLE),
3880
 
  ColumnInfo("SQL_PATH",
3881
 
            FN_REFLEN,
3882
 
            DRIZZLE_TYPE_VARCHAR,
3883
 
            0, 1, "", SKIP_OPEN_TABLE),
3884
 
  ColumnInfo()
3885
 
};
3886
 
 
3887
 
 
3888
 
ColumnInfo tables_fields_info[]=
3889
 
{
3890
 
  ColumnInfo("TABLE_CATALOG",  FN_REFLEN, DRIZZLE_TYPE_VARCHAR,
3891
 
            0, 1, "", SKIP_OPEN_TABLE),
3892
 
  ColumnInfo("TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR,
3893
 
            0, 0, "", SKIP_OPEN_TABLE), 
3894
 
  ColumnInfo("TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR,
3895
 
            0, 0, "Name", SKIP_OPEN_TABLE),
3896
 
  ColumnInfo("TABLE_TYPE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR,
3897
 
            0, 0, "", OPEN_FRM_ONLY),
3898
 
  ColumnInfo("ENGINE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR,
3899
 
            0, 1, "Engine", OPEN_FRM_ONLY),
3900
 
  ColumnInfo("VERSION", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
3901
 
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Version", OPEN_FRM_ONLY),
3902
 
  ColumnInfo("ROW_FORMAT", 10, DRIZZLE_TYPE_VARCHAR, 0, 1, "Row_format", OPEN_FULL_TABLE),
3903
 
  ColumnInfo("TABLE_ROWS", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
3904
 
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Rows", OPEN_FULL_TABLE),
3905
 
  ColumnInfo("AVG_ROW_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
3906
 
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Avg_row_length", OPEN_FULL_TABLE),
3907
 
  ColumnInfo("DATA_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
3908
 
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Data_length", OPEN_FULL_TABLE),
3909
 
  ColumnInfo("MAX_DATA_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
3910
 
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Max_data_length", OPEN_FULL_TABLE),
3911
 
  ColumnInfo("INDEX_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
3912
 
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Index_length", OPEN_FULL_TABLE),
3913
 
  ColumnInfo("DATA_FREE", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
3914
 
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Data_free", OPEN_FULL_TABLE),
3915
 
  ColumnInfo("AUTO_INCREMENT", MY_INT64_NUM_DECIMAL_DIGITS , DRIZZLE_TYPE_LONGLONG, 0,
3916
 
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Auto_increment", OPEN_FULL_TABLE),
3917
 
  ColumnInfo("CREATE_TIME", 0, DRIZZLE_TYPE_DATETIME, 0, 1, "Create_time", OPEN_FULL_TABLE),
3918
 
  ColumnInfo("UPDATE_TIME", 0, DRIZZLE_TYPE_DATETIME, 0, 1, "Update_time", OPEN_FULL_TABLE),
3919
 
  ColumnInfo("CHECK_TIME", 0, DRIZZLE_TYPE_DATETIME, 0, 1, "Check_time", OPEN_FULL_TABLE),
3920
 
  ColumnInfo("TABLE_COLLATION", 64, DRIZZLE_TYPE_VARCHAR, 0, 1, "Collation", OPEN_FRM_ONLY),
3921
 
  ColumnInfo("CHECKSUM", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
3922
 
   (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Checksum", OPEN_FULL_TABLE),
3923
 
  ColumnInfo("CREATE_OPTIONS", 255, DRIZZLE_TYPE_VARCHAR, 0, 1, "Create_options",
3924
 
   OPEN_FRM_ONLY),
3925
 
  ColumnInfo("TABLE_COMMENT", TABLE_COMMENT_MAXLEN, DRIZZLE_TYPE_VARCHAR,
3926
 
            0, 0, "Comment", OPEN_FRM_ONLY),
3927
 
  ColumnInfo()
3928
 
};
3929
 
 
3930
 
 
3931
 
ColumnInfo columns_fields_info[]=
3932
 
{
3933
 
  ColumnInfo("TABLE_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, "", OPEN_FRM_ONLY),
3934
 
  ColumnInfo("TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "", OPEN_FRM_ONLY),
3935
 
  ColumnInfo("TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "", OPEN_FRM_ONLY),
3936
 
  ColumnInfo("COLUMN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Field",
3937
 
   OPEN_FRM_ONLY),
3938
 
  ColumnInfo("ORDINAL_POSITION", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0,
3939
 
   MY_I_S_UNSIGNED, "", OPEN_FRM_ONLY),
3940
 
  ColumnInfo("COLUMN_DEFAULT", MAX_FIELD_VARCHARLENGTH, DRIZZLE_TYPE_VARCHAR, 0,
3941
 
   1, "Default", OPEN_FRM_ONLY),
3942
 
  ColumnInfo("IS_NULLABLE", 3, DRIZZLE_TYPE_VARCHAR, 0, 0, "Null", OPEN_FRM_ONLY),
3943
 
  ColumnInfo("DATA_TYPE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "", OPEN_FRM_ONLY),
3944
 
  ColumnInfo("CHARACTER_MAXIMUM_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG,
3945
 
   0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "", OPEN_FRM_ONLY),
3946
 
  ColumnInfo("CHARACTER_OCTET_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS , DRIZZLE_TYPE_LONGLONG,
3947
 
   0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "", OPEN_FRM_ONLY),
3948
 
  ColumnInfo("NUMERIC_PRECISION", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG,
3949
 
   0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "", OPEN_FRM_ONLY),
3950
 
  ColumnInfo("NUMERIC_SCALE", MY_INT64_NUM_DECIMAL_DIGITS , DRIZZLE_TYPE_LONGLONG,
3951
 
   0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "", OPEN_FRM_ONLY),
3952
 
  ColumnInfo("CHARACTER_SET_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 1, "", OPEN_FRM_ONLY),
3953
 
  ColumnInfo("COLLATION_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 1, "Collation", OPEN_FRM_ONLY),
3954
 
  ColumnInfo("COLUMN_TYPE", 65535, DRIZZLE_TYPE_VARCHAR, 0, 0, "Type", OPEN_FRM_ONLY),
3955
 
  ColumnInfo("COLUMN_KEY", 3, DRIZZLE_TYPE_VARCHAR, 0, 0, "Key", OPEN_FRM_ONLY),
3956
 
  ColumnInfo("EXTRA", 27, DRIZZLE_TYPE_VARCHAR, 0, 0, "Extra", OPEN_FRM_ONLY),
3957
 
  ColumnInfo("PRIVILEGES", 80, DRIZZLE_TYPE_VARCHAR, 0, 0, "Privileges", OPEN_FRM_ONLY),
3958
 
  ColumnInfo("COLUMN_COMMENT", COLUMN_COMMENT_MAXLEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Comment", OPEN_FRM_ONLY),
3959
 
  ColumnInfo("STORAGE", 8, DRIZZLE_TYPE_VARCHAR, 0, 0, "Storage", OPEN_FRM_ONLY),
3960
 
  ColumnInfo("FORMAT", 8, DRIZZLE_TYPE_VARCHAR, 0, 0, "Format", OPEN_FRM_ONLY),
3961
 
  ColumnInfo()
3962
 
};
3963
 
 
3964
 
 
3965
 
ColumnInfo collation_fields_info[]=
3966
 
{
3967
 
  ColumnInfo("COLLATION_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, "Collation", SKIP_OPEN_TABLE),
3968
 
  ColumnInfo("CHARACTER_SET_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, "Charset",
3969
 
   SKIP_OPEN_TABLE),
3970
 
  ColumnInfo("ID", MY_INT32_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0, 0, "Id",
3971
 
   SKIP_OPEN_TABLE),
3972
 
  ColumnInfo("IS_DEFAULT", 3, DRIZZLE_TYPE_VARCHAR, 0, 0, "Default", SKIP_OPEN_TABLE),
3973
 
  ColumnInfo("IS_COMPILED", 3, DRIZZLE_TYPE_VARCHAR, 0, 0, "Compiled", SKIP_OPEN_TABLE),
3974
 
  ColumnInfo("SORTLEN", 3, DRIZZLE_TYPE_LONGLONG, 0, 0, "Sortlen", SKIP_OPEN_TABLE),
3975
 
  ColumnInfo()
3976
 
};
3977
 
 
3978
 
 
3979
 
 
3980
 
ColumnInfo coll_charset_app_fields_info[]=
3981
 
{
3982
 
  ColumnInfo("COLLATION_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, "", SKIP_OPEN_TABLE),
3983
 
  ColumnInfo("CHARACTER_SET_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, "", SKIP_OPEN_TABLE),
3984
 
  ColumnInfo()
3985
 
};
3986
 
 
3987
 
 
3988
 
ColumnInfo stat_fields_info[]=
3989
 
{
3990
 
  ColumnInfo("TABLE_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, "", OPEN_FRM_ONLY),
3991
 
  ColumnInfo("TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "", OPEN_FRM_ONLY),
3992
 
  ColumnInfo("TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Table", OPEN_FRM_ONLY),
3993
 
  ColumnInfo("NON_UNIQUE", 1, DRIZZLE_TYPE_LONGLONG, 0, 0, "Non_unique", OPEN_FRM_ONLY),
3994
 
  ColumnInfo("INDEX_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "", OPEN_FRM_ONLY),
3995
 
  ColumnInfo("INDEX_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Key_name",
3996
 
   OPEN_FRM_ONLY),
3997
 
  ColumnInfo("SEQ_IN_INDEX", 2, DRIZZLE_TYPE_LONGLONG, 0, 0, "Seq_in_index", OPEN_FRM_ONLY),
3998
 
  ColumnInfo("COLUMN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Column_name",
3999
 
   OPEN_FRM_ONLY),
4000
 
  ColumnInfo("COLLATION", 1, DRIZZLE_TYPE_VARCHAR, 0, 1, "Collation", OPEN_FRM_ONLY),
4001
 
  ColumnInfo("CARDINALITY", MY_INT64_NUM_DECIMAL_DIGITS, DRIZZLE_TYPE_LONGLONG, 0, 1,
4002
 
   "Cardinality", OPEN_FULL_TABLE),
4003
 
  ColumnInfo("SUB_PART", 3, DRIZZLE_TYPE_LONGLONG, 0, 1, "Sub_part", OPEN_FRM_ONLY),
4004
 
  ColumnInfo("PACKED", 10, DRIZZLE_TYPE_VARCHAR, 0, 1, "Packed", OPEN_FRM_ONLY),
4005
 
  ColumnInfo("NULLABLE", 3, DRIZZLE_TYPE_VARCHAR, 0, 0, "Null", OPEN_FRM_ONLY),
4006
 
  ColumnInfo("INDEX_TYPE", 16, DRIZZLE_TYPE_VARCHAR, 0, 0, "Index_type", OPEN_FULL_TABLE),
4007
 
  ColumnInfo("COMMENT", 16, DRIZZLE_TYPE_VARCHAR, 0, 1, "Comment", OPEN_FRM_ONLY),
4008
 
  ColumnInfo("INDEX_COMMENT", INDEX_COMMENT_MAXLEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Index_Comment", OPEN_FRM_ONLY),
4009
 
  ColumnInfo()
4010
 
};
4011
 
 
4012
 
 
4013
 
ColumnInfo table_constraints_fields_info[]=
4014
 
{
4015
 
  ColumnInfo("CONSTRAINT_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, "", OPEN_FULL_TABLE),
4016
 
  ColumnInfo("CONSTRAINT_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0,
4017
 
   "", OPEN_FULL_TABLE),
4018
 
  ColumnInfo("CONSTRAINT_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0,
4019
 
   "", OPEN_FULL_TABLE),
4020
 
  ColumnInfo("TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "", OPEN_FULL_TABLE),
4021
 
  ColumnInfo("TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "", OPEN_FULL_TABLE),
4022
 
  ColumnInfo("CONSTRAINT_TYPE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, 
4023
 
   "", OPEN_FULL_TABLE),
4024
 
  ColumnInfo()
4025
 
};
4026
 
 
4027
 
 
4028
 
ColumnInfo key_column_usage_fields_info[]=
4029
 
{
4030
 
  ColumnInfo("CONSTRAINT_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, "", OPEN_FULL_TABLE),
4031
 
  ColumnInfo("CONSTRAINT_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0,
4032
 
   "", OPEN_FULL_TABLE),
4033
 
  ColumnInfo("CONSTRAINT_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0,
4034
 
   "", OPEN_FULL_TABLE),
4035
 
  ColumnInfo("TABLE_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, "", OPEN_FULL_TABLE),
4036
 
  ColumnInfo("TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "", OPEN_FULL_TABLE),
4037
 
  ColumnInfo("TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0,
4038
 
  "", OPEN_FULL_TABLE),
4039
 
  ColumnInfo("COLUMN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "", OPEN_FULL_TABLE),
4040
 
  ColumnInfo("ORDINAL_POSITION", 10 ,DRIZZLE_TYPE_LONGLONG, 0, 0, "", OPEN_FULL_TABLE),
4041
 
  ColumnInfo("POSITION_IN_UNIQUE_CONSTRAINT", 10 ,DRIZZLE_TYPE_LONGLONG, 0, 1,
4042
 
   "", OPEN_FULL_TABLE),
4043
 
  ColumnInfo("REFERENCED_TABLE_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1,
4044
 
   "", OPEN_FULL_TABLE),
4045
 
  ColumnInfo("REFERENCED_TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1,
4046
 
   "", OPEN_FULL_TABLE),
4047
 
  ColumnInfo("REFERENCED_COLUMN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1,
4048
 
   "", OPEN_FULL_TABLE),
4049
 
  ColumnInfo()
4050
 
};
4051
 
 
4052
 
 
4053
 
ColumnInfo table_names_fields_info[]=
4054
 
{
4055
 
  ColumnInfo("TABLE_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, "", SKIP_OPEN_TABLE),
4056
 
  ColumnInfo("TABLE_SCHEMA",NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "", SKIP_OPEN_TABLE),
4057
 
  ColumnInfo("TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Tables_in_",
4058
 
   SKIP_OPEN_TABLE),
4059
 
  ColumnInfo("TABLE_TYPE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Table_type",
4060
 
   OPEN_FRM_ONLY),
4061
 
  ColumnInfo()
4062
 
};
4063
 
 
4064
 
 
4065
 
ColumnInfo open_tables_fields_info[]=
4066
 
{
4067
 
  ColumnInfo("Database", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Database",
4068
 
   SKIP_OPEN_TABLE),
4069
 
  ColumnInfo("Table",NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Table", SKIP_OPEN_TABLE),
4070
 
  ColumnInfo("In_use", 1, DRIZZLE_TYPE_LONGLONG, 0, 0, "In_use", SKIP_OPEN_TABLE),
4071
 
  ColumnInfo("Name_locked", 4, DRIZZLE_TYPE_LONGLONG, 0, 0, "Name_locked", SKIP_OPEN_TABLE),
4072
 
  ColumnInfo()
4073
 
};
4074
 
 
4075
 
 
4076
3028
ColumnInfo variables_fields_info[]=
4077
3029
{
4078
3030
  ColumnInfo("VARIABLE_NAME", 64, DRIZZLE_TYPE_VARCHAR, 0, 0, "Variable_name",
4082
3034
};
4083
3035
 
4084
3036
 
4085
 
ColumnInfo plugin_fields_info[]=
4086
 
{
4087
 
  ColumnInfo("PLUGIN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Name",
4088
 
   SKIP_OPEN_TABLE),
4089
 
  ColumnInfo("PLUGIN_VERSION", 20, DRIZZLE_TYPE_VARCHAR, 0, 0, "", SKIP_OPEN_TABLE),
4090
 
  ColumnInfo("PLUGIN_STATUS", 10, DRIZZLE_TYPE_VARCHAR, 0, 0, "Status", SKIP_OPEN_TABLE),
4091
 
  ColumnInfo("PLUGIN_AUTHOR", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, "", SKIP_OPEN_TABLE),
4092
 
  ColumnInfo("PLUGIN_DESCRIPTION", 65535, DRIZZLE_TYPE_VARCHAR, 0, 1, "", SKIP_OPEN_TABLE),
4093
 
  ColumnInfo("PLUGIN_LICENSE", 80, DRIZZLE_TYPE_VARCHAR, 0, 1, "License", SKIP_OPEN_TABLE),
4094
 
  ColumnInfo()
4095
 
};
4096
 
 
4097
 
ColumnInfo referential_constraints_fields_info[]=
4098
 
{
4099
 
  ColumnInfo("CONSTRAINT_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1, "", OPEN_FULL_TABLE),
4100
 
  ColumnInfo("CONSTRAINT_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0,
4101
 
   "", OPEN_FULL_TABLE),
4102
 
  ColumnInfo("CONSTRAINT_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0,
4103
 
   "", OPEN_FULL_TABLE),
4104
 
  ColumnInfo("UNIQUE_CONSTRAINT_CATALOG", FN_REFLEN, DRIZZLE_TYPE_VARCHAR, 0, 1,
4105
 
   "", OPEN_FULL_TABLE),
4106
 
  ColumnInfo("UNIQUE_CONSTRAINT_SCHEMA", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0,
4107
 
   "", OPEN_FULL_TABLE),
4108
 
  ColumnInfo("UNIQUE_CONSTRAINT_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0,
4109
 
   MY_I_S_MAYBE_NULL, "", OPEN_FULL_TABLE),
4110
 
  ColumnInfo("MATCH_OPTION", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "", OPEN_FULL_TABLE),
4111
 
  ColumnInfo("UPDATE_RULE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "", OPEN_FULL_TABLE),
4112
 
  ColumnInfo("DELETE_RULE", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "", OPEN_FULL_TABLE),
4113
 
  ColumnInfo("TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "", OPEN_FULL_TABLE),
4114
 
  ColumnInfo("REFERENCED_TABLE_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0,
4115
 
   "", OPEN_FULL_TABLE),
4116
 
  ColumnInfo()
4117
 
};
4118
 
 
4119
 
static ColumnsISMethods columns_methods;
4120
3037
static StatusISMethods status_methods;
4121
3038
static VariablesISMethods variables_methods;
4122
 
static KeyColUsageISMethods key_col_usage_methods;
4123
 
static OpenTablesISMethods open_tables_methods;
4124
 
static PluginsISMethods plugins_methods;
4125
 
static RefConstraintsISMethods ref_constraints_methods;
4126
 
static SchemataISMethods schemata_methods;
4127
 
static StatsISMethods stats_methods;
4128
 
static TablesISMethods tables_methods;
4129
 
static TabConstraintsISMethods tab_constraints_methods;
4130
 
static TabNamesISMethods tab_names_methods;
4131
3039
 
4132
 
static InfoSchemaTable columns_table("COLUMNS",
4133
 
                                     columns_fields_info,
4134
 
                                     1, 2, false, true, OPTIMIZE_I_S_TABLE,
4135
 
                                     &columns_methods);
4136
3040
static InfoSchemaTable global_stat_table("GLOBAL_STATUS",
4137
3041
                                         variables_fields_info,
4138
3042
                                         -1, -1, false, false, 0,
4141
3045
                                        variables_fields_info,
4142
3046
                                        -1, -1, false, false, 0,
4143
3047
                                        &variables_methods);
4144
 
static InfoSchemaTable key_col_usage_table("KEY_COLUMN_USAGE",
4145
 
                                           key_column_usage_fields_info,
4146
 
                                           4, 5, false, true, OPEN_TABLE_ONLY,
4147
 
                                           &key_col_usage_methods);
4148
 
static InfoSchemaTable open_tab_table("OPEN_TABLES",
4149
 
                                      open_tables_fields_info,
4150
 
                                      -1, -1, true, false, 0,
4151
 
                                      &open_tables_methods);
4152
 
static InfoSchemaTable plugins_table("PLUGINS",
4153
 
                                     plugin_fields_info,
4154
 
                                     -1, -1, false, false, 0,
4155
 
                                     &plugins_methods);
4156
 
static InfoSchemaTable ref_constrain_table("REFERENTIAL_CONSTRAINTS",
4157
 
                                           referential_constraints_fields_info,
4158
 
                                           1, 9, false, true, OPEN_TABLE_ONLY,
4159
 
                                           &ref_constraints_methods);
4160
 
static InfoSchemaTable schemata_table("SCHEMATA",
4161
 
                                      schema_fields_info,
4162
 
                                      1, -1, false, false, 0,
4163
 
                                      &schemata_methods);
4164
3048
static InfoSchemaTable sess_stat_table("SESSION_STATUS",
4165
3049
                                       variables_fields_info,
4166
3050
                                       -1, -1, false, false, 0,
4169
3053
                                      variables_fields_info,
4170
3054
                                      -1, -1, false, false, 0,
4171
3055
                                      &variables_methods);
4172
 
static InfoSchemaTable stats_table("STATISTICS",
4173
 
                                   stat_fields_info,
4174
 
                                   1, 2, false, true,
4175
 
                                   OPEN_TABLE_ONLY|OPTIMIZE_I_S_TABLE,
4176
 
                                   &stats_methods);
4177
3056
static InfoSchemaTable status_table("STATUS",
4178
3057
                                    variables_fields_info,
4179
3058
                                    -1, -1, true, false, 0,
4180
3059
                                    &status_methods);
4181
 
static InfoSchemaTable tables_table("TABLES",
4182
 
                                    tables_fields_info,
4183
 
                                    1, 2, false, true, OPTIMIZE_I_S_TABLE,
4184
 
                                    &tables_methods);
4185
 
static InfoSchemaTable tab_constrain_table("TABLE_CONSTRAINTS",
4186
 
                                           table_constraints_fields_info,
4187
 
                                           3, 4, false, true, OPEN_TABLE_ONLY,
4188
 
                                           &tab_constraints_methods);
4189
 
static InfoSchemaTable tab_names_table("TABLE_NAMES",
4190
 
                                       table_names_fields_info,
4191
 
                                       1, 2, true, true, 0,
4192
 
                                       &tab_names_methods);
4193
3060
static InfoSchemaTable var_table("VARIABLES",
4194
3061
                                 variables_fields_info,
4195
3062
                                 -1, -1, true, false, 0,
4196
3063
                                 &variables_methods);
4197
3064
 
4198
 
/**
4199
 
 * @note
4200
 
 *   Make sure that the order of schema_tables and enum_schema_tables are the same.
4201
 
 */
4202
 
 
4203
3065
InfoSchemaTable schema_tables[]=
4204
3066
{
4205
 
  columns_table,
4206
3067
  global_stat_table,
4207
3068
  global_var_table,
4208
 
  key_col_usage_table,
4209
 
  open_tab_table,
4210
 
  plugins_table,
4211
 
  ref_constrain_table,
4212
 
  schemata_table,
4213
3069
  sess_stat_table,
4214
3070
  sess_var_table,
4215
 
  stats_table,
4216
3071
  status_table,
4217
 
  tables_table,
4218
 
  tab_constrain_table,
4219
 
  tab_names_table,
4220
3072
  var_table,
4221
3073
  InfoSchemaTable()
4222
3074
};