~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_show.cc

  • Committer: Mats Kindahl
  • Date: 2008-08-25 19:04:45 UTC
  • mfrom: (371 trunk)
  • mto: (489.1.2 codestyle)
  • mto: This revision was merged to the branch mainline in revision 372.
  • Revision ID: mats@mysql.com-20080825190445-xsby29pqsfrapuxd
Merging lp:~mkindahl/stdize-code with lp:drizzle

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include <drizzled/sql_show.h>
21
21
#include "repl_failsafe.h"
22
22
#include <mysys/my_dir.h>
 
23
#include <libdrizzle/gettext.h>
23
24
 
24
25
inline const char *
25
26
str_or_nil(const char *str)
30
31
/* Match the values of enum ha_choice */
31
32
static const char *ha_choice_values[] = {"", "0", "1"};
32
33
 
33
 
static void store_key_options(THD *thd, String *packet, TABLE *table,
 
34
static void store_key_options(THD *thd, String *packet, Table *table,
34
35
                              KEY *key_info);
35
36
 
36
37
 
88
89
static bool show_plugins(THD *thd, plugin_ref plugin,
89
90
                            void *arg)
90
91
{
91
 
  TABLE *table= (TABLE*) arg;
 
92
  Table *table= (Table*) arg;
92
93
  struct st_mysql_plugin *plug= plugin_decl(plugin);
93
94
  struct st_plugin_dl *plugin_dl= plugin_dlib(plugin);
94
95
  const CHARSET_INFO * const cs= system_charset_info;
171
172
}
172
173
 
173
174
 
174
 
int fill_plugins(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((unused)))
 
175
int fill_plugins(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
175
176
{
176
 
  TABLE *table= tables->table;
 
177
  Table *table= tables->table;
177
178
 
178
 
  if (plugin_foreach_with_mask(thd, show_plugins, MYSQL_ANY_PLUGIN,
 
179
  if (plugin_foreach_with_mask(thd, show_plugins, DRIZZLE_ANY_PLUGIN,
179
180
                               ~PLUGIN_IS_FREED, table))
180
181
    return(1);
181
182
 
190
191
    find_files()
191
192
    thd                 thread handler
192
193
    files               put found files in this list
193
 
    db                  database name to set in TABLE_LIST structure
 
194
    db                  database name to set in TableList structure
194
195
    path                path to database
195
196
    wild                filter for found files
196
197
    dir                 read databases in path if true, read .frm files in
213
214
  FILEINFO *file;
214
215
  LEX_STRING *file_name= 0;
215
216
  uint file_name_len;
216
 
  TABLE_LIST table_list;
 
217
  TableList table_list;
217
218
 
218
219
  if (wild && !wild[0])
219
220
    wild=0;
302
303
 
303
304
 
304
305
bool
305
 
mysqld_show_create(THD *thd, TABLE_LIST *table_list)
 
306
mysqld_show_create(THD *thd, TableList *table_list)
306
307
{
307
308
  Protocol *protocol= thd->protocol;
308
309
  char buff[2048];
400
401
****************************************************************************/
401
402
 
402
403
void
403
 
mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild)
 
404
mysqld_list_fields(THD *thd, TableList *table_list, const char *wild)
404
405
{
405
 
  TABLE *table;
 
406
  Table *table;
406
407
 
407
408
  if (open_normal_and_derived_tables(thd, table_list, 0))
408
409
    return;
548
549
      !require_quotes(name, length) &&
549
550
      !(thd->options & OPTION_QUOTE_SHOW_CREATE))
550
551
    return EOF;
551
 
  return '"';
 
552
  return '`';
552
553
}
553
554
 
554
555
 
649
650
    0       OK
650
651
 */
651
652
 
652
 
int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
 
653
int store_create_info(THD *thd, TableList *table_list, String *packet,
653
654
                      HA_CREATE_INFO *create_info_arg)
654
655
{
655
656
  List<Item> field_list;
660
661
  Field **ptr,*field;
661
662
  uint primary_key;
662
663
  KEY *key_info;
663
 
  TABLE *table= table_list->table;
 
664
  Table *table= table_list->table;
664
665
  handler *file= table->file;
665
666
  TABLE_SHARE *share= table->s;
666
667
  HA_CREATE_INFO create_info;
694
695
    We have to restore the read_set if we are called from insert in case
695
696
    of row based replication.
696
697
  */
697
 
  old_map= tmp_use_all_columns(table, table->read_set);
 
698
  old_map= table->use_all_columns(table->read_set);
698
699
 
699
700
  for (ptr=table->field ; (field= *ptr); ptr++)
700
701
  {
753
754
      if (column_format)
754
755
      {
755
756
        packet->append(STRING_WITH_LEN(" /*!"));
756
 
        packet->append(STRING_WITH_LEN(MYSQL_VERSION_TABLESPACE_IN_FRM_STR));
 
757
        packet->append(STRING_WITH_LEN(DRIZZLE_VERSION_TABLESPACE_IN_FRM_STR));
757
758
        packet->append(STRING_WITH_LEN(" COLUMN_FORMAT"));
758
759
        if (column_format == COLUMN_FORMAT_TYPE_FIXED)
759
760
          packet->append(STRING_WITH_LEN(" FIXED */"));
983
984
    append_directory(thd, packet, "DATA",  create_info.data_file_name);
984
985
    append_directory(thd, packet, "INDEX", create_info.index_file_name);
985
986
  }
986
 
  tmp_restore_column_map(table->read_set, old_map);
 
987
  table->restore_column_map(old_map);
987
988
  return(0);
988
989
}
989
990
 
1056
1057
}
1057
1058
 
1058
1059
static void store_key_options(THD *thd __attribute__((unused)),
1059
 
                              String *packet, TABLE *table,
 
1060
                              String *packet, Table *table,
1060
1061
                              KEY *key_info)
1061
1062
{
1062
1063
  char *end, buff[32];
1216
1217
  return;
1217
1218
}
1218
1219
 
1219
 
int fill_schema_processlist(THD* thd, TABLE_LIST* tables,
 
1220
int fill_schema_processlist(THD* thd, TableList* tables,
1220
1221
                            COND* cond __attribute__((unused)))
1221
1222
{
1222
 
  TABLE *table= tables->table;
 
1223
  Table *table= tables->table;
1223
1224
  const CHARSET_INFO * const cs= system_charset_info;
1224
1225
  char *user;
1225
1226
  time_t now= my_time(0);
1492
1493
                              SHOW_VAR *variables,
1493
1494
                              enum enum_var_type value_type,
1494
1495
                              struct system_status_var *status_var,
1495
 
                              const char *prefix, TABLE *table,
 
1496
                              const char *prefix, Table *table,
1496
1497
                              bool ucase_names)
1497
1498
{
1498
1499
  MY_ALIGNED_BYTE_ARRAY(buff_data, SHOW_VAR_FUNC_BUFF_SIZE, long);
1688
1689
    1                     error
1689
1690
*/
1690
1691
 
1691
 
bool schema_table_store_record(THD *thd, TABLE *table)
 
1692
bool schema_table_store_record(THD *thd, Table *table)
1692
1693
{
1693
1694
  int error;
1694
1695
  if ((error= table->file->ha_write_row(table->record[0])))
1734
1735
*/
1735
1736
 
1736
1737
bool get_lookup_value(THD *thd, Item_func *item_func,
1737
 
                      TABLE_LIST *table, 
 
1738
                      TableList *table, 
1738
1739
                      LOOKUP_FIELD_VALUES *lookup_field_vals)
1739
1740
{
1740
1741
  ST_SCHEMA_TABLE *schema_table= table->schema_table;
1816
1817
    1             error, there can be no matching records for the condition
1817
1818
*/
1818
1819
 
1819
 
bool calc_lookup_values_from_cond(THD *thd, COND *cond, TABLE_LIST *table,
 
1820
bool calc_lookup_values_from_cond(THD *thd, COND *cond, TableList *table,
1820
1821
                                  LOOKUP_FIELD_VALUES *lookup_field_vals)
1821
1822
{
1822
1823
  if (!cond)
1851
1852
}
1852
1853
 
1853
1854
 
1854
 
bool uses_only_table_name_fields(Item *item, TABLE_LIST *table)
 
1855
bool uses_only_table_name_fields(Item *item, TableList *table)
1855
1856
{
1856
1857
  if (item->type() == Item::FUNC_ITEM)
1857
1858
  {
1891
1892
}
1892
1893
 
1893
1894
 
1894
 
static COND * make_cond_for_info_schema(COND *cond, TABLE_LIST *table)
 
1895
static COND * make_cond_for_info_schema(COND *cond, TableList *table)
1895
1896
{
1896
1897
  if (!cond)
1897
1898
    return (COND*) 0;
1965
1966
    1             error, there can be no matching records for the condition
1966
1967
*/
1967
1968
 
1968
 
bool get_lookup_field_values(THD *thd, COND *cond, TABLE_LIST *tables,
 
1969
bool get_lookup_field_values(THD *thd, COND *cond, TableList *tables,
1969
1970
                             LOOKUP_FIELD_VALUES *lookup_field_values)
1970
1971
{
1971
1972
  LEX *lex= thd->lex;
2159
2160
  add_data.files= files;
2160
2161
  add_data.wild= wild;
2161
2162
  if (plugin_foreach(thd, add_schema_table,
2162
 
                     MYSQL_INFORMATION_SCHEMA_PLUGIN, &add_data))
 
2163
                     DRIZZLE_INFORMATION_SCHEMA_PLUGIN, &add_data))
2163
2164
    return(1);
2164
2165
 
2165
2166
  return(0);
2246
2247
  @brief          Fill I_S table for SHOW COLUMNS|INDEX commands
2247
2248
 
2248
2249
  @param[in]      thd                      thread handler
2249
 
  @param[in]      tables                   TABLE_LIST for I_S table
 
2250
  @param[in]      tables                   TableList for I_S table
2250
2251
  @param[in]      schema_table             pointer to I_S structure
2251
2252
  @param[in]      open_tables_state_backup pointer to Open_tables_state object
2252
2253
                                           which is used to save|restore original
2259
2260
*/
2260
2261
 
2261
2262
static int 
2262
 
fill_schema_show_cols_or_idxs(THD *thd, TABLE_LIST *tables,
 
2263
fill_schema_show_cols_or_idxs(THD *thd, TableList *tables,
2263
2264
                              ST_SCHEMA_TABLE *schema_table,
2264
2265
                              Open_tables_state *open_tables_state_backup)
2265
2266
{
2267
2268
  bool res;
2268
2269
  LEX_STRING tmp_lex_string, tmp_lex_string1, *db_name, *table_name;
2269
2270
  enum_sql_command save_sql_command= lex->sql_command;
2270
 
  TABLE_LIST *show_table_list= (TABLE_LIST*) tables->schema_select_lex->
 
2271
  TableList *show_table_list= (TableList*) tables->schema_select_lex->
2271
2272
    table_list.first;
2272
 
  TABLE *table= tables->table;
 
2273
  Table *table= tables->table;
2273
2274
  int error= 1;
2274
2275
 
2275
2276
  lex->all_selects_list= tables->schema_select_lex;
2288
2289
  */
2289
2290
  lex->sql_command= SQLCOM_SHOW_FIELDS;
2290
2291
  res= open_normal_and_derived_tables(thd, show_table_list,
2291
 
                                      MYSQL_LOCK_IGNORE_FLUSH);
 
2292
                                      DRIZZLE_LOCK_IGNORE_FLUSH);
2292
2293
  lex->sql_command= save_sql_command;
2293
2294
  /*
2294
2295
    get_all_tables() returns 1 on failure and 0 on success thus
2317
2318
 
2318
2319
 
2319
2320
/**
2320
 
  @brief          Fill I_S table for SHOW TABLE NAMES commands
 
2321
  @brief          Fill I_S table for SHOW Table NAMES commands
2321
2322
 
2322
2323
  @param[in]      thd                      thread handler
2323
 
  @param[in]      table                    TABLE struct for I_S table
 
2324
  @param[in]      table                    Table struct for I_S table
2324
2325
  @param[in]      db_name                  database name
2325
2326
  @param[in]      table_name               table name
2326
2327
  @param[in]      with_i_schema            I_S table if true
2330
2331
    @retval       1           error
2331
2332
*/
2332
2333
 
2333
 
static int fill_schema_table_names(THD *thd, TABLE *table,
 
2334
static int fill_schema_table_names(THD *thd, Table *table,
2334
2335
                                   LEX_STRING *db_name, LEX_STRING *table_name,
2335
2336
                                   bool with_i_schema)
2336
2337
{
2345
2346
    char path[FN_REFLEN];
2346
2347
    (void) build_table_filename(path, sizeof(path), db_name->str, 
2347
2348
                                table_name->str, reg_ext, 0);
2348
 
    switch (mysql_frm_type(thd, path, &not_used)) {
2349
 
    case FRMTYPE_ERROR:
 
2349
    if (mysql_frm_type(thd, path, &not_used)) 
 
2350
    {
 
2351
      table->field[3]->store(STRING_WITH_LEN("BASE Table"),
 
2352
                             system_charset_info);
 
2353
    }
 
2354
    else
 
2355
    {
2350
2356
      table->field[3]->store(STRING_WITH_LEN("ERROR"),
2351
2357
                             system_charset_info);
2352
 
      break;
2353
 
    case FRMTYPE_TABLE:
2354
 
      table->field[3]->store(STRING_WITH_LEN("BASE TABLE"),
2355
 
                             system_charset_info);
2356
 
      break;
2357
 
    default:
2358
 
      assert(0);
2359
2358
    }
 
2359
 
2360
2360
    if (thd->is_error() && thd->main_da.sql_errno() == ER_NO_SUCH_TABLE)
2361
2361
    {
2362
2362
      thd->clear_error();
2385
2385
    @retval       SKIP_OPEN_TABLE | OPEN_FRM_ONLY | OPEN_FULL_TABLE
2386
2386
*/
2387
2387
 
2388
 
static uint get_table_open_method(TABLE_LIST *tables,
 
2388
static uint get_table_open_method(TableList *tables,
2389
2389
                                  ST_SCHEMA_TABLE *schema_table,
2390
2390
                                  enum enum_schema_tables schema_table_idx __attribute__((unused)))
2391
2391
{
2413
2413
  @brief          Fill I_S table with data from FRM file only
2414
2414
 
2415
2415
  @param[in]      thd                      thread handler
2416
 
  @param[in]      table                    TABLE struct for I_S table
 
2416
  @param[in]      table                    Table struct for I_S table
2417
2417
  @param[in]      schema_table             I_S table struct
2418
2418
  @param[in]      db_name                  database name
2419
2419
  @param[in]      table_name               table name
2426
2426
                              open_tables function for this table
2427
2427
*/
2428
2428
 
2429
 
static int fill_schema_table_from_frm(THD *thd,TABLE_LIST *tables,
 
2429
static int fill_schema_table_from_frm(THD *thd,TableList *tables,
2430
2430
                                      ST_SCHEMA_TABLE *schema_table,
2431
2431
                                      LEX_STRING *db_name,
2432
2432
                                      LEX_STRING *table_name,
2433
2433
                                      enum enum_schema_tables schema_table_idx __attribute__((unused)))
2434
2434
{
2435
 
  TABLE *table= tables->table;
 
2435
  Table *table= tables->table;
2436
2436
  TABLE_SHARE *share;
2437
 
  TABLE tbl;
2438
 
  TABLE_LIST table_list;
 
2437
  Table tbl;
 
2438
  TableList table_list;
2439
2439
  uint res= 0;
2440
2440
  int error;
2441
2441
  char key[MAX_DBKEY_LENGTH];
2442
2442
  uint key_length;
2443
2443
 
2444
 
  memset(&table_list, 0, sizeof(TABLE_LIST));
2445
 
  memset(&tbl, 0, sizeof(TABLE));
 
2444
  memset(&table_list, 0, sizeof(TableList));
 
2445
  memset(&tbl, 0, sizeof(Table));
2446
2446
 
2447
2447
  table_list.table_name= table_name->str;
2448
2448
  table_list.db= db_name->str;
2450
2450
  key_length= create_table_def_key(thd, key, &table_list, 0);
2451
2451
  pthread_mutex_lock(&LOCK_open);
2452
2452
  share= get_table_share(thd, &table_list, key,
2453
 
                         key_length, OPEN_VIEW, &error);
 
2453
                         key_length, 0, &error);
2454
2454
  if (!share)
2455
2455
  {
2456
2456
    res= 0;
2493
2493
    @retval       1                        error
2494
2494
*/
2495
2495
 
2496
 
int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
 
2496
int get_all_tables(THD *thd, TableList *tables, COND *cond)
2497
2497
{
2498
2498
  LEX *lex= thd->lex;
2499
 
  TABLE *table= tables->table;
 
2499
  Table *table= tables->table;
2500
2500
  SELECT_LEX *old_all_select_lex= lex->all_selects_list;
2501
2501
  enum_sql_command save_sql_command= lex->sql_command;
2502
2502
  SELECT_LEX *lsel= tables->schema_select_lex;
2621
2621
            continue;
2622
2622
          }
2623
2623
 
2624
 
          /* SHOW TABLE NAMES command */
 
2624
          /* SHOW Table NAMES command */
2625
2625
          if (schema_table_idx == SCH_TABLE_NAMES)
2626
2626
          {
2627
2627
            if (fill_schema_table_names(thd, tables->table, db_name,
2652
2652
              goto err;
2653
2653
            if (make_table_list(thd, &sel, db_name, table_name))
2654
2654
              goto err;
2655
 
            TABLE_LIST *show_table_list= (TABLE_LIST*) sel.table_list.first;
 
2655
            TableList *show_table_list= (TableList*) sel.table_list.first;
2656
2656
            lex->all_selects_list= &sel;
2657
2657
            lex->derived_tables= 0;
2658
2658
            lex->sql_command= SQLCOM_SHOW_FIELDS;
2659
2659
            show_table_list->i_s_requested_object=
2660
2660
              schema_table->i_s_requested_object;
2661
2661
            res= open_normal_and_derived_tables(thd, show_table_list,
2662
 
                                                MYSQL_LOCK_IGNORE_FLUSH);
 
2662
                                                DRIZZLE_LOCK_IGNORE_FLUSH);
2663
2663
            lex->sql_command= save_sql_command;
2664
2664
            /*
2665
2665
              XXX:  show_table_list has a flag i_is_requested,
2723
2723
}
2724
2724
 
2725
2725
 
2726
 
bool store_schema_shemata(THD* thd, TABLE *table, LEX_STRING *db_name,
 
2726
bool store_schema_shemata(THD* thd, Table *table, LEX_STRING *db_name,
2727
2727
                          const CHARSET_INFO * const cs)
2728
2728
{
2729
2729
  restore_record(table, s->default_values);
2734
2734
}
2735
2735
 
2736
2736
 
2737
 
int fill_schema_schemata(THD *thd, TABLE_LIST *tables, COND *cond)
 
2737
int fill_schema_schemata(THD *thd, TableList *tables, COND *cond)
2738
2738
{
2739
2739
  /*
2740
2740
    TODO: fill_schema_shemata() is called when new client is connected.
2746
2746
  LEX_STRING *db_name;
2747
2747
  bool with_i_schema;
2748
2748
  HA_CREATE_INFO create;
2749
 
  TABLE *table= tables->table;
 
2749
  Table *table= tables->table;
2750
2750
 
2751
2751
  if (get_lookup_field_values(thd, cond, tables, &lookup_field_vals))
2752
2752
    return(0);
2794
2794
}
2795
2795
 
2796
2796
 
2797
 
static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
2798
 
                                    TABLE *table, bool res,
 
2797
static int get_schema_tables_record(THD *thd, TableList *tables,
 
2798
                                    Table *table, bool res,
2799
2799
                                    LEX_STRING *db_name,
2800
2800
                                    LEX_STRING *table_name)
2801
2801
{
2815
2815
    if (tables->schema_table)
2816
2816
      table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"), cs);
2817
2817
    else
2818
 
      table->field[3]->store(STRING_WITH_LEN("BASE TABLE"), cs);
 
2818
      table->field[3]->store(STRING_WITH_LEN("BASE Table"), cs);
2819
2819
    table->field[20]->store(error, strlen(error), cs);
2820
2820
    thd->clear_error();
2821
2821
  }
2822
2822
  else
2823
2823
  {
2824
2824
    char option_buff[400],*ptr;
2825
 
    TABLE *show_table= tables->table;
 
2825
    Table *show_table= tables->table;
2826
2826
    TABLE_SHARE *share= show_table->s;
2827
2827
    handler *file= show_table->file;
2828
2828
    handlerton *tmp_db_type= share->db_type();
2831
2831
    else if (share->tmp_table)
2832
2832
      table->field[3]->store(STRING_WITH_LEN("LOCAL TEMPORARY"), cs);
2833
2833
    else
2834
 
      table->field[3]->store(STRING_WITH_LEN("BASE TABLE"), cs);
 
2834
      table->field[3]->store(STRING_WITH_LEN("BASE Table"), cs);
2835
2835
 
2836
2836
    for (int i= 4; i < 20; i++)
2837
2837
    {
2998
2998
  @return         void
2999
2999
*/
3000
3000
 
3001
 
void store_column_type(TABLE *table, Field *field, const CHARSET_INFO * const cs,
 
3001
void store_column_type(Table *table, Field *field, const CHARSET_INFO * const cs,
3002
3002
                       uint offset)
3003
3003
{
3004
3004
  bool is_blob;
3086
3086
}
3087
3087
 
3088
3088
 
3089
 
static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
3090
 
                                    TABLE *table, bool res,
 
3089
static int get_schema_column_record(THD *thd, TableList *tables,
 
3090
                                    Table *table, bool res,
3091
3091
                                    LEX_STRING *db_name,
3092
3092
                                    LEX_STRING *table_name)
3093
3093
{
3094
3094
  LEX *lex= thd->lex;
3095
3095
  const char *wild= lex->wild ? lex->wild->ptr() : NullS;
3096
3096
  const CHARSET_INFO * const cs= system_charset_info;
3097
 
  TABLE *show_table;
 
3097
  Table *show_table;
3098
3098
  TABLE_SHARE *show_table_share;
3099
3099
  Field **ptr, *field, *timestamp_field;
3100
3100
  int count;
3219
3219
 
3220
3220
 
3221
3221
 
3222
 
int fill_schema_charsets(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((unused)))
 
3222
int fill_schema_charsets(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
3223
3223
{
3224
3224
  CHARSET_INFO **cs;
3225
3225
  const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
3226
 
  TABLE *table= tables->table;
 
3226
  Table *table= tables->table;
3227
3227
  const CHARSET_INFO * const scs= system_charset_info;
3228
3228
 
3229
3229
  for (cs= all_charsets ; cs < all_charsets+255 ; cs++)
3250
3250
}
3251
3251
 
3252
3252
 
3253
 
int fill_schema_collation(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((unused)))
 
3253
int fill_schema_collation(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
3254
3254
{
3255
3255
  CHARSET_INFO **cs;
3256
3256
  const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
3257
 
  TABLE *table= tables->table;
 
3257
  Table *table= tables->table;
3258
3258
  const CHARSET_INFO * const scs= system_charset_info;
3259
3259
  for (cs= all_charsets ; cs < all_charsets+255 ; cs++ )
3260
3260
  {
3292
3292
}
3293
3293
 
3294
3294
 
3295
 
int fill_schema_coll_charset_app(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((unused)))
 
3295
int fill_schema_coll_charset_app(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
3296
3296
{
3297
3297
  CHARSET_INFO **cs;
3298
 
  TABLE *table= tables->table;
 
3298
  Table *table= tables->table;
3299
3299
  const CHARSET_INFO * const scs= system_charset_info;
3300
3300
  for (cs= all_charsets ; cs < all_charsets+255 ; cs++ )
3301
3301
  {
3321
3321
}
3322
3322
 
3323
3323
 
3324
 
static int get_schema_stat_record(THD *thd, TABLE_LIST *tables,
3325
 
                                  TABLE *table, bool res,
 
3324
static int get_schema_stat_record(THD *thd, TableList *tables,
 
3325
                                  Table *table, bool res,
3326
3326
                                  LEX_STRING *db_name,
3327
3327
                                  LEX_STRING *table_name)
3328
3328
{
3345
3345
  }
3346
3346
  else
3347
3347
  {
3348
 
    TABLE *show_table= tables->table;
 
3348
    Table *show_table= tables->table;
3349
3349
    KEY *key_info=show_table->s->key_info;
3350
3350
    if (show_table->file)
3351
3351
      show_table->file->info(HA_STATUS_VARIABLE |
3418
3418
}
3419
3419
 
3420
3420
 
3421
 
bool store_constraints(THD *thd, TABLE *table, LEX_STRING *db_name,
 
3421
bool store_constraints(THD *thd, Table *table, LEX_STRING *db_name,
3422
3422
                       LEX_STRING *table_name, const char *key_name,
3423
3423
                       uint key_len, const char *con_type, uint con_len)
3424
3424
{
3433
3433
}
3434
3434
 
3435
3435
 
3436
 
static int get_schema_constraints_record(THD *thd, TABLE_LIST *tables,
3437
 
                                         TABLE *table, bool res,
 
3436
static int get_schema_constraints_record(THD *thd, TableList *tables,
 
3437
                                         Table *table, bool res,
3438
3438
                                         LEX_STRING *db_name,
3439
3439
                                         LEX_STRING *table_name)
3440
3440
{
3449
3449
  else
3450
3450
  {
3451
3451
    List<FOREIGN_KEY_INFO> f_key_list;
3452
 
    TABLE *show_table= tables->table;
 
3452
    Table *show_table= tables->table;
3453
3453
    KEY *key_info=show_table->key_info;
3454
3454
    uint primary_key= show_table->s->primary_key;
3455
3455
    show_table->file->info(HA_STATUS_VARIABLE | 
3492
3492
}
3493
3493
 
3494
3494
 
3495
 
void store_key_column_usage(TABLE *table, LEX_STRING *db_name,
 
3495
void store_key_column_usage(Table *table, LEX_STRING *db_name,
3496
3496
                            LEX_STRING *table_name, const char *key_name,
3497
3497
                            uint key_len, const char *con_type, uint con_len,
3498
3498
                            int64_t idx)
3508
3508
 
3509
3509
 
3510
3510
static int get_schema_key_column_usage_record(THD *thd,
3511
 
                                              TABLE_LIST *tables,
3512
 
                                              TABLE *table, bool res,
 
3511
                                              TableList *tables,
 
3512
                                              Table *table, bool res,
3513
3513
                                              LEX_STRING *db_name,
3514
3514
                                              LEX_STRING *table_name)
3515
3515
{
3524
3524
  else
3525
3525
  {
3526
3526
    List<FOREIGN_KEY_INFO> f_key_list;
3527
 
    TABLE *show_table= tables->table;
 
3527
    Table *show_table= tables->table;
3528
3528
    KEY *key_info=show_table->key_info;
3529
3529
    uint primary_key= show_table->s->primary_key;
3530
3530
    show_table->file->info(HA_STATUS_VARIABLE | 
3596
3596
}
3597
3597
 
3598
3598
 
3599
 
int fill_open_tables(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((unused)))
 
3599
int fill_open_tables(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
3600
3600
{
3601
3601
  const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
3602
 
  TABLE *table= tables->table;
 
3602
  Table *table= tables->table;
3603
3603
  const CHARSET_INFO * const cs= system_charset_info;
3604
 
  OPEN_TABLE_LIST *open_list;
 
3604
  OPEN_TableList *open_list;
3605
3605
  if (!(open_list=list_open_tables(thd,thd->lex->select_lex.db, wild))
3606
3606
            && thd->is_fatal_error)
3607
3607
    return(1);
3620
3620
}
3621
3621
 
3622
3622
 
3623
 
int fill_variables(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((unused)))
 
3623
int fill_variables(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
3624
3624
{
3625
3625
  int res= 0;
3626
3626
  LEX *lex= thd->lex;
3643
3643
}
3644
3644
 
3645
3645
 
3646
 
int fill_status(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((unused)))
 
3646
int fill_status(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
3647
3647
{
3648
3648
  LEX *lex= thd->lex;
3649
3649
  const char *wild= lex->wild ? lex->wild->ptr() : NullS;
3704
3704
*/
3705
3705
 
3706
3706
static int
3707
 
get_referential_constraints_record(THD *thd, TABLE_LIST *tables,
3708
 
                                   TABLE *table, bool res,
 
3707
get_referential_constraints_record(THD *thd, TableList *tables,
 
3708
                                   Table *table, bool res,
3709
3709
                                   LEX_STRING *db_name, LEX_STRING *table_name)
3710
3710
{
3711
3711
  const CHARSET_INFO * const cs= system_charset_info;
3721
3721
 
3722
3722
  {
3723
3723
    List<FOREIGN_KEY_INFO> f_key_list;
3724
 
    TABLE *show_table= tables->table;
 
3724
    Table *show_table= tables->table;
3725
3725
    show_table->file->info(HA_STATUS_VARIABLE | 
3726
3726
                           HA_STATUS_NO_LOCK |
3727
3727
                           HA_STATUS_TIME);
3828
3828
 
3829
3829
  schema_table_a.table_name= table_name;
3830
3830
  if (plugin_foreach(thd, find_schema_table_in_plugin, 
3831
 
                     MYSQL_INFORMATION_SCHEMA_PLUGIN, &schema_table_a))
 
3831
                     DRIZZLE_INFORMATION_SCHEMA_PLUGIN, &schema_table_a))
3832
3832
    return(schema_table_a.schema_table);
3833
3833
 
3834
3834
  return(NULL);
3856
3856
  @retval  NULL           Can't create table
3857
3857
*/
3858
3858
 
3859
 
TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
 
3859
Table *create_schema_table(THD *thd, TableList *table_list)
3860
3860
{
3861
3861
  int field_count= 0;
3862
3862
  Item *item;
3863
 
  TABLE *table;
 
3863
  Table *table;
3864
3864
  List<Item> field_list;
3865
3865
  ST_SCHEMA_TABLE *schema_table= table_list->schema_table;
3866
3866
  ST_FIELD_INFO *fields_info= schema_table->fields_info;
3940
3940
  tmp_table_param->schema_table= 1;
3941
3941
  SELECT_LEX *select_lex= thd->lex->current_select;
3942
3942
  if (!(table= create_tmp_table(thd, tmp_table_param,
3943
 
                                field_list, (ORDER*) 0, 0, 0, 
 
3943
                                field_list, (order_st*) 0, 0, 0, 
3944
3944
                                (select_lex->options | thd->options |
3945
3945
                                 TMP_TABLE_ALL_COLUMNS),
3946
3946
                                HA_POS_ERROR, table_list->alias)))
4128
4128
    1   error
4129
4129
*/
4130
4130
 
4131
 
int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list)
 
4131
int mysql_schema_table(THD *thd, LEX *lex, TableList *table_list)
4132
4132
{
4133
 
  TABLE *table;
 
4133
  Table *table;
4134
4134
  if (!(table= table_list->schema_table->create_table(thd, table_list)))
4135
4135
    return(1);
4136
4136
  table->s->tmp_table= SYSTEM_TMP_TABLE;
4258
4258
    if (!tab->table || !tab->table->pos_in_table_list)
4259
4259
      break;
4260
4260
 
4261
 
    TABLE_LIST *table_list= tab->table->pos_in_table_list;
 
4261
    TableList *table_list= tab->table->pos_in_table_list;
4262
4262
    if (table_list->schema_table)
4263
4263
    {
4264
4264
      bool is_subselect= (&lex->unit != lex->current_select->master_unit() &&
4605
4605
   create_schema_table, fill_schema_coll_charset_app, 0, 0, -1, -1, 0, 0},
4606
4606
  {"COLUMNS", columns_fields_info, create_schema_table, 
4607
4607
   get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0,
4608
 
   OPTIMIZE_I_S_TABLE|OPEN_VIEW_FULL},
 
4608
   OPTIMIZE_I_S_TABLE},
4609
4609
  {"GLOBAL_STATUS", variables_fields_info, create_schema_table,
4610
4610
   fill_status, make_old_format, 0, -1, -1, 0, 0},
4611
4611
  {"GLOBAL_VARIABLES", variables_fields_info, create_schema_table,
4672
4672
 
4673
4673
    if (plugin->plugin->init(schema_table))
4674
4674
    {
4675
 
      sql_print_error("Plugin '%s' init function returned error.",
 
4675
      sql_print_error(_("Plugin '%s' init function returned error."),
4676
4676
                      plugin->name.str);
4677
4677
      goto err;
4678
4678
    }