~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_show.cc

  • Committer: Brian Aker
  • Date: 2008-08-18 22:20:43 UTC
  • mto: This revision was merged to the branch mainline in revision 352.
  • Revision ID: brian@tangent.org-20080818222043-et6zf93ogrgx1cz9
Refactoring table.h

Show diffs side-by-side

added added

removed removed

Lines of Context:
168
168
}
169
169
 
170
170
 
171
 
int fill_plugins(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((unused)))
 
171
int fill_plugins(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
172
172
{
173
173
  Table *table= tables->table;
174
174
 
187
187
    find_files()
188
188
    thd                 thread handler
189
189
    files               put found files in this list
190
 
    db                  database name to set in TABLE_LIST structure
 
190
    db                  database name to set in TableList structure
191
191
    path                path to database
192
192
    wild                filter for found files
193
193
    dir                 read databases in path if true, read .frm files in
210
210
  FILEINFO *file;
211
211
  LEX_STRING *file_name= 0;
212
212
  uint file_name_len;
213
 
  TABLE_LIST table_list;
 
213
  TableList table_list;
214
214
 
215
215
  if (wild && !wild[0])
216
216
    wild=0;
299
299
 
300
300
 
301
301
bool
302
 
mysqld_show_create(THD *thd, TABLE_LIST *table_list)
 
302
mysqld_show_create(THD *thd, TableList *table_list)
303
303
{
304
304
  Protocol *protocol= thd->protocol;
305
305
  char buff[2048];
397
397
****************************************************************************/
398
398
 
399
399
void
400
 
mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild)
 
400
mysqld_list_fields(THD *thd, TableList *table_list, const char *wild)
401
401
{
402
402
  Table *table;
403
403
 
646
646
    0       OK
647
647
 */
648
648
 
649
 
int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
 
649
int store_create_info(THD *thd, TableList *table_list, String *packet,
650
650
                      HA_CREATE_INFO *create_info_arg)
651
651
{
652
652
  List<Item> field_list;
1213
1213
  return;
1214
1214
}
1215
1215
 
1216
 
int fill_schema_processlist(THD* thd, TABLE_LIST* tables,
 
1216
int fill_schema_processlist(THD* thd, TableList* tables,
1217
1217
                            COND* cond __attribute__((unused)))
1218
1218
{
1219
1219
  Table *table= tables->table;
1731
1731
*/
1732
1732
 
1733
1733
bool get_lookup_value(THD *thd, Item_func *item_func,
1734
 
                      TABLE_LIST *table, 
 
1734
                      TableList *table, 
1735
1735
                      LOOKUP_FIELD_VALUES *lookup_field_vals)
1736
1736
{
1737
1737
  ST_SCHEMA_TABLE *schema_table= table->schema_table;
1813
1813
    1             error, there can be no matching records for the condition
1814
1814
*/
1815
1815
 
1816
 
bool calc_lookup_values_from_cond(THD *thd, COND *cond, TABLE_LIST *table,
 
1816
bool calc_lookup_values_from_cond(THD *thd, COND *cond, TableList *table,
1817
1817
                                  LOOKUP_FIELD_VALUES *lookup_field_vals)
1818
1818
{
1819
1819
  if (!cond)
1848
1848
}
1849
1849
 
1850
1850
 
1851
 
bool uses_only_table_name_fields(Item *item, TABLE_LIST *table)
 
1851
bool uses_only_table_name_fields(Item *item, TableList *table)
1852
1852
{
1853
1853
  if (item->type() == Item::FUNC_ITEM)
1854
1854
  {
1888
1888
}
1889
1889
 
1890
1890
 
1891
 
static COND * make_cond_for_info_schema(COND *cond, TABLE_LIST *table)
 
1891
static COND * make_cond_for_info_schema(COND *cond, TableList *table)
1892
1892
{
1893
1893
  if (!cond)
1894
1894
    return (COND*) 0;
1962
1962
    1             error, there can be no matching records for the condition
1963
1963
*/
1964
1964
 
1965
 
bool get_lookup_field_values(THD *thd, COND *cond, TABLE_LIST *tables,
 
1965
bool get_lookup_field_values(THD *thd, COND *cond, TableList *tables,
1966
1966
                             LOOKUP_FIELD_VALUES *lookup_field_values)
1967
1967
{
1968
1968
  LEX *lex= thd->lex;
2243
2243
  @brief          Fill I_S table for SHOW COLUMNS|INDEX commands
2244
2244
 
2245
2245
  @param[in]      thd                      thread handler
2246
 
  @param[in]      tables                   TABLE_LIST for I_S table
 
2246
  @param[in]      tables                   TableList for I_S table
2247
2247
  @param[in]      schema_table             pointer to I_S structure
2248
2248
  @param[in]      open_tables_state_backup pointer to Open_tables_state object
2249
2249
                                           which is used to save|restore original
2256
2256
*/
2257
2257
 
2258
2258
static int 
2259
 
fill_schema_show_cols_or_idxs(THD *thd, TABLE_LIST *tables,
 
2259
fill_schema_show_cols_or_idxs(THD *thd, TableList *tables,
2260
2260
                              ST_SCHEMA_TABLE *schema_table,
2261
2261
                              Open_tables_state *open_tables_state_backup)
2262
2262
{
2264
2264
  bool res;
2265
2265
  LEX_STRING tmp_lex_string, tmp_lex_string1, *db_name, *table_name;
2266
2266
  enum_sql_command save_sql_command= lex->sql_command;
2267
 
  TABLE_LIST *show_table_list= (TABLE_LIST*) tables->schema_select_lex->
 
2267
  TableList *show_table_list= (TableList*) tables->schema_select_lex->
2268
2268
    table_list.first;
2269
2269
  Table *table= tables->table;
2270
2270
  int error= 1;
2381
2381
    @retval       SKIP_OPEN_TABLE | OPEN_FRM_ONLY | OPEN_FULL_TABLE
2382
2382
*/
2383
2383
 
2384
 
static uint get_table_open_method(TABLE_LIST *tables,
 
2384
static uint get_table_open_method(TableList *tables,
2385
2385
                                  ST_SCHEMA_TABLE *schema_table,
2386
2386
                                  enum enum_schema_tables schema_table_idx __attribute__((unused)))
2387
2387
{
2422
2422
                              open_tables function for this table
2423
2423
*/
2424
2424
 
2425
 
static int fill_schema_table_from_frm(THD *thd,TABLE_LIST *tables,
 
2425
static int fill_schema_table_from_frm(THD *thd,TableList *tables,
2426
2426
                                      ST_SCHEMA_TABLE *schema_table,
2427
2427
                                      LEX_STRING *db_name,
2428
2428
                                      LEX_STRING *table_name,
2431
2431
  Table *table= tables->table;
2432
2432
  TABLE_SHARE *share;
2433
2433
  Table tbl;
2434
 
  TABLE_LIST table_list;
 
2434
  TableList table_list;
2435
2435
  uint res= 0;
2436
2436
  int error;
2437
2437
  char key[MAX_DBKEY_LENGTH];
2438
2438
  uint key_length;
2439
2439
 
2440
 
  memset(&table_list, 0, sizeof(TABLE_LIST));
 
2440
  memset(&table_list, 0, sizeof(TableList));
2441
2441
  memset(&tbl, 0, sizeof(Table));
2442
2442
 
2443
2443
  table_list.table_name= table_name->str;
2489
2489
    @retval       1                        error
2490
2490
*/
2491
2491
 
2492
 
int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
 
2492
int get_all_tables(THD *thd, TableList *tables, COND *cond)
2493
2493
{
2494
2494
  LEX *lex= thd->lex;
2495
2495
  Table *table= tables->table;
2648
2648
              goto err;
2649
2649
            if (make_table_list(thd, &sel, db_name, table_name))
2650
2650
              goto err;
2651
 
            TABLE_LIST *show_table_list= (TABLE_LIST*) sel.table_list.first;
 
2651
            TableList *show_table_list= (TableList*) sel.table_list.first;
2652
2652
            lex->all_selects_list= &sel;
2653
2653
            lex->derived_tables= 0;
2654
2654
            lex->sql_command= SQLCOM_SHOW_FIELDS;
2730
2730
}
2731
2731
 
2732
2732
 
2733
 
int fill_schema_schemata(THD *thd, TABLE_LIST *tables, COND *cond)
 
2733
int fill_schema_schemata(THD *thd, TableList *tables, COND *cond)
2734
2734
{
2735
2735
  /*
2736
2736
    TODO: fill_schema_shemata() is called when new client is connected.
2790
2790
}
2791
2791
 
2792
2792
 
2793
 
static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
 
2793
static int get_schema_tables_record(THD *thd, TableList *tables,
2794
2794
                                    Table *table, bool res,
2795
2795
                                    LEX_STRING *db_name,
2796
2796
                                    LEX_STRING *table_name)
3082
3082
}
3083
3083
 
3084
3084
 
3085
 
static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
 
3085
static int get_schema_column_record(THD *thd, TableList *tables,
3086
3086
                                    Table *table, bool res,
3087
3087
                                    LEX_STRING *db_name,
3088
3088
                                    LEX_STRING *table_name)
3215
3215
 
3216
3216
 
3217
3217
 
3218
 
int fill_schema_charsets(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((unused)))
 
3218
int fill_schema_charsets(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
3219
3219
{
3220
3220
  CHARSET_INFO **cs;
3221
3221
  const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
3246
3246
}
3247
3247
 
3248
3248
 
3249
 
int fill_schema_collation(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((unused)))
 
3249
int fill_schema_collation(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
3250
3250
{
3251
3251
  CHARSET_INFO **cs;
3252
3252
  const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
3288
3288
}
3289
3289
 
3290
3290
 
3291
 
int fill_schema_coll_charset_app(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((unused)))
 
3291
int fill_schema_coll_charset_app(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
3292
3292
{
3293
3293
  CHARSET_INFO **cs;
3294
3294
  Table *table= tables->table;
3317
3317
}
3318
3318
 
3319
3319
 
3320
 
static int get_schema_stat_record(THD *thd, TABLE_LIST *tables,
 
3320
static int get_schema_stat_record(THD *thd, TableList *tables,
3321
3321
                                  Table *table, bool res,
3322
3322
                                  LEX_STRING *db_name,
3323
3323
                                  LEX_STRING *table_name)
3429
3429
}
3430
3430
 
3431
3431
 
3432
 
static int get_schema_constraints_record(THD *thd, TABLE_LIST *tables,
 
3432
static int get_schema_constraints_record(THD *thd, TableList *tables,
3433
3433
                                         Table *table, bool res,
3434
3434
                                         LEX_STRING *db_name,
3435
3435
                                         LEX_STRING *table_name)
3504
3504
 
3505
3505
 
3506
3506
static int get_schema_key_column_usage_record(THD *thd,
3507
 
                                              TABLE_LIST *tables,
 
3507
                                              TableList *tables,
3508
3508
                                              Table *table, bool res,
3509
3509
                                              LEX_STRING *db_name,
3510
3510
                                              LEX_STRING *table_name)
3592
3592
}
3593
3593
 
3594
3594
 
3595
 
int fill_open_tables(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((unused)))
 
3595
int fill_open_tables(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
3596
3596
{
3597
3597
  const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
3598
3598
  Table *table= tables->table;
3599
3599
  const CHARSET_INFO * const cs= system_charset_info;
3600
 
  OPEN_TABLE_LIST *open_list;
 
3600
  OPEN_TableList *open_list;
3601
3601
  if (!(open_list=list_open_tables(thd,thd->lex->select_lex.db, wild))
3602
3602
            && thd->is_fatal_error)
3603
3603
    return(1);
3616
3616
}
3617
3617
 
3618
3618
 
3619
 
int fill_variables(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((unused)))
 
3619
int fill_variables(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
3620
3620
{
3621
3621
  int res= 0;
3622
3622
  LEX *lex= thd->lex;
3639
3639
}
3640
3640
 
3641
3641
 
3642
 
int fill_status(THD *thd, TABLE_LIST *tables, COND *cond __attribute__((unused)))
 
3642
int fill_status(THD *thd, TableList *tables, COND *cond __attribute__((unused)))
3643
3643
{
3644
3644
  LEX *lex= thd->lex;
3645
3645
  const char *wild= lex->wild ? lex->wild->ptr() : NullS;
3700
3700
*/
3701
3701
 
3702
3702
static int
3703
 
get_referential_constraints_record(THD *thd, TABLE_LIST *tables,
 
3703
get_referential_constraints_record(THD *thd, TableList *tables,
3704
3704
                                   Table *table, bool res,
3705
3705
                                   LEX_STRING *db_name, LEX_STRING *table_name)
3706
3706
{
3852
3852
  @retval  NULL           Can't create table
3853
3853
*/
3854
3854
 
3855
 
Table *create_schema_table(THD *thd, TABLE_LIST *table_list)
 
3855
Table *create_schema_table(THD *thd, TableList *table_list)
3856
3856
{
3857
3857
  int field_count= 0;
3858
3858
  Item *item;
4124
4124
    1   error
4125
4125
*/
4126
4126
 
4127
 
int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list)
 
4127
int mysql_schema_table(THD *thd, LEX *lex, TableList *table_list)
4128
4128
{
4129
4129
  Table *table;
4130
4130
  if (!(table= table_list->schema_table->create_table(thd, table_list)))
4254
4254
    if (!tab->table || !tab->table->pos_in_table_list)
4255
4255
      break;
4256
4256
 
4257
 
    TABLE_LIST *table_list= tab->table->pos_in_table_list;
 
4257
    TableList *table_list= tab->table->pos_in_table_list;
4258
4258
    if (table_list->schema_table)
4259
4259
    {
4260
4260
      bool is_subselect= (&lex->unit != lex->current_select->master_unit() &&