17
17
/* A lexical scanner on a temporary buffer with a yacc interface */
19
19
#define DRIZZLE_LEX 1
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.
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.
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);
29
sys_var *trg_new_row_fake_var= (sys_var*) 0x01;
55
32
LEX_STRING constant for null-string to be used in parser and other places.
57
34
const LEX_STRING null_lex_str= {NULL, 0};
59
Lex_input_stream::Lex_input_stream(Session *session,
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,
60
115
const char* buffer,
61
116
unsigned int length)
174
233
The operation converts the specified text literal to the utf8 and appends
175
234
the result to the utf8-body.
177
@param session Thread context.
236
@param thd Thread context.
178
237
@param txt Text literal.
179
238
@param txt_cs Character set of the text literal.
180
239
@param end_ptr Pointer in the pre-processed buffer, to which
181
240
m_cpp_utf8_processed_ptr will be set in the end of the
184
void Lex_input_stream::body_utf8_append_literal(const LEX_STRING *txt,
244
void Lex_input_stream::body_utf8_append_literal(THD *thd,
245
const LEX_STRING *txt,
246
const CHARSET_INFO * const txt_cs,
185
247
const char *end_ptr)
187
249
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;
190
267
/* NOTE: utf_txt.length is in bytes, not in symbols. */
192
memcpy(m_body_utf8_ptr, txt->str, txt->length);
193
m_body_utf8_ptr += txt->length;
269
memcpy(m_body_utf8_ptr, utf_txt.str, utf_txt.length);
270
m_body_utf8_ptr += utf_txt.length;
194
271
*m_body_utf8_ptr= 0;
196
273
m_cpp_utf8_processed_ptr= end_ptr;
200
278
This is called before every query that is to be parsed.
201
279
Because of this, it's critical to not do too much things here.
202
280
(We already do too much here)
204
void lex_start(Session *session)
283
void lex_start(THD *thd)
206
LEX *lex= session->lex;
208
lex->session= lex->unit.session= session;
287
lex->thd= lex->unit.thd= thd;
210
289
lex->context_stack.empty();
211
290
lex->unit.init_query();
251
337
lex->nest_level=0 ;
252
338
lex->allow_sum_func= 0;
253
339
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;
255
355
lex->is_lex_started= true;
256
lex->statement= NULL;
259
359
void lex_end(LEX *lex)
261
361
if (lex->yacc_yyss)
263
free(lex->yacc_yyss);
264
free(lex->yacc_yyvs);
363
my_free(lex->yacc_yyss, MYF(0));
364
my_free(lex->yacc_yyvs, MYF(0));
265
365
lex->yacc_yyss= 0;
266
366
lex->yacc_yyvs= 0;
274
delete lex->statement;
369
/* release used plugins */
370
plugin_unlock_list(0, (plugin_ref*)lex->plugins.buffer,
371
lex->plugins.elements);
372
reset_dynamic(&lex->plugins);
277
static int find_keyword(Lex_input_stream *lip, uint32_t len, bool function)
378
static int find_keyword(Lex_input_stream *lip, uint len, bool function)
279
/* Plenty of memory for the largest lex symbol we have */
281
380
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;
287
const SYMBOL *symbol= lookup_symbol(tok_upper, len, function);
382
SYMBOL *symbol= get_hash_symbol(tok, len, function);
290
385
lip->yylval->symbol.symbol=symbol;
763
887
for (; state_map[c] == MY_LEX_SKIP ; c= lip->yyGet()) {};
765
889
if (start == lip->get_ptr() && c == '.' && ident_map[(uint8_t)lip->yyPeek()])
766
lip->next_state=MY_LEX_IDENT_SEP;
890
lip->next_state=MY_LEX_IDENT_SEP;
768
892
{ // '(' must follow directly if function
770
if ((tokval = find_keyword(lip, length, c == '(')))
772
lip->next_state= MY_LEX_START; // Allow signed numbers
773
return(tokval); // Was keyword
894
if ((tokval = find_keyword(lip, length, c == '(')))
896
lip->next_state= MY_LEX_START; // Allow signed numbers
897
return(tokval); // Was keyword
775
899
lip->yySkip(); // next state does a unget
777
901
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);
779
925
lip->body_utf8_append(lip->m_cpp_text_start);
781
lip->body_utf8_append_literal(&yylval->lex_str, lip->m_cpp_text_end);
927
lip->body_utf8_append_literal(thd, &yylval->lex_str, cs,
928
lip->m_cpp_text_end);
783
930
return(result_state); // IDENT or IDENT_QUOTED
827
974
while (my_isdigit(cs, (c = lip->yyGet()))) ;
828
975
if (!ident_map[c])
829
976
{ // Can't be identifier
830
state=MY_LEX_INT_OR_REAL;
977
state=MY_LEX_INT_OR_REAL;
833
980
if (c == 'e' || c == 'E')
835
// The following test is written this way to allow numbers of type 1e1
982
// The following test is written this way to allow numbers of type 1e1
836
983
if (my_isdigit(cs,lip->yyPeek()) ||
837
984
(c=(lip->yyGet())) == '+' || c == '-')
839
986
if (my_isdigit(cs,lip->yyPeek())) // Number must have digit after sign
842
989
while (my_isdigit(cs,lip->yyGet())) ;
843
990
yylval->lex_str=get_token(lip, 0, lip->yyLength());
850
997
case MY_LEX_IDENT_START: // We come here after '.'
851
998
result_state= IDENT;
999
#if defined(USE_MB) && defined(USE_MB_IDENT)
854
result_state= IDENT_QUOTED;
1002
result_state= IDENT_QUOTED;
855
1003
while (ident_map[c=lip->yyGet()])
857
1005
if (my_mbcharlen(cs, c) > 1)
859
int l= my_ismbchar(cs, lip->get_ptr() -1, lip->get_end_of_query());
1008
if ((l = my_ismbchar(cs,
1010
lip->get_end_of_query())) == 0)
862
1012
lip->skip_binary(l-1);
868
1019
for (result_state=0; ident_map[c= lip->yyGet()]; result_state|= c) {};
869
1020
/* If there were non-ASCII characters, mark that we must convert */
870
1021
result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT;
872
1023
if (c == '.' && ident_map[(uint8_t)lip->yyPeek()])
873
lip->next_state=MY_LEX_IDENT_SEP;// Next is '.'
1024
lip->next_state=MY_LEX_IDENT_SEP;// Next is '.'
875
1026
yylval->lex_str= get_token(lip, 0, lip->yyLength());
877
1028
lip->body_utf8_append(lip->m_cpp_text_start);
879
lip->body_utf8_append_literal(&yylval->lex_str, lip->m_cpp_text_end);
1030
lip->body_utf8_append_literal(thd, &yylval->lex_str, cs,
1031
lip->m_cpp_text_end);
881
1033
return(result_state);
883
1035
case MY_LEX_USER_VARIABLE_DELIMITER: // Found quote char
885
uint32_t double_quotes= 0;
1037
uint double_quotes= 0;
886
1038
char quote_char= c; // Used char
887
1039
while ((c=lip->yyGet()))
890
if ((var_length= my_mbcharlen(cs, c)) == 1)
894
if (lip->yyPeek() != quote_char)
901
else if (var_length < 1)
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)
903
1056
lip->skip_binary(var_length-1);
905
1059
if (double_quotes)
906
yylval->lex_str=get_quoted_token(lip, 1, lip->yyLength() - double_quotes -1, quote_char);
1060
yylval->lex_str=get_quoted_token(lip, 1,
1061
lip->yyLength() - double_quotes -1,
908
1064
yylval->lex_str=get_token(lip, 1, lip->yyLength() -1);
909
1065
if (c == quote_char)
910
1066
lip->yySkip(); // Skip end `
911
1067
lip->next_state= MY_LEX_START;
912
1069
lip->body_utf8_append(lip->m_cpp_text_start);
913
lip->body_utf8_append_literal(&yylval->lex_str, lip->m_cpp_text_end);
1071
lip->body_utf8_append_literal(thd, &yylval->lex_str, cs,
1072
lip->m_cpp_text_end);
914
1074
return(IDENT_QUOTED);
916
1076
case MY_LEX_INT_OR_REAL: // Complete int or incomplete real
918
1078
{ // Found complete integer number.
919
1079
yylval->lex_str=get_token(lip, 0, lip->yyLength());
920
return int_token(yylval->lex_str.str,yylval->lex_str.length);
1080
return int_token(yylval->lex_str.str,yylval->lex_str.length);
923
1083
case MY_LEX_REAL: // Incomplete real number
1234
1409
result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT;
1237
lip->next_state=MY_LEX_IDENT_SEP;
1412
lip->next_state=MY_LEX_IDENT_SEP;
1238
1413
length= lip->yyLength();
1239
1414
if (length == 0)
1240
1415
return(ABORT_SYM); // Names must be nonempty.
1241
1416
if ((tokval= find_keyword(lip, length,0)))
1243
1418
lip->yyUnget(); // Put back 'c'
1244
return(tokval); // Was keyword
1419
return(tokval); // Was keyword
1246
1421
yylval->lex_str=get_token(lip, 0, length);
1248
1423
lip->body_utf8_append(lip->m_cpp_text_start);
1250
lip->body_utf8_append_literal(&yylval->lex_str, lip->m_cpp_text_end);
1425
lip->body_utf8_append_literal(thd, &yylval->lex_str, cs,
1426
lip->m_cpp_text_end);
1252
1428
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);
1257
1476
void trim_whitespace(const CHARSET_INFO * const cs, LEX_STRING *str)
1603
1836
prohibit using LIMIT clause
1605
bool Select_Lex::test_limit()
1838
bool st_select_lex::test_limit()
1607
1840
if (select_limit != 0)
1609
1842
my_error(ER_NOT_SUPPORTED_YET, MYF(0),
1610
1843
"LIMIT & IN/ALL/ANY/SOME subquery");
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)
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)),
1633
1871
return(item_list.push_back(item));
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)
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)
1657
bool Select_Lex::inc_in_sum_expr()
1900
bool st_select_lex::inc_in_sum_expr()
1663
uint32_t Select_Lex::get_in_sum_expr()
1907
uint st_select_lex::get_in_sum_expr()
1665
1909
return in_sum_expr;
1668
TableList* Select_Lex::get_table_list()
1913
TABLE_LIST* st_select_lex::get_table_list()
1670
return (TableList*) table_list.first;
1915
return (TABLE_LIST*) table_list.first;
1673
List<Item>* Select_Lex::get_item_list()
1918
List<Item>* st_select_lex::get_item_list()
1675
1920
return &item_list;
1678
uint32_t Select_Lex::get_table_join_options()
1923
uint32_t st_select_lex::get_table_join_options()
1680
1925
return table_join_options;
1683
bool Select_Lex::setup_ref_array(Session *session, uint32_t order_group_num)
1929
bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num)
1685
1931
if (ref_pointer_array)
1935
We have to create array in prepared statement memory if it is
1938
Query_arena *arena= thd->stmt_arena;
1688
1939
return (ref_pointer_array=
1689
(Item **)session->alloc(sizeof(Item*) * (n_child_sum_items +
1940
(Item **)arena->alloc(sizeof(Item*) * (n_child_sum_items +
1690
1941
item_list.elements +
1691
1942
select_n_having_items +
1692
1943
select_n_where_fields +
1693
1944
order_group_num)*5)) == 0;
1696
void Select_Lex_Unit::print(String *str, enum_query_type query_type)
1948
void st_select_lex_unit::print(String *str, enum_query_type query_type)
1698
1950
bool union_all= !union_distinct;
1699
for (Select_Lex *sl= first_select(); sl; sl= sl->next_select())
1951
for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select())
1701
1953
if (sl != first_select())
1833
2090
query_tables= 0;
1834
2091
query_tables_last= &query_tables;
1835
2092
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);
1839
2127
Initialize LEX object.
1845
2133
LEX object initialized with this constructor can be used as part of
1846
Session object for which one can safely call open_tables(), lock_tables()
2134
THD object for which one can safely call open_tables(), lock_tables()
1847
2135
and close_thread_tables() functions. But it is not yet ready for
1848
2136
statement parsing. On should use lex_start() function to prepare LEX
1852
2141
:result(0), yacc_yyss(0), yacc_yyvs(0),
1853
2142
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);
1855
2149
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:
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
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
2119
2628
are in sql_union.cc