17
17
/* A lexical scanner on a temporary buffer with a yacc interface */
19
19
#define DRIZZLE_LEX 1
20
#include <drizzled/server_includes.h>
22
static int lex_one_token(void *arg, void *yythd);
25
We are using pointer to this variable for distinguishing between assignment
26
to NEW row field (when parsing trigger definition) and structured variable.
21
#include "drizzled/configmake.h"
22
#include "drizzled/item/num.h"
23
#include "drizzled/error.h"
24
#include "drizzled/session.h"
25
#include "drizzled/sql_base.h"
26
#include "drizzled/lookup_symbol.h"
27
#include "drizzled/index_hint.h"
33
static int lex_one_token(void *arg, void *yysession);
34
int DRIZZLElex(void *arg, void *yysession);
37
save order by and tables in own lists.
29
sys_var *trg_new_row_fake_var= (sys_var*) 0x01;
39
static bool add_to_list(Session *session, SQL_LIST &list, Item *item, bool asc)
42
if (!(order = (order_st *) session->alloc(sizeof(order_st))))
44
order->item_ptr= item;
45
order->item= &order->item_ptr;
49
order->counter_used= 0;
50
list.link_in_list((unsigned char*) order,(unsigned char**) &order->next);
32
55
LEX_STRING constant for null-string to be used in parser and other places.
34
57
const LEX_STRING null_lex_str= {NULL, 0};
36
/* Longest standard keyword name */
38
#define TOCK_NAME_LENGTH 24
41
The following data is based on the latin1 character set, and is only
42
used when comparing keywords
45
static uchar to_upper_lex[]=
47
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
48
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
49
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
50
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
51
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
52
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
53
96, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
54
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,123,124,125,126,127,
55
128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
56
144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
57
160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
58
176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
59
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
60
208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
61
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
62
208,209,210,211,212,213,214,247,216,217,218,219,220,221,222,255
66
Names of the index hints (for error messages). Keep in sync with
70
const char * index_hint_type_name[] =
77
inline int lex_casecmp(const char *s, const char *t, uint len)
80
to_upper_lex[(uchar) *s++] == to_upper_lex[(uchar) *t++]) ;
90
for (i=0 ; i < array_elements(symbols) ; i++)
91
symbols[i].length=(uchar) strlen(symbols[i].name);
92
for (i=0 ; i < array_elements(sql_functions) ; i++)
93
sql_functions[i].length=(uchar) strlen(sql_functions[i].name);
100
{ // Call this when daemon ends
106
st_parsing_options::reset()
108
allows_variable= true;
109
allows_select_into= true;
110
allows_select_procedure= true;
111
allows_derived= true;
114
Lex_input_stream::Lex_input_stream(THD *thd,
59
Lex_input_stream::Lex_input_stream(Session *session,
115
60
const char* buffer,
116
61
unsigned int length)
233
174
The operation converts the specified text literal to the utf8 and appends
234
175
the result to the utf8-body.
236
@param thd Thread context.
177
@param session Thread context.
237
178
@param txt Text literal.
238
179
@param txt_cs Character set of the text literal.
239
180
@param end_ptr Pointer in the pre-processed buffer, to which
240
181
m_cpp_utf8_processed_ptr will be set in the end of the
244
void Lex_input_stream::body_utf8_append_literal(THD *thd,
245
const LEX_STRING *txt,
246
const CHARSET_INFO * const txt_cs,
184
void Lex_input_stream::body_utf8_append_literal(const LEX_STRING *txt,
247
185
const char *end_ptr)
249
187
if (!m_cpp_utf8_processed_ptr)
254
if (!my_charset_same(txt_cs, &my_charset_utf8_general_ci))
256
thd->convert_string(&utf_txt,
257
&my_charset_utf8_general_ci,
258
txt->str, txt->length,
263
utf_txt.str= txt->str;
264
utf_txt.length= txt->length;
267
190
/* NOTE: utf_txt.length is in bytes, not in symbols. */
269
memcpy(m_body_utf8_ptr, utf_txt.str, utf_txt.length);
270
m_body_utf8_ptr += utf_txt.length;
192
memcpy(m_body_utf8_ptr, txt->str, txt->length);
193
m_body_utf8_ptr += txt->length;
271
194
*m_body_utf8_ptr= 0;
273
196
m_cpp_utf8_processed_ptr= end_ptr;
278
200
This is called before every query that is to be parsed.
279
201
Because of this, it's critical to not do too much things here.
280
202
(We already do too much here)
283
void lex_start(THD *thd)
204
void lex_start(Session *session)
206
LEX *lex= session->lex;
287
lex->thd= lex->unit.thd= thd;
208
lex->session= lex->unit.session= session;
289
210
lex->context_stack.empty();
290
211
lex->unit.init_query();
337
251
lex->nest_level=0 ;
338
252
lex->allow_sum_func= 0;
339
253
lex->in_sum_func= NULL;
341
ok, there must be a better solution for this, long-term
342
I tried "memset" in the sql_yacc.yy code, but that for
343
some reason made the values zero, even if they were set
345
lex->server_options.server_name= 0;
346
lex->server_options.server_name_length= 0;
347
lex->server_options.host= 0;
348
lex->server_options.db= 0;
349
lex->server_options.username= 0;
350
lex->server_options.password= 0;
351
lex->server_options.scheme= 0;
352
lex->server_options.owner= 0;
353
lex->server_options.port= -1;
355
255
lex->is_lex_started= true;
256
lex->statement= NULL;
359
259
void lex_end(LEX *lex)
361
261
if (lex->yacc_yyss)
363
my_free(lex->yacc_yyss, MYF(0));
364
my_free(lex->yacc_yyvs, MYF(0));
263
free(lex->yacc_yyss);
264
free(lex->yacc_yyvs);
365
265
lex->yacc_yyss= 0;
366
266
lex->yacc_yyvs= 0;
369
/* release used plugins */
370
plugin_unlock_list(0, (plugin_ref*)lex->plugins.buffer,
371
lex->plugins.elements);
372
reset_dynamic(&lex->plugins);
274
delete lex->statement;
378
static int find_keyword(Lex_input_stream *lip, uint len, bool function)
277
static int find_keyword(Lex_input_stream *lip, uint32_t len, bool function)
279
/* Plenty of memory for the largest lex symbol we have */
380
281
const char *tok= lip->get_tok_start();
283
for (;tok_pos<len && tok_pos<63;tok_pos++)
284
tok_upper[tok_pos]=my_toupper(system_charset_info, tok[tok_pos]);
285
tok_upper[tok_pos]=0;
382
SYMBOL *symbol= get_hash_symbol(tok, len, function);
287
const SYMBOL *symbol= lookup_symbol(tok_upper, len, function);
385
290
lip->yylval->symbol.symbol=symbol;
887
763
for (; state_map[c] == MY_LEX_SKIP ; c= lip->yyGet()) {};
889
765
if (start == lip->get_ptr() && c == '.' && ident_map[(uint8_t)lip->yyPeek()])
890
lip->next_state=MY_LEX_IDENT_SEP;
766
lip->next_state=MY_LEX_IDENT_SEP;
892
768
{ // '(' must follow directly if function
894
if ((tokval = find_keyword(lip, length, c == '(')))
896
lip->next_state= MY_LEX_START; // Allow signed numbers
897
return(tokval); // Was keyword
770
if ((tokval = find_keyword(lip, length, c == '(')))
772
lip->next_state= MY_LEX_START; // Allow signed numbers
773
return(tokval); // Was keyword
899
775
lip->yySkip(); // next state does a unget
901
777
yylval->lex_str=get_token(lip, 0, length);
904
Note: "SELECT _bla AS 'alias'"
905
_bla should be considered as a IDENT if charset haven't been found.
906
So we don't use MYF(MY_WME) with get_charset_by_csname to avoid
910
if (yylval->lex_str.str[0] == '_')
912
const CHARSET_INFO * const cs= get_charset_by_csname(yylval->lex_str.str + 1,
913
MY_CS_PRIMARY, MYF(0));
917
lip->m_underscore_cs= cs;
919
lip->body_utf8_append(lip->m_cpp_text_start,
920
lip->get_cpp_tok_start() + length);
921
return(UNDERSCORE_CHARSET);
925
779
lip->body_utf8_append(lip->m_cpp_text_start);
927
lip->body_utf8_append_literal(thd, &yylval->lex_str, cs,
928
lip->m_cpp_text_end);
781
lip->body_utf8_append_literal(&yylval->lex_str, lip->m_cpp_text_end);
930
783
return(result_state); // IDENT or IDENT_QUOTED
974
827
while (my_isdigit(cs, (c = lip->yyGet()))) ;
975
828
if (!ident_map[c])
976
829
{ // Can't be identifier
977
state=MY_LEX_INT_OR_REAL;
830
state=MY_LEX_INT_OR_REAL;
980
833
if (c == 'e' || c == 'E')
982
// The following test is written this way to allow numbers of type 1e1
835
// The following test is written this way to allow numbers of type 1e1
983
836
if (my_isdigit(cs,lip->yyPeek()) ||
984
837
(c=(lip->yyGet())) == '+' || c == '-')
986
839
if (my_isdigit(cs,lip->yyPeek())) // Number must have digit after sign
989
842
while (my_isdigit(cs,lip->yyGet())) ;
990
843
yylval->lex_str=get_token(lip, 0, lip->yyLength());
997
850
case MY_LEX_IDENT_START: // We come here after '.'
998
851
result_state= IDENT;
999
#if defined(USE_MB) && defined(USE_MB_IDENT)
1002
result_state= IDENT_QUOTED;
854
result_state= IDENT_QUOTED;
1003
855
while (ident_map[c=lip->yyGet()])
1005
857
if (my_mbcharlen(cs, c) > 1)
1008
if ((l = my_ismbchar(cs,
1010
lip->get_end_of_query())) == 0)
859
int l= my_ismbchar(cs, lip->get_ptr() -1, lip->get_end_of_query());
1012
862
lip->skip_binary(l-1);
1019
868
for (result_state=0; ident_map[c= lip->yyGet()]; result_state|= c) {};
1020
869
/* If there were non-ASCII characters, mark that we must convert */
1021
870
result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT;
1023
872
if (c == '.' && ident_map[(uint8_t)lip->yyPeek()])
1024
lip->next_state=MY_LEX_IDENT_SEP;// Next is '.'
873
lip->next_state=MY_LEX_IDENT_SEP;// Next is '.'
1026
875
yylval->lex_str= get_token(lip, 0, lip->yyLength());
1028
877
lip->body_utf8_append(lip->m_cpp_text_start);
1030
lip->body_utf8_append_literal(thd, &yylval->lex_str, cs,
1031
lip->m_cpp_text_end);
879
lip->body_utf8_append_literal(&yylval->lex_str, lip->m_cpp_text_end);
1033
881
return(result_state);
1035
883
case MY_LEX_USER_VARIABLE_DELIMITER: // Found quote char
1037
uint double_quotes= 0;
885
uint32_t double_quotes= 0;
1038
886
char quote_char= c; // Used char
1039
887
while ((c=lip->yyGet()))
1042
if ((var_length= my_mbcharlen(cs, c)) == 1)
1044
if (c == quote_char)
1046
if (lip->yyPeek() != quote_char)
1054
else if (var_length < 1)
890
if ((var_length= my_mbcharlen(cs, c)) == 1)
894
if (lip->yyPeek() != quote_char)
901
else if (var_length < 1)
1056
903
lip->skip_binary(var_length-1);
1059
905
if (double_quotes)
1060
yylval->lex_str=get_quoted_token(lip, 1,
1061
lip->yyLength() - double_quotes -1,
906
yylval->lex_str=get_quoted_token(lip, 1, lip->yyLength() - double_quotes -1, quote_char);
1064
908
yylval->lex_str=get_token(lip, 1, lip->yyLength() -1);
1065
909
if (c == quote_char)
1066
910
lip->yySkip(); // Skip end `
1067
911
lip->next_state= MY_LEX_START;
1069
912
lip->body_utf8_append(lip->m_cpp_text_start);
1071
lip->body_utf8_append_literal(thd, &yylval->lex_str, cs,
1072
lip->m_cpp_text_end);
913
lip->body_utf8_append_literal(&yylval->lex_str, lip->m_cpp_text_end);
1074
914
return(IDENT_QUOTED);
1076
916
case MY_LEX_INT_OR_REAL: // Complete int or incomplete real
1078
918
{ // Found complete integer number.
1079
919
yylval->lex_str=get_token(lip, 0, lip->yyLength());
1080
return int_token(yylval->lex_str.str,yylval->lex_str.length);
920
return int_token(yylval->lex_str.str,yylval->lex_str.length);
1083
923
case MY_LEX_REAL: // Incomplete real number
1409
1234
result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT;
1412
lip->next_state=MY_LEX_IDENT_SEP;
1237
lip->next_state=MY_LEX_IDENT_SEP;
1413
1238
length= lip->yyLength();
1414
1239
if (length == 0)
1415
1240
return(ABORT_SYM); // Names must be nonempty.
1416
1241
if ((tokval= find_keyword(lip, length,0)))
1418
1243
lip->yyUnget(); // Put back 'c'
1419
return(tokval); // Was keyword
1244
return(tokval); // Was keyword
1421
1246
yylval->lex_str=get_token(lip, 0, length);
1423
1248
lip->body_utf8_append(lip->m_cpp_text_start);
1425
lip->body_utf8_append_literal(thd, &yylval->lex_str, cs,
1426
lip->m_cpp_text_end);
1250
lip->body_utf8_append_literal(&yylval->lex_str, lip->m_cpp_text_end);
1428
1252
return(result_state);
1435
Construct a copy of this object to be used for mysql_alter_table
1436
and mysql_create_table.
1438
Historically, these two functions modify their Alter_info
1439
arguments. This behaviour breaks re-execution of prepared
1440
statements and stored procedures and is compensated by always
1441
supplying a copy of Alter_info to these functions.
1443
@return You need to use check the error in THD for out
1444
of memory condition after calling this function.
1447
Alter_info::Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root)
1448
:drop_list(rhs.drop_list, mem_root),
1449
alter_list(rhs.alter_list, mem_root),
1450
key_list(rhs.key_list, mem_root),
1451
create_list(rhs.create_list, mem_root),
1453
keys_onoff(rhs.keys_onoff),
1454
tablespace_op(rhs.tablespace_op),
1455
no_parts(rhs.no_parts),
1456
build_method(rhs.build_method),
1457
datetime_field(rhs.datetime_field),
1458
error_if_not_empty(rhs.error_if_not_empty)
1461
Make deep copies of used objects.
1462
This is not a fully deep copy - clone() implementations
1463
of Alter_drop, Alter_column, Key, foreign_key, Key_part_spec
1464
do not copy string constants. At the same length the only
1465
reason we make a copy currently is that ALTER/CREATE TABLE
1466
code changes input Alter_info definitions, but string
1467
constants never change.
1469
list_copy_and_replace_each_value(drop_list, mem_root);
1470
list_copy_and_replace_each_value(alter_list, mem_root);
1471
list_copy_and_replace_each_value(key_list, mem_root);
1472
list_copy_and_replace_each_value(create_list, mem_root);
1476
1257
void trim_whitespace(const CHARSET_INFO * const cs, LEX_STRING *str)
1836
1603
prohibit using LIMIT clause
1838
bool st_select_lex::test_limit()
1605
bool Select_Lex::test_limit()
1840
1607
if (select_limit != 0)
1842
1609
my_error(ER_NOT_SUPPORTED_YET, MYF(0),
1843
1610
"LIMIT & IN/ALL/ANY/SOME subquery");
1850
st_select_lex_unit* st_select_lex_unit::master_unit()
1856
st_select_lex* st_select_lex_unit::outer_select()
1858
return (st_select_lex*) master;
1862
bool st_select_lex::add_order_to_list(THD *thd, Item *item, bool asc)
1864
return add_to_list(thd, order_list, item, asc);
1868
bool st_select_lex::add_item_to_list(THD *thd __attribute__((unused)),
1616
Select_Lex_Unit* Select_Lex_Unit::master_unit()
1621
Select_Lex* Select_Lex_Unit::outer_select()
1623
return (Select_Lex*) master;
1626
bool Select_Lex::add_order_to_list(Session *session, Item *item, bool asc)
1628
return add_to_list(session, order_list, item, asc);
1631
bool Select_Lex::add_item_to_list(Session *, Item *item)
1871
1633
return(item_list.push_back(item));
1875
bool st_select_lex::add_group_to_list(THD *thd, Item *item, bool asc)
1877
return add_to_list(thd, group_list, item, asc);
1881
st_select_lex_unit* st_select_lex::master_unit()
1883
return (st_select_lex_unit*) master;
1887
st_select_lex* st_select_lex::outer_select()
1889
return (st_select_lex*) master->get_master();
1893
bool st_select_lex::set_braces(bool value)
1636
bool Select_Lex::add_group_to_list(Session *session, Item *item, bool asc)
1638
return add_to_list(session, group_list, item, asc);
1641
Select_Lex_Unit* Select_Lex::master_unit()
1643
return (Select_Lex_Unit*) master;
1646
Select_Lex* Select_Lex::outer_select()
1648
return (Select_Lex*) master->get_master();
1651
bool Select_Lex::set_braces(bool value)
1900
bool st_select_lex::inc_in_sum_expr()
1657
bool Select_Lex::inc_in_sum_expr()
1907
uint st_select_lex::get_in_sum_expr()
1663
uint32_t Select_Lex::get_in_sum_expr()
1909
1665
return in_sum_expr;
1913
TABLE_LIST* st_select_lex::get_table_list()
1668
TableList* Select_Lex::get_table_list()
1915
return (TABLE_LIST*) table_list.first;
1670
return (TableList*) table_list.first;
1918
List<Item>* st_select_lex::get_item_list()
1673
List<Item>* Select_Lex::get_item_list()
1920
1675
return &item_list;
1923
uint32_t st_select_lex::get_table_join_options()
1678
uint32_t Select_Lex::get_table_join_options()
1925
1680
return table_join_options;
1929
bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num)
1683
bool Select_Lex::setup_ref_array(Session *session, uint32_t order_group_num)
1931
1685
if (ref_pointer_array)
1935
We have to create array in prepared statement memory if it is
1938
Query_arena *arena= thd->stmt_arena;
1939
1688
return (ref_pointer_array=
1940
(Item **)arena->alloc(sizeof(Item*) * (n_child_sum_items +
1689
(Item **)session->alloc(sizeof(Item*) * (n_child_sum_items +
1941
1690
item_list.elements +
1942
1691
select_n_having_items +
1943
1692
select_n_where_fields +
1944
1693
order_group_num)*5)) == 0;
1948
void st_select_lex_unit::print(String *str, enum_query_type query_type)
1696
void Select_Lex_Unit::print(String *str, enum_query_type query_type)
1950
1698
bool union_all= !union_distinct;
1951
for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select())
1699
for (Select_Lex *sl= first_select(); sl; sl= sl->next_select())
1953
1701
if (sl != first_select())
2090
1833
query_tables= 0;
2091
1834
query_tables_last= &query_tables;
2092
1835
query_tables_own_last= 0;
2096
We delay real initialization of hash (and therefore related
2097
memory allocation) until first insertion into this hash.
2099
hash_clear(&sroutines);
2101
else if (sroutines.records)
2103
/* Non-zero sroutines.records means that hash was initialized. */
2104
my_hash_reset(&sroutines);
2106
sroutines_list.empty();
2107
sroutines_list_own_last= sroutines_list.next;
2108
sroutines_list_own_elements= 0;
2109
binlog_stmt_flags= 0;
2114
Destroy Query_tables_list object with freeing all resources used by it.
2117
destroy_query_tables_list()
2120
void Query_tables_list::destroy_query_tables_list()
2122
hash_free(&sroutines);
2127
1839
Initialize LEX object.
2133
1845
LEX object initialized with this constructor can be used as part of
2134
THD object for which one can safely call open_tables(), lock_tables()
1846
Session object for which one can safely call open_tables(), lock_tables()
2135
1847
and close_thread_tables() functions. But it is not yet ready for
2136
1848
statement parsing. On should use lex_start() function to prepare LEX
2141
1852
:result(0), yacc_yyss(0), yacc_yyvs(0),
2142
1853
sql_command(SQLCOM_END), option_type(OPT_DEFAULT), is_lex_started(0)
2145
my_init_dynamic_array2(&plugins, sizeof(plugin_ref),
2146
plugins_static_buffer,
2147
INITIAL_LEX_PLUGIN_LIST_SIZE,
2148
INITIAL_LEX_PLUGIN_LIST_SIZE);
2149
1855
reset_query_tables_list(true);
2154
Check whether the merging algorithm can be used on this VIEW
2157
st_lex::can_be_merged()
2160
We can apply merge algorithm if it is single SELECT view with
2161
subqueries only in WHERE clause (we do not count SELECTs of underlying
2162
views, and second level subqueries) and we have not grpouping, ordering,
2163
HAVING clause, aggregate functions, DISTINCT clause, LIMIT clause and
2164
several underlying tables.
2167
false - only temporary table algorithm can be used
2168
true - merge algorithm can be used
2171
bool st_lex::can_be_merged()
2173
// TODO: do not forget implement case when select_lex.table_list.elements==0
2175
/* find non VIEW subqueries/unions */
2176
bool selects_allow_merge= select_lex.next_select() == 0;
2177
if (selects_allow_merge)
2179
for (SELECT_LEX_UNIT *tmp_unit= select_lex.first_inner_unit();
2181
tmp_unit= tmp_unit->next_unit())
2183
if (tmp_unit->first_select()->parent_lex == this &&
2184
(tmp_unit->item == 0 ||
2185
(tmp_unit->item->place() != IN_WHERE &&
2186
tmp_unit->item->place() != IN_ON)))
2188
selects_allow_merge= 0;
2194
return (selects_allow_merge &&
2195
select_lex.group_list.elements == 0 &&
2196
select_lex.having == 0 &&
2197
select_lex.with_sum_func == 0 &&
2198
select_lex.table_list.elements >= 1 &&
2199
!(select_lex.options & SELECT_DISTINCT) &&
2200
select_lex.select_limit == 0);
2205
check if command can use VIEW with MERGE algorithm (for top VIEWs)
2208
st_lex::can_use_merged()
2211
Only listed here commands can use merge algorithm in top level
2212
SELECT_LEX (for subqueries will be used merge algorithm if
2213
st_lex::can_not_use_merged() is not true).
2216
false - command can't use merged VIEWs
2217
true - VIEWs with MERGE algorithms can be used
2220
bool st_lex::can_use_merged()
2222
switch (sql_command)
2225
case SQLCOM_CREATE_TABLE:
2227
case SQLCOM_UPDATE_MULTI:
2229
case SQLCOM_DELETE_MULTI:
2231
case SQLCOM_INSERT_SELECT:
2232
case SQLCOM_REPLACE:
2233
case SQLCOM_REPLACE_SELECT:
2242
Check if command can't use merged views in any part of command
2245
st_lex::can_not_use_merged()
2248
Temporary table algorithm will be used on all SELECT levels for queries
2249
listed here (see also st_lex::can_use_merged()).
2252
false - command can't use merged VIEWs
2253
true - VIEWs with MERGE algorithms can be used
2256
bool st_lex::can_not_use_merged()
2258
switch (sql_command)
2261
SQLCOM_SHOW_FIELDS is necessary to make
2262
information schema tables working correctly with views.
2263
see get_schema_tables_result function
2265
case SQLCOM_SHOW_FIELDS:
2544
Save current state of Query_tables_list for this LEX, and prepare it
2545
for processing of new statemnt.
2548
reset_n_backup_query_tables_list()
2549
backup Pointer to Query_tables_list instance to be used for backup
2552
void st_lex::reset_n_backup_query_tables_list(Query_tables_list *backup __attribute__((unused)))
2558
Restore state of Query_tables_list for this LEX from backup.
2561
restore_backup_query_tables_list()
2562
backup Pointer to Query_tables_list instance used for backup
2565
void st_lex::restore_backup_query_tables_list(Query_tables_list *backup __attribute__((unused)))
2571
Checks for usage of routines and/or tables in a parsed statement
2574
st_lex:table_or_sp_used()
2577
false No routines and tables used
2578
true Either or both routines and tables are used.
2581
bool st_lex::table_or_sp_used()
2583
if (sroutines.records || query_tables)
2591
Do end-of-prepare fixup for list of tables and their merge-VIEWed tables
2594
fix_prepare_info_in_table_list()
2596
tbl List of tables to process
2599
Perform end-end-of prepare fixup for list of tables, if any of the tables
2600
is a merge-algorithm VIEW, recursively fix up its underlying tables as
2605
static void fix_prepare_info_in_table_list(THD *thd, TABLE_LIST *tbl)
2607
for (; tbl; tbl= tbl->next_local)
2611
tbl->prep_on_expr= tbl->on_expr;
2612
tbl->on_expr= tbl->on_expr->copy_andor_structure(thd);
2614
fix_prepare_info_in_table_list(thd, tbl->merge_underlying_list);
2620
There are st_select_lex::add_table_to_list &
2621
st_select_lex::set_lock_for_tables are in sql_parse.cc
2623
st_select_lex::print is in sql_select.cc
2625
st_select_lex_unit::prepare, st_select_lex_unit::exec,
2626
st_select_lex_unit::cleanup, st_select_lex_unit::reinit_exec_mechanism,
2627
st_select_lex_unit::change_result
2111
There are Select_Lex::add_table_to_list &
2112
Select_Lex::set_lock_for_tables are in sql_parse.cc
2114
Select_Lex::print is in sql_select.cc
2116
Select_Lex_Unit::prepare, Select_Lex_Unit::exec,
2117
Select_Lex_Unit::cleanup, Select_Lex_Unit::reinit_exec_mechanism,
2118
Select_Lex_Unit::change_result
2628
2119
are in sql_union.cc