793
793
This function is used in the parser to convert a SHOW or DESCRIBE
794
794
table_name command to a SELECT from INFORMATION_SCHEMA.
795
It prepares a SELECT_LEX and a TableList object to represent the
795
It prepares a Select_Lex and a TableList object to represent the
796
796
given command as a SELECT parse tree.
798
798
@param session thread handle
816
816
int prepare_schema_table(Session *session, LEX *lex, Table_ident *table_ident,
817
817
enum enum_schema_tables schema_table_idx)
819
SELECT_LEX *schema_select_lex= NULL;
819
Select_Lex *schema_select_lex= NULL;
821
821
switch (schema_table_idx) {
822
822
case SCH_SCHEMATA:
834
schema_select_lex= new SELECT_LEX();
834
schema_select_lex= new Select_Lex();
835
835
db.str= schema_select_lex->db= lex->select_lex.db;
836
836
schema_select_lex->table_list.first= NULL;
837
837
db.length= strlen(db.str);
849
849
assert(table_ident);
850
850
TableList **query_tables_last= lex->query_tables_last;
851
schema_select_lex= new SELECT_LEX();
851
schema_select_lex= new Select_Lex();
852
852
/* 'parent_lex' is used in init_query() so it must be before it. */
853
853
schema_select_lex->parent_lex= lex;
854
854
schema_select_lex->init_query();
965
965
bool need_start_waiting= false; // have protection against global read lock
966
966
LEX *lex= session->lex;
967
/* first SELECT_LEX (have special meaning for many of non-SELECTcommands) */
968
SELECT_LEX *select_lex= &lex->select_lex;
969
/* first table of first SELECT_LEX */
967
/* first Select_Lex (have special meaning for many of non-SELECTcommands) */
968
Select_Lex *select_lex= &lex->select_lex;
969
/* first table of first Select_Lex */
970
970
TableList *first_table= (TableList*) select_lex->table_list.first;
971
971
/* list of all tables in query */
972
972
TableList *all_tables;
973
/* most outer SELECT_LEX_UNIT of query */
974
SELECT_LEX_UNIT *unit= &lex->unit;
973
/* most outer Select_Lex_UNIT of query */
974
Select_Lex_UNIT *unit= &lex->unit;
975
975
/* Saved variable value */
978
In many cases first table of main SELECT_LEX have special meaning =>
978
In many cases first table of main Select_Lex have special meaning =>
979
979
check that it is first table in global list and relink it first in
980
980
queries_tables list if it is necessary (we need such relinking only
981
981
for queries with subqueries in select list, in this case tables of
982
982
subqueries will go to global list first)
984
all_tables will differ from first_table only if most upper SELECT_LEX
984
all_tables will differ from first_table only if most upper Select_Lex
985
985
do not contain tables.
987
987
Because of above in place where should be at least one table in most
988
outer SELECT_LEX we have following check:
988
outer Select_Lex we have following check:
989
989
assert(first_table == all_tables);
990
990
assert(first_table == all_tables && first_table != 0);
1202
1202
select_tables)))
1205
CREATE from SELECT give its SELECT_LEX for SELECT,
1205
CREATE from SELECT give its Select_Lex for SELECT,
1206
1206
and item_list belong to SELECT
1208
1208
res= handle_select(session, lex, result, 0);
2039
2039
/* assign global limit variable if limit is not given */
2041
SELECT_LEX *param= lex->unit.global_parameters;
2041
Select_Lex *param= lex->unit.global_parameters;
2042
2042
if (!param->explicit_limit)
2043
2043
param->select_limit=
2044
2044
new Item_int((uint64_t) session->variables.select_limit);
2123
2123
mysql_init_select(LEX *lex)
2125
SELECT_LEX *select_lex= lex->current_select;
2125
Select_Lex *select_lex= lex->current_select;
2126
2126
select_lex->init_select();
2128
2128
if (select_lex == &lex->select_lex)
2137
2137
mysql_new_select(LEX *lex, bool move_down)
2139
SELECT_LEX *select_lex;
2139
Select_Lex *select_lex;
2140
2140
Session *session= lex->session;
2142
if (!(select_lex= new (session->mem_root) SELECT_LEX()))
2142
if (!(select_lex= new (session->mem_root) Select_Lex()))
2144
2144
select_lex->select_number= ++session->select_number;
2145
2145
select_lex->parent_lex= lex; /* Used in init_query. */
2154
2154
select_lex->nest_level= lex->nest_level;
2157
SELECT_LEX_UNIT *unit;
2157
Select_Lex_UNIT *unit;
2158
2158
lex->subqueries= true;
2159
2159
/* first select_lex of subselect or derived table */
2160
if (!(unit= new (session->mem_root) SELECT_LEX_UNIT()))
2160
if (!(unit= new (session->mem_root) Select_Lex_UNIT()))
2163
2163
unit->init_query();
2184
2184
select_lex->include_neighbour(lex->current_select);
2185
SELECT_LEX_UNIT *unit= select_lex->master_unit();
2185
Select_Lex_UNIT *unit= select_lex->master_unit();
2186
2186
if (!unit->fake_select_lex && unit->add_fake_select_lex(lex->session))
2188
2188
select_lex->context.outer_context=
2192
2192
select_lex->master_unit()->global_parameters= select_lex;
2193
select_lex->include_global((st_select_lex_node**)&lex->all_selects_list);
2193
select_lex->include_global((Select_Lex_node**)&lex->all_selects_list);
2194
2194
lex->current_select= select_lex;
2196
2196
in subquery is SELECT query and we allow resolution of names in SELECT
2672
2672
The function initializes a structure of the TableList type
2673
2673
for a nested join. It sets up its nested join list as empty.
2674
2674
The created structure is added to the front of the current
2675
join list in the st_select_lex object. Then the function
2675
join list in the Select_Lex object. Then the function
2676
2676
changes the current nest level for joins to refer to the newly
2677
2677
created empty list after having saved the info on the old level
2678
2678
in the initialized structure.
2762
2762
\# Pointer to TableList element created for the new nested join
2765
TableList *st_select_lex::nest_last_join(Session *session)
2765
TableList *Select_Lex::nest_last_join(Session *session)
2767
2767
TableList *ptr;
2768
2768
nested_join_st *nested_join;
2807
2807
Add a table to the current join list.
2809
2809
The function puts a table in front of the current join list
2810
of st_select_lex object.
2810
of Select_Lex object.
2811
2811
Thus, joined tables are put into this list in the reverse order
2812
2812
(the most outer join operation follows first).
2899
Create a fake SELECT_LEX for a unit.
2899
Create a fake Select_Lex for a unit.
2901
The method create a fake SELECT_LEX object for a unit.
2901
The method create a fake Select_Lex object for a unit.
2902
2902
This object is created for any union construct containing a union
2903
2903
operation and also for any single select union construct of the form
2924
bool st_select_lex_unit::add_fake_select_lex(Session *session_arg)
2924
bool Select_Lex_unit::add_fake_select_lex(Session *session_arg)
2926
SELECT_LEX *first_sl= first_select();
2926
Select_Lex *first_sl= first_select();
2927
2927
assert(!fake_select_lex);
2929
if (!(fake_select_lex= new (session_arg->mem_root) SELECT_LEX()))
2929
if (!(fake_select_lex= new (session_arg->mem_root) Select_Lex()))
2931
2931
fake_select_lex->include_standalone(this,
2932
(SELECT_LEX_NODE**)&fake_select_lex);
2932
(Select_Lex_NODE**)&fake_select_lex);
2933
2933
fake_select_lex->select_number= INT_MAX;
2934
2934
fake_select_lex->parent_lex= session_arg->lex; /* Used in init_query. */
2935
2935
fake_select_lex->make_empty_select();
3294
3294
Item * all_any_subquery_creator(Item *left_expr,
3295
3295
chooser_compare_func_creator cmp,
3297
SELECT_LEX *select_lex)
3297
Select_Lex *select_lex)
3299
3299
if ((cmp == &comp_eq_creator) && !all) // = ANY <=> IN
3300
3300
return new Item_in_subselect(left_expr, select_lex);
3365
3365
bool multi_delete_precheck(Session *session, TableList *)
3367
SELECT_LEX *select_lex= &session->lex->select_lex;
3367
Select_Lex *select_lex= &session->lex->select_lex;
3368
3368
TableList **save_query_tables_own_last= session->lex->query_tables_own_last;
3370
3370
session->lex->query_tables_own_last= 0;