2441
Find underlying base tables (TABLE_LIST) which represent given
2441
Find underlying base tables (TableList) which represent given
2442
2442
table_to_find (Table)
2445
TABLE_LIST::find_underlying_table()
2445
TableList::find_underlying_table()
2446
2446
table_to_find table to find
2450
2450
found table reference
2453
TABLE_LIST *TABLE_LIST::find_underlying_table(Table *table_to_find)
2453
TableList *TableList::find_underlying_table(Table *table_to_find)
2455
2455
/* is this real table and table which we are looking for? */
2456
2456
if (table == table_to_find && merge_underlying_list == 0)
2459
for (TABLE_LIST *tbl= merge_underlying_list; tbl; tbl= tbl->next_local)
2459
for (TableList *tbl= merge_underlying_list; tbl; tbl= tbl->next_local)
2462
2462
if ((result= tbl->find_underlying_table(table_to_find)))
2469
2469
cleunup items belonged to view fields translation table
2472
TABLE_LIST::cleanup_items()
2472
TableList::cleanup_items()
2475
void TABLE_LIST::cleanup_items()
2475
void TableList::cleanup_items()
2477
2477
if (!field_translation)
2527
2527
TRUE if a leaf, false otherwise.
2529
bool TABLE_LIST::is_leaf_for_name_resolution()
2529
bool TableList::is_leaf_for_name_resolution()
2531
2531
return (is_natural_join || is_join_columns_complete || !nested_join);
2537
2537
respect to name resolution.
2540
TABLE_LIST::first_leaf_for_name_resolution()
2540
TableList::first_leaf_for_name_resolution()
2543
2543
Given that 'this' is a nested table reference, recursively walk
2555
2555
else return 'this'
2558
TABLE_LIST *TABLE_LIST::first_leaf_for_name_resolution()
2558
TableList *TableList::first_leaf_for_name_resolution()
2560
TABLE_LIST *cur_table_ref= NULL;
2561
NESTED_JOIN *cur_nested_join;
2560
TableList *cur_table_ref= NULL;
2561
nested_join_st *cur_nested_join;
2563
2563
if (is_leaf_for_name_resolution())
2568
2568
cur_nested_join;
2569
2569
cur_nested_join= cur_table_ref->nested_join)
2571
List_iterator_fast<TABLE_LIST> it(cur_nested_join->join_list);
2571
List_iterator_fast<TableList> it(cur_nested_join->join_list);
2572
2572
cur_table_ref= it++;
2574
2574
If the current nested join is a RIGHT JOIN, the operands in
2594
2594
respect to name resolution.
2597
TABLE_LIST::last_leaf_for_name_resolution()
2597
TableList::last_leaf_for_name_resolution()
2600
2600
Given that 'this' is a nested table reference, recursively walk
2612
2612
- else - 'this'
2615
TABLE_LIST *TABLE_LIST::last_leaf_for_name_resolution()
2615
TableList *TableList::last_leaf_for_name_resolution()
2617
TABLE_LIST *cur_table_ref= this;
2618
NESTED_JOIN *cur_nested_join;
2617
TableList *cur_table_ref= this;
2618
nested_join_st *cur_nested_join;
2620
2620
if (is_leaf_for_name_resolution())
2649
Natural_join_column::Natural_join_column(Field_translator *field_param,
2652
assert(tab->field_translation);
2653
view_field= field_param;
2660
Natural_join_column::Natural_join_column(Field *field_param,
2663
assert(tab->table == field_param->table);
2664
table_field= field_param;
2671
const char *Natural_join_column::name()
2675
assert(table_field == NULL);
2676
return view_field->name;
2679
return table_field->field_name;
2683
Item *Natural_join_column::create_item(THD *thd)
2687
assert(table_field == NULL);
2688
return create_view_field(thd, table_ref, &view_field->item,
2691
return new Item_field(thd, &thd->lex->current_select->context, table_field);
2695
Field *Natural_join_column::field()
2699
assert(table_field == NULL);
2706
const char *Natural_join_column::table_name()
2709
return table_ref->alias;
2713
const char *Natural_join_column::db_name()
2716
Test that TABLE_LIST::db is the same as st_table_share::db to
2717
ensure consistency. An exception are I_S schema tables, which
2718
are inconsistent in this respect.
2720
assert(!strcmp(table_ref->db,
2721
table_ref->table->s->db.str) ||
2722
(table_ref->schema_table &&
2723
table_ref->table->s->db.str[0] == 0));
2724
return table_ref->db;
2728
void Field_iterator_view::set(TABLE_LIST *table)
2649
void Field_iterator_view::set(TableList *table)
2730
2651
assert(table->field_translation);
2769
2690
Item *create_view_field(THD *thd __attribute__((unused)),
2770
TABLE_LIST *view, Item **field_ref,
2691
TableList *view, Item **field_ref,
2771
2692
const char *name __attribute__((unused)))
2773
2694
if (view->schema_table_reformed)
2810
2731
If the table reference we are iterating over is a natural join, or it is
2811
an operand of a natural join, and TABLE_LIST::join_columns contains all
2732
an operand of a natural join, and TableList::join_columns contains all
2812
2733
the columns of the join operand, then we pick the columns from
2813
TABLE_LIST::join_columns, instead of the orginial container of the
2734
TableList::join_columns, instead of the orginial container of the
2814
2735
columns of the join operator.
2816
2737
if (table_ref->is_join_columns_complete)
2879
2800
return natural_join_it.column_ref()->db_name();
2882
Test that TABLE_LIST::db is the same as st_table_share::db to
2803
Test that TableList::db is the same as st_table_share::db to
2883
2804
ensure consistency. An exception are I_S schema tables, which
2884
2805
are inconsistent in this respect.
2931
2852
Natural_join_column *
2932
Field_iterator_table_ref::get_or_create_column_ref(TABLE_LIST *parent_table_ref)
2853
Field_iterator_table_ref::get_or_create_column_ref(TableList *parent_table_ref)
2934
2855
Natural_join_column *nj_col;
2935
2856
bool is_created= true;
2936
2857
uint field_count=0;
2937
TABLE_LIST *add_table_ref= parent_table_ref ?
2858
TableList *add_table_ref= parent_table_ref ?
2938
2859
parent_table_ref : table_ref;
2940
2861
if (field_it == &table_field_it)
3277
3198
Cleanup this table for re-execution.
3280
TABLE_LIST::reinit_before_use()
3201
TableList::reinit_before_use()
3283
void TABLE_LIST::reinit_before_use(THD *thd)
3204
void TableList::reinit_before_use(THD *thd)
3286
3207
Reset old pointers to TABLEs: they are not valid since the tables
3290
3211
/* Reset is_schema_table_processed value(needed for I_S tables */
3291
3212
schema_table_state= NOT_PROCESSED;
3293
TABLE_LIST *embedded; /* The table at the current level of nesting. */
3294
TABLE_LIST *parent_embedding= this; /* The parent nested table reference. */
3214
TableList *embedded; /* The table at the current level of nesting. */
3215
TableList *parent_embedding= this; /* The parent nested table reference. */
3297
3218
embedded= parent_embedding;
3332
3253
The parser collects the index hints for each table in a "tagged list"
3333
(TABLE_LIST::index_hints). Using the information in this tagged list
3254
(TableList::index_hints). Using the information in this tagged list
3334
3255
this function sets the members Table::keys_in_use_for_query,
3335
3256
Table::keys_in_use_for_group_by, Table::keys_in_use_for_order_by,
3336
3257
Table::force_index and Table::covering_keys.
3372
3293
false no errors found
3373
3294
TRUE found and reported an error.
3375
bool TABLE_LIST::process_index_hints(Table *tbl)
3296
bool TableList::process_index_hints(Table *tbl)
3377
3298
/* initialize the result variables */
3378
3299
tbl->keys_in_use_for_query= tbl->keys_in_use_for_group_by=