12
12
You should have received a copy of the GNU General Public License
13
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
17
17
/* A lexical scanner on a temporary buffer with a yacc interface */
20
#include "mysql_priv.h"
21
#include "item_create.h"
25
static int lex_one_token(void *arg, void *yythd);
28
We are using pointer to this variable for distinguishing between assignment
29
to NEW row field (when parsing trigger definition) and structured variable.
32
sys_var *trg_new_row_fake_var= (sys_var*) 0x01;
23
#include <drizzled/sql_reserved_words.h>
25
#include <drizzled/configmake.h>
26
#include <drizzled/item/num.h>
27
#include <drizzled/error.h>
28
#include <drizzled/session.h>
29
#include <drizzled/sql_base.h>
30
#include <drizzled/lookup_symbol.h>
31
#include <drizzled/index_hint.h>
32
#include <drizzled/select_result.h>
33
#include <drizzled/item/subselect.h>
34
#include <drizzled/statement.h>
35
#include <drizzled/sql_lex.h>
36
#include <drizzled/plugin.h>
37
#include <drizzled/lex_input_stream.h>
42
#include <drizzled/message/alter_table.pb.h>
48
/* Stay outside of the namespace because otherwise bison goes nuts */
49
int base_sql_lex(ParserType *arg, drizzled::Session *yysession);
53
static int lex_one_token(ParserType *arg, drizzled::Session *yysession);
35
LEX_STRING constant for null-string to be used in parser and other places.
37
const LEX_STRING null_lex_str= {NULL, 0};
39
/* Longest standard keyword name */
41
#define TOCK_NAME_LENGTH 24
44
The following data is based on the latin1 character set, and is only
45
used when comparing keywords
48
static uchar to_upper_lex[]=
50
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
51
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
52
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
53
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
54
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
55
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
56
96, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
57
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,123,124,125,126,127,
58
128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
59
144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
60
160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
61
176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
62
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
63
208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
64
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
65
208,209,210,211,212,213,214,247,216,217,218,219,220,221,222,255
69
Names of the index hints (for error messages). Keep in sync with
73
const char * index_hint_type_name[] =
80
inline int lex_casecmp(const char *s, const char *t, uint len)
83
to_upper_lex[(uchar) *s++] == to_upper_lex[(uchar) *t++]) ;
93
for (i=0 ; i < array_elements(symbols) ; i++)
94
symbols[i].length=(uchar) strlen(symbols[i].name);
95
for (i=0 ; i < array_elements(sql_functions) ; i++)
96
sql_functions[i].length=(uchar) strlen(sql_functions[i].name);
103
{ // Call this when daemon ends
109
st_parsing_options::reset()
111
allows_variable= true;
112
allows_select_into= true;
113
allows_select_procedure= true;
114
allows_derived= true;
117
Lex_input_stream::Lex_input_stream(THD *thd,
56
save order by and tables in own lists.
58
static void add_to_list(Session *session, SQL_LIST &list, Item *item, bool asc)
60
Order* order = new (session->mem) Order;
61
order->item_ptr= item;
62
order->item= &order->item_ptr;
66
order->counter_used= 0;
67
list.link_in_list((unsigned char*) order, (unsigned char**) &order->next);
70
Lex_input_stream::Lex_input_stream(Session *session,
118
71
const char* buffer,
72
unsigned int length) :
237
153
The operation converts the specified text literal to the utf8 and appends
238
154
the result to the utf8-body.
240
@param thd Thread context.
156
@param session Thread context.
241
157
@param txt Text literal.
242
158
@param txt_cs Character set of the text literal.
243
159
@param end_ptr Pointer in the pre-processed buffer, to which
244
160
m_cpp_utf8_processed_ptr will be set in the end of the
248
void Lex_input_stream::body_utf8_append_literal(THD *thd,
249
const LEX_STRING *txt,
250
CHARSET_INFO *txt_cs,
163
void Lex_input_stream::body_utf8_append_literal(str_ref txt, const char *end_ptr)
253
165
if (!m_cpp_utf8_processed_ptr)
258
if (!my_charset_same(txt_cs, &my_charset_utf8_general_ci))
260
thd->convert_string(&utf_txt,
261
&my_charset_utf8_general_ci,
262
txt->str, txt->length,
267
utf_txt.str= txt->str;
268
utf_txt.length= txt->length;
271
168
/* NOTE: utf_txt.length is in bytes, not in symbols. */
273
memcpy(m_body_utf8_ptr, utf_txt.str, utf_txt.length);
274
m_body_utf8_ptr += utf_txt.length;
170
memcpy(m_body_utf8_ptr, txt.data(), txt.size());
171
m_body_utf8_ptr += txt.size();
275
172
*m_body_utf8_ptr= 0;
277
174
m_cpp_utf8_processed_ptr= end_ptr;
282
178
This is called before every query that is to be parsed.
283
179
Because of this, it's critical to not do too much things here.
284
180
(We already do too much here)
287
void lex_start(THD *thd)
291
lex->thd= lex->unit.thd= thd;
293
lex->context_stack.empty();
182
void LEX::start(Session *arg)
187
void lex_start(Session *session)
189
LEX *lex= &session->lex();
191
lex->session= lex->unit.session= session;
193
lex->context_stack.clear();
294
194
lex->unit.init_query();
295
195
lex->unit.init_select();
296
196
/* 'parent_lex' is used in init_query() so it must be before it. */
297
197
lex->select_lex.parent_lex= lex;
298
198
lex->select_lex.init_query();
299
lex->value_list.empty();
300
lex->update_list.empty();
301
lex->param_list.empty();
302
lex->view_list.empty();
303
lex->auxiliary_table_list.empty();
199
lex->value_list.clear();
200
lex->update_list.clear();
201
lex->auxiliary_table_list.clear();
304
202
lex->unit.next= lex->unit.master=
305
203
lex->unit.link_next= lex->unit.return_to= 0;
306
204
lex->unit.prev= lex->unit.link_prev= 0;
309
207
lex->select_lex.master= &lex->unit;
310
208
lex->select_lex.prev= &lex->unit.slave;
311
209
lex->select_lex.link_next= lex->select_lex.slave= lex->select_lex.next= 0;
312
lex->select_lex.link_prev= (st_select_lex_node**)&(lex->all_selects_list);
210
lex->select_lex.link_prev= (Select_Lex_Node**)&(lex->all_selects_list);
313
211
lex->select_lex.options= 0;
314
212
lex->select_lex.init_order();
315
lex->select_lex.group_list.empty();
213
lex->select_lex.group_list.clear();
316
214
lex->describe= 0;
317
lex->subqueries= false;
318
215
lex->derived_tables= 0;
319
216
lex->lock_option= TL_READ;
320
217
lex->leaf_tables_insert= 0;
321
lex->parsing_options.reset();
322
lex->empty_field_list_on_rset= 0;
218
lex->var_list.clear();
323
219
lex->select_lex.select_number= 1;
325
221
lex->select_lex.in_sum_expr=0;
326
lex->select_lex.ftfunc_list_alloc.empty();
327
lex->select_lex.ftfunc_list= &lex->select_lex.ftfunc_list_alloc;
328
lex->select_lex.group_list.empty();
329
lex->select_lex.order_list.empty();
222
lex->select_lex.group_list.clear();
223
lex->select_lex.order_list.clear();
330
224
lex->sql_command= SQLCOM_END;
331
225
lex->duplicates= DUP_ERROR;
333
lex->proc_list.first= 0;
334
227
lex->escape_used= false;
335
228
lex->query_tables= 0;
336
229
lex->reset_query_tables_list(false);
337
230
lex->expr_allows_subselect= true;
338
231
lex->use_only_table_context= false;
233
lex->name.assign(NULL, 0);
342
234
lex->nest_level=0 ;
343
235
lex->allow_sum_func= 0;
344
236
lex->in_sum_func= NULL;
346
ok, there must be a better solution for this, long-term
347
I tried "bzero" in the sql_yacc.yy code, but that for
348
some reason made the values zero, even if they were set
350
lex->server_options.server_name= 0;
351
lex->server_options.server_name_length= 0;
352
lex->server_options.host= 0;
353
lex->server_options.db= 0;
354
lex->server_options.username= 0;
355
lex->server_options.password= 0;
356
lex->server_options.scheme= 0;
357
lex->server_options.socket= 0;
358
lex->server_options.owner= 0;
359
lex->server_options.port= -1;
361
239
lex->is_lex_started= true;
240
lex->statement= NULL;
242
lex->is_cross= false;
365
void lex_end(LEX *lex)
369
my_free(lex->yacc_yyss, MYF(0));
370
my_free(lex->yacc_yyvs, MYF(0));
375
/* release used plugins */
376
plugin_unlock_list(0, (plugin_ref*)lex->plugins.buffer,
377
lex->plugins.elements);
378
reset_dynamic(&lex->plugins);
257
safe_delete(_create_table);
258
safe_delete(_alter_table);
266
safe_delete(statement);
384
static int find_keyword(Lex_input_stream *lip, uint len, bool function)
269
static int find_keyword(Lex_input_stream *lip, uint32_t len, bool function)
271
/* Plenty of memory for the largest lex symbol we have */
386
273
const char *tok= lip->get_tok_start();
275
for (;tok_pos<len && tok_pos<63;tok_pos++)
276
tok_upper[tok_pos]= system_charset_info->toupper(tok[tok_pos]);
277
tok_upper[tok_pos]=0;
388
SYMBOL *symbol= get_hash_symbol(tok, len, function);
279
const SYMBOL *symbol= lookup_symbol(tok_upper, len, function);
391
282
lip->yylval->symbol.symbol=symbol;
395
286
return symbol->tok;
401
Check if name is a keyword
405
name checked name (must not be empty)
406
len length of checked name
410
1 name isn't a keyword
413
bool is_keyword(const char *name, uint len)
416
return get_hash_symbol(name,len,0)!=0;
419
bool is_lex_native_function(const LEX_STRING *name)
421
assert(name != NULL);
422
return (get_hash_symbol(name->str, name->length, 1) != 0);
425
292
/* make a copy of token before ptr and set yytoklen */
427
static LEX_STRING get_token(Lex_input_stream *lip, uint skip, uint length)
293
static lex_string_t get_token(Lex_input_stream *lip, uint32_t skip, uint32_t length)
430
295
lip->yyUnget(); // ptr points now after last token char
431
tmp.length=lip->yytoklen=length;
432
tmp.str= lip->m_thd->strmake(lip->get_tok_start() + skip, tmp.length);
296
lip->yytoklen= length;
298
tmp.assign(lip->m_session->mem.strdup(lip->get_tok_start() + skip, length), length);
434
299
lip->m_cpp_text_start= lip->get_cpp_tok_start() + skip;
435
lip->m_cpp_text_end= lip->m_cpp_text_start + tmp.length;
300
lip->m_cpp_text_end= lip->m_cpp_text_start + tmp.size();
442
There are no dangerous charsets in mysql for function
443
get_quoted_token yet. But it should be fixed in the
306
There are no dangerous charsets in mysql for function
307
get_quoted_token yet. But it should be fixed in the
444
308
future to operate multichar strings (like ucs2)
447
static LEX_STRING get_quoted_token(Lex_input_stream *lip,
449
uint length, char quote)
310
static lex_string_t get_quoted_token(Lex_input_stream *lip,
312
uint32_t length, char quote)
452
const char *from, *end;
454
314
lip->yyUnget(); // ptr points now after last token char
455
tmp.length= lip->yytoklen=length;
456
tmp.str=(char*) lip->m_thd->alloc(tmp.length+1);
457
from= lip->get_tok_start() + skip;
315
lip->yytoklen= length;
317
tmp.assign((char*)lip->m_session->mem.alloc(length + 1), length);
318
const char* from= lip->get_tok_start() + skip;
319
char* to= (char*)tmp.data();
320
const char* end= to+length;
461
322
lip->m_cpp_text_start= lip->get_cpp_tok_start() + skip;
462
323
lip->m_cpp_text_end= lip->m_cpp_text_start + length;
478
339
Return an unescaped text literal without quotes
479
340
Fix sometimes to do only one scan of the string
482
342
static char *get_text(Lex_input_stream *lip, int pre_skip, int post_skip)
484
register uchar c,sep;
486
CHARSET_INFO *cs= lip->m_thd->charset();
344
bool found_escape= false;
345
const charset_info_st* const cs= lip->m_session->charset();
488
347
lip->tok_bitmap= 0;
489
sep= lip->yyGetLast(); // String should end with this
348
unsigned char sep= lip->yyGetLast(); // String should end with this
349
while (not lip->eof())
351
unsigned char c= lip->yyGet();
493
352
lip->tok_bitmap|= c;
500
lip->get_end_of_query()))) {
501
lip->skip_binary(l-1);
356
int l= my_ismbchar(cs, lip->get_ptr() -1, lip->get_end_of_query());
359
lip->skip_binary(l-1);
507
365
{ // Escaped character
513
371
else if (c == sep)
515
373
if (c == lip->yyGet()) // Check if two separators in a row
517
found_escape=1; // duplicate. Remember for delete
375
found_escape= true; // duplicate. Remember for delete
523
381
/* Found end. Unescape and return string */
524
const char *str, *end;
527
str= lip->get_tok_start();
382
const char* str= lip->get_tok_start();
383
const char* end= lip->get_ptr();
529
384
/* Extract the text from the token */
532
387
assert(end >= str);
534
if (!(start= (char*) lip->m_thd->alloc((uint) (end-str)+1)))
535
return (char*) ""; // Sql_alloc has set error flag
389
char* start= (char*) lip->m_session->mem.alloc((uint32_t) (end-str)+1);
537
391
lip->m_cpp_text_start= lip->get_cpp_tok_start() + pre_skip;
538
392
lip->m_cpp_text_end= lip->get_cpp_ptr() - post_skip;
542
lip->yytoklen=(uint) (end-str);
543
memcpy(start,str,lip->yytoklen);
544
start[lip->yytoklen]=0;
396
lip->yytoklen= (uint32_t) (end-str);
397
memcpy(start, str, lip->yytoklen);
398
start[lip->yytoklen]= 0;
550
for (to=start ; str != end ; str++)
555
(l = my_ismbchar(cs, str, end))) {
562
if (!(lip->m_thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES) &&
563
*str == '\\' && str+1 != end)
579
*to++= 0; // Ascii null
581
case 'Z': // ^Z must be escaped on Win32
586
*to++= '\\'; // remember prefix for wildcard
404
for (to= start; str != end; str++)
408
int l= my_ismbchar(cs, str, end);
417
if (*str == '\\' && (str + 1) != end)
433
*to++= 0; // Ascii null
435
case 'Z': // ^Z must be escaped on Win32
440
*to++= '\\'; // remember prefix for wildcard
593
else if (*str == sep)
594
*to++= *str++; // Two ' or "
599
lip->yytoklen=(uint) (to-start);
447
else if (*str == sep)
448
*to++= *str++; // Two ' or "
453
lip->yytoklen= (uint32_t) (to - start);
921
739
for (; state_map[c] == MY_LEX_SKIP ; c= lip->yyGet()) {};
923
741
if (start == lip->get_ptr() && c == '.' && ident_map[(uint8_t)lip->yyPeek()])
924
lip->next_state=MY_LEX_IDENT_SEP;
742
lip->next_state=MY_LEX_IDENT_SEP;
926
744
{ // '(' must follow directly if function
928
if ((tokval = find_keyword(lip, length, c == '(')))
930
lip->next_state= MY_LEX_START; // Allow signed numbers
931
return(tokval); // Was keyword
746
if ((tokval = find_keyword(lip, length, c == '(')))
748
lip->next_state= MY_LEX_START; // Allow signed numbers
749
return(tokval); // Was keyword
933
751
lip->yySkip(); // next state does a unget
935
yylval->lex_str=get_token(lip, 0, length);
938
Note: "SELECT _bla AS 'alias'"
939
_bla should be considered as a IDENT if charset haven't been found.
940
So we don't use MYF(MY_WME) with get_charset_by_csname to avoid
944
if (yylval->lex_str.str[0] == '_')
946
CHARSET_INFO *cs= get_charset_by_csname(yylval->lex_str.str + 1,
947
MY_CS_PRIMARY, MYF(0));
951
lip->m_underscore_cs= cs;
953
lip->body_utf8_append(lip->m_cpp_text_start,
954
lip->get_cpp_tok_start() + length);
955
return(UNDERSCORE_CHARSET);
753
yylval->lex_str= get_token(lip, 0, length);
959
755
lip->body_utf8_append(lip->m_cpp_text_start);
961
lip->body_utf8_append_literal(thd, &yylval->lex_str, cs,
962
lip->m_cpp_text_end);
757
lip->body_utf8_append_literal(yylval->lex_str, lip->m_cpp_text_end);
964
759
return(result_state); // IDENT or IDENT_QUOTED
966
761
case MY_LEX_IDENT_SEP: // Found ident and now '.'
967
yylval->lex_str.str= (char*) lip->get_ptr();
968
yylval->lex_str.length= 1;
762
yylval->lex_str.assign(lip->get_ptr(), 1);
969
763
c= lip->yyGet(); // should be '.'
970
764
lip->next_state= MY_LEX_IDENT_START;// Next is an ident (not a keyword)
971
765
if (!ident_map[(uint8_t)lip->yyPeek()]) // Probably ` or "
972
lip->next_state= MY_LEX_START;
766
lip->next_state= MY_LEX_START;
975
769
case MY_LEX_NUMBER_IDENT: // number or ident which num-start
1008
while (my_isdigit(cs, (c = lip->yyGet()))) ;
802
while (cs->isdigit((c = lip->yyGet()))) ;
1009
803
if (!ident_map[c])
1010
804
{ // Can't be identifier
1011
state=MY_LEX_INT_OR_REAL;
805
state=MY_LEX_INT_OR_REAL;
1014
808
if (c == 'e' || c == 'E')
1016
// The following test is written this way to allow numbers of type 1e1
1017
if (my_isdigit(cs,lip->yyPeek()) ||
810
// The following test is written this way to allow numbers of type 1e1
811
if (cs->isdigit(lip->yyPeek()) ||
1018
812
(c=(lip->yyGet())) == '+' || c == '-')
1020
if (my_isdigit(cs,lip->yyPeek())) // Number must have digit after sign
814
if (cs->isdigit(lip->yyPeek())) // Number must have digit after sign
1023
while (my_isdigit(cs,lip->yyGet())) ;
1024
yylval->lex_str=get_token(lip, 0, lip->yyLength());
817
while (cs->isdigit(lip->yyGet())) ;
818
yylval->lex_str= get_token(lip, 0, lip->yyLength());
1031
825
case MY_LEX_IDENT_START: // We come here after '.'
1032
826
result_state= IDENT;
1033
#if defined(USE_MB) && defined(USE_MB_IDENT)
1036
result_state= IDENT_QUOTED;
829
result_state= IDENT_QUOTED;
1037
830
while (ident_map[c=lip->yyGet()])
1039
832
if (my_mbcharlen(cs, c) > 1)
1042
if ((l = my_ismbchar(cs,
1044
lip->get_end_of_query())) == 0)
834
int l= my_ismbchar(cs, lip->get_ptr() -1, lip->get_end_of_query());
1046
837
lip->skip_binary(l-1);
1053
843
for (result_state=0; ident_map[c= lip->yyGet()]; result_state|= c) {};
1054
844
/* If there were non-ASCII characters, mark that we must convert */
1055
845
result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT;
1057
847
if (c == '.' && ident_map[(uint8_t)lip->yyPeek()])
1058
lip->next_state=MY_LEX_IDENT_SEP;// Next is '.'
848
lip->next_state=MY_LEX_IDENT_SEP;// Next is '.'
1060
850
yylval->lex_str= get_token(lip, 0, lip->yyLength());
1062
852
lip->body_utf8_append(lip->m_cpp_text_start);
1064
lip->body_utf8_append_literal(thd, &yylval->lex_str, cs,
1065
lip->m_cpp_text_end);
853
lip->body_utf8_append_literal(yylval->lex_str, lip->m_cpp_text_end);
1067
855
return(result_state);
1069
857
case MY_LEX_USER_VARIABLE_DELIMITER: // Found quote char
1071
uint double_quotes= 0;
859
uint32_t double_quotes= 0;
1072
860
char quote_char= c; // Used char
1073
861
while ((c=lip->yyGet()))
1076
if ((var_length= my_mbcharlen(cs, c)) == 1)
1078
if (c == quote_char)
1080
if (lip->yyPeek() != quote_char)
1088
else if (var_length < 1)
864
if ((var_length= my_mbcharlen(cs, c)) == 1)
868
if (lip->yyPeek() != quote_char)
875
else if (var_length < 1)
1090
877
lip->skip_binary(var_length-1);
1094
yylval->lex_str=get_quoted_token(lip, 1,
1095
lip->yyLength() - double_quotes -1,
1098
yylval->lex_str=get_token(lip, 1, lip->yyLength() -1);
879
yylval->lex_str= double_quotes
880
? get_quoted_token(lip, 1, lip->yyLength() - double_quotes - 1, quote_char)
881
: get_token(lip, 1, lip->yyLength() - 1);
1099
882
if (c == quote_char)
1100
883
lip->yySkip(); // Skip end `
1101
884
lip->next_state= MY_LEX_START;
1103
885
lip->body_utf8_append(lip->m_cpp_text_start);
1105
lip->body_utf8_append_literal(thd, &yylval->lex_str, cs,
1106
lip->m_cpp_text_end);
1108
return(IDENT_QUOTED);
886
lip->body_utf8_append_literal(yylval->lex_str, lip->m_cpp_text_end);
1110
889
case MY_LEX_INT_OR_REAL: // Complete int or incomplete real
1112
891
{ // Found complete integer number.
1113
892
yylval->lex_str=get_token(lip, 0, lip->yyLength());
1114
return int_token(yylval->lex_str.str,yylval->lex_str.length);
893
return int_token(yylval->lex_str.data(), yylval->lex_str.size());
1117
896
case MY_LEX_REAL: // Incomplete real number
1118
while (my_isdigit(cs,c = lip->yyGet())) ;
897
while (cs->isdigit(c = lip->yyGet())) ;
1120
899
if (c == 'e' || c == 'E')
1122
901
c = lip->yyGet();
1123
if (c == '-' || c == '+')
1124
c = lip->yyGet(); // Skip sign
1125
if (!my_isdigit(cs,c))
1126
{ // No digit after sign
1130
while (my_isdigit(cs,lip->yyGet())) ;
902
if (c == '-' || c == '+')
903
c = lip->yyGet(); // Skip sign
905
{ // No digit after sign
909
while (cs->isdigit(lip->yyGet())) ;
1131
910
yylval->lex_str=get_token(lip, 0, lip->yyLength());
1134
913
yylval->lex_str=get_token(lip, 0, lip->yyLength());
1135
914
return(DECIMAL_NUM);
1137
916
case MY_LEX_HEX_NUMBER: // Found x'hexstring'
1138
917
lip->yySkip(); // Accept opening '
1139
while (my_isxdigit(cs, (c= lip->yyGet()))) ;
918
while (cs->isxdigit((c= lip->yyGet()))) ;
1141
920
return(ABORT_SYM); // Illegal hex constant
1142
921
lip->yySkip(); // Accept closing '
1143
922
length= lip->yyLength(); // Length of hexnum+3
1144
if ((length % 2) == 0)
1145
return(ABORT_SYM); // odd number of hex digits
924
return ABORT_SYM; // odd number of hex digits
1146
925
yylval->lex_str=get_token(lip,
1148
927
length-3); // don't count x' and last '
1388
1155
state=MY_LEX_CHAR;
1390
1158
case MY_LEX_END:
1391
1159
lip->next_state=MY_LEX_END;
1392
return(0); // We found end of input last time
1160
return false; // We found end of input last time
1394
1162
/* Actually real shouldn't start with . but allow them anyhow */
1395
1164
case MY_LEX_REAL_OR_POINT:
1396
if (my_isdigit(cs,lip->yyPeek()))
1397
state = MY_LEX_REAL; // Real
1165
if (cs->isdigit(lip->yyPeek()))
1166
state= MY_LEX_REAL; // Real
1400
state= MY_LEX_IDENT_SEP; // return '.'
1169
state= MY_LEX_IDENT_SEP; // return '.'
1401
1170
lip->yyUnget(); // Put back '.'
1404
1174
case MY_LEX_USER_END: // end '@' of user@hostname
1405
1175
switch (state_map[(uint8_t)lip->yyPeek()]) {
1406
1176
case MY_LEX_STRING:
1407
1177
case MY_LEX_USER_VARIABLE_DELIMITER:
1408
1178
case MY_LEX_STRING_OR_DELIMITER:
1410
1180
case MY_LEX_USER_END:
1411
lip->next_state=MY_LEX_SYSTEM_VAR;
1181
lip->next_state=MY_LEX_SYSTEM_VAR;
1414
lip->next_state=MY_LEX_HOSTNAME;
1184
lip->next_state=MY_LEX_HOSTNAME;
1417
yylval->lex_str.str=(char*) lip->get_ptr();
1418
yylval->lex_str.length=1;
1187
yylval->lex_str.assign(lip->get_ptr(), 1);
1420
1190
case MY_LEX_HOSTNAME: // end '@' of user@hostname
1421
1191
for (c=lip->yyGet() ;
1422
my_isalnum(cs,c) || c == '.' || c == '_' || c == '$';
1192
cs->isalnum(c) || c == '.' || c == '_' || c == '$';
1423
1193
c= lip->yyGet()) ;
1424
1194
yylval->lex_str=get_token(lip, 0, lip->yyLength());
1425
1195
return(LEX_HOSTNAME);
1426
1197
case MY_LEX_SYSTEM_VAR:
1427
yylval->lex_str.str=(char*) lip->get_ptr();
1428
yylval->lex_str.length=1;
1198
yylval->lex_str.assign(lip->get_ptr(), 1);
1429
1199
lip->yySkip(); // Skip '@'
1430
1200
lip->next_state= (state_map[(uint8_t)lip->yyPeek()] ==
1431
1201
MY_LEX_USER_VARIABLE_DELIMITER ?
1432
1202
MY_LEX_OPERATOR_OR_IDENT :
1433
1203
MY_LEX_IDENT_OR_KEYWORD);
1434
1204
return((int) '@');
1435
1206
case MY_LEX_IDENT_OR_KEYWORD:
1437
We come here when we have found two '@' in a row.
1438
We should now be able to handle:
1439
[(global | local | session) .]variable_name
1208
We come here when we have found two '@' in a row.
1209
We should now be able to handle:
1210
[(global | local | session) .]variable_name
1442
1213
for (result_state= 0; ident_map[c= lip->yyGet()]; result_state|= c) {};
1444
1215
result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT;
1447
lip->next_state=MY_LEX_IDENT_SEP;
1218
lip->next_state=MY_LEX_IDENT_SEP;
1448
1220
length= lip->yyLength();
1449
1221
if (length == 0)
1450
1222
return(ABORT_SYM); // Names must be nonempty.
1451
1224
if ((tokval= find_keyword(lip, length,0)))
1453
1226
lip->yyUnget(); // Put back 'c'
1454
return(tokval); // Was keyword
1227
return(tokval); // Was keyword
1456
1229
yylval->lex_str=get_token(lip, 0, length);
1458
1231
lip->body_utf8_append(lip->m_cpp_text_start);
1460
lip->body_utf8_append_literal(thd, &yylval->lex_str, cs,
1461
lip->m_cpp_text_end);
1463
return(result_state);
1232
lip->body_utf8_append_literal(yylval->lex_str, lip->m_cpp_text_end);
1234
return result_state;
1470
Construct a copy of this object to be used for mysql_alter_table
1471
and mysql_create_table.
1473
Historically, these two functions modify their Alter_info
1474
arguments. This behaviour breaks re-execution of prepared
1475
statements and stored procedures and is compensated by always
1476
supplying a copy of Alter_info to these functions.
1478
@return You need to use check the error in THD for out
1479
of memory condition after calling this function.
1482
Alter_info::Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root)
1483
:drop_list(rhs.drop_list, mem_root),
1484
alter_list(rhs.alter_list, mem_root),
1485
key_list(rhs.key_list, mem_root),
1486
create_list(rhs.create_list, mem_root),
1488
keys_onoff(rhs.keys_onoff),
1489
tablespace_op(rhs.tablespace_op),
1490
no_parts(rhs.no_parts),
1491
build_method(rhs.build_method),
1492
datetime_field(rhs.datetime_field),
1493
error_if_not_empty(rhs.error_if_not_empty)
1496
Make deep copies of used objects.
1497
This is not a fully deep copy - clone() implementations
1498
of Alter_drop, Alter_column, Key, foreign_key, Key_part_spec
1499
do not copy string constants. At the same length the only
1500
reason we make a copy currently is that ALTER/CREATE TABLE
1501
code changes input Alter_info definitions, but string
1502
constants never change.
1504
list_copy_and_replace_each_value(drop_list, mem_root);
1505
list_copy_and_replace_each_value(alter_list, mem_root);
1506
list_copy_and_replace_each_value(key_list, mem_root);
1507
list_copy_and_replace_each_value(create_list, mem_root);
1511
void trim_whitespace(CHARSET_INFO *cs, LEX_STRING *str)
1515
This code assumes that there are no multi-bytes characters
1516
that can be considered white-space.
1519
while ((str->length > 0) && (my_isspace(cs, str->str[0])))
1527
Also, parsing backward is not safe with multi bytes characters
1529
while ((str->length > 0) && (my_isspace(cs, str->str[str->length-1])))
1537
st_select_lex structures initialisations
1240
Select_Lex structures initialisations
1540
void st_select_lex_node::init_query()
1242
void Select_Lex_Node::init_query()
1543
1245
linkage= UNSPECIFIED_TYPE;
1544
1246
no_error= no_table_names_allowed= 0;
1548
void st_select_lex_node::init_select()
1552
void st_select_lex_unit::init_query()
1554
st_select_lex_node::init_query();
1247
uncacheable.reset();
1250
void Select_Lex_Node::init_select()
1254
void Select_Lex_Unit::init_query()
1256
Select_Lex_Node::init_query();
1555
1257
linkage= GLOBAL_OPTIONS_TYPE;
1556
1258
global_parameters= first_select();
1557
1259
select_limit_cnt= HA_POS_ERROR;
1801
1493
next->prev= prev;
1806
st_select_lex_node::mark_as_dependent mark all st_select_lex struct from
1807
this to 'last' as dependent
1810
last - pointer to last st_select_lex struct, before wich all
1811
st_select_lex have to be marked as dependent
1814
'last' should be reachable from this st_select_lex_node
1817
void st_select_lex::mark_as_dependent(st_select_lex *last)
1497
* Mark all Select_Lex struct from this to 'last' as dependent
1499
* @param Pointer to last Select_Lex struct, before wich all
1500
* Select_Lex have to be marked as dependent
1501
* @note 'last' should be reachable from this Select_Lex_Node
1503
void Select_Lex::mark_as_dependent(Select_Lex *last)
1820
1506
Mark all selects from resolved to 1 before select where was
1821
1507
found table as depended (of select where was found table)
1823
for (SELECT_LEX *s= this;
1509
for (Select_Lex *s= this;
1824
1510
s && s != last;
1825
1511
s= s->outer_select())
1827
if (!(s->uncacheable & UNCACHEABLE_DEPENDENT))
1513
if (! (s->uncacheable.test(UNCACHEABLE_DEPENDENT)))
1829
1515
// Select is dependent of outer select
1830
s->uncacheable= (s->uncacheable & ~UNCACHEABLE_UNITED) |
1831
UNCACHEABLE_DEPENDENT;
1832
SELECT_LEX_UNIT *munit= s->master_unit();
1833
munit->uncacheable= (munit->uncacheable & ~UNCACHEABLE_UNITED) |
1834
UNCACHEABLE_DEPENDENT;
1835
for (SELECT_LEX *sl= munit->first_select(); sl ; sl= sl->next_select())
1516
s->uncacheable.set(UNCACHEABLE_DEPENDENT);
1517
s->uncacheable.set(UNCACHEABLE_UNITED);
1518
Select_Lex_Unit *munit= s->master_unit();
1519
munit->uncacheable.set(UNCACHEABLE_UNITED);
1520
munit->uncacheable.set(UNCACHEABLE_DEPENDENT);
1521
for (Select_Lex *sl= munit->first_select(); sl ; sl= sl->next_select())
1838
!(sl->uncacheable & (UNCACHEABLE_DEPENDENT | UNCACHEABLE_UNITED)))
1839
sl->uncacheable|= UNCACHEABLE_UNITED;
1524
! (sl->uncacheable.test(UNCACHEABLE_DEPENDENT) && sl->uncacheable.test(UNCACHEABLE_UNITED)))
1525
sl->uncacheable.set(UNCACHEABLE_UNITED);
1842
1528
s->is_correlated= true;
1849
bool st_select_lex_node::set_braces(bool value __attribute__((__unused__)))
1851
bool st_select_lex_node::inc_in_sum_expr() { return 1; }
1852
uint st_select_lex_node::get_in_sum_expr() { return 0; }
1853
TABLE_LIST* st_select_lex_node::get_table_list() { return 0; }
1854
List<Item>* st_select_lex_node::get_item_list() { return 0; }
1855
TABLE_LIST *st_select_lex_node::add_table_to_list (THD *thd __attribute__((__unused__)),
1856
Table_ident *table __attribute__((__unused__)),
1857
LEX_STRING *alias __attribute__((__unused__)),
1858
ulong table_join_options __attribute__((__unused__)),
1859
thr_lock_type flags __attribute__((__unused__)),
1860
List<Index_hint> *hints __attribute__((__unused__)),
1861
LEX_STRING *option __attribute__((__unused__)))
1865
ulong st_select_lex_node::get_table_join_options()
1535
bool Select_Lex_Node::set_braces(bool)
1538
bool Select_Lex_Node::inc_in_sum_expr()
1541
uint32_t Select_Lex_Node::get_in_sum_expr()
1544
TableList* Select_Lex_Node::get_table_list()
1547
List<Item>* Select_Lex_Node::get_item_list()
1550
TableList *Select_Lex_Node::add_table_to_list(Session *,
1553
const bitset<NUM_OF_TABLE_OPTIONS>&,
1871
1563
prohibit using LIMIT clause
1873
bool st_select_lex::test_limit()
1565
bool Select_Lex::test_limit()
1875
1567
if (select_limit != 0)
1877
1569
my_error(ER_NOT_SUPPORTED_YET, MYF(0),
1878
1570
"LIMIT & IN/ALL/ANY/SOME subquery");
1885
st_select_lex_unit* st_select_lex_unit::master_unit()
1891
st_select_lex* st_select_lex_unit::outer_select()
1893
return (st_select_lex*) master;
1897
bool st_select_lex::add_order_to_list(THD *thd, Item *item, bool asc)
1899
return add_to_list(thd, order_list, item, asc);
1903
bool st_select_lex::add_item_to_list(THD *thd __attribute__((__unused__)),
1906
return(item_list.push_back(item));
1910
bool st_select_lex::add_group_to_list(THD *thd, Item *item, bool asc)
1912
return add_to_list(thd, group_list, item, asc);
1916
st_select_lex_unit* st_select_lex::master_unit()
1918
return (st_select_lex_unit*) master;
1922
st_select_lex* st_select_lex::outer_select()
1924
return (st_select_lex*) master->get_master();
1928
bool st_select_lex::set_braces(bool value)
1576
Select_Lex_Unit* Select_Lex_Unit::master_unit()
1581
Select_Lex* Select_Lex_Unit::outer_select()
1583
return (Select_Lex*) master;
1586
void Select_Lex::add_order_to_list(Session *session, Item *item, bool asc)
1588
add_to_list(session, order_list, item, asc);
1591
void Select_Lex::add_item_to_list(Session *, Item *item)
1593
item_list.push_back(item);
1596
void Select_Lex::add_group_to_list(Session *session, Item *item, bool asc)
1598
add_to_list(session, group_list, item, asc);
1601
Select_Lex_Unit* Select_Lex::master_unit()
1603
return (Select_Lex_Unit*) master;
1606
Select_Lex* Select_Lex::outer_select()
1608
return (Select_Lex*) master->get_master();
1611
bool Select_Lex::set_braces(bool value)
1935
bool st_select_lex::inc_in_sum_expr()
1617
bool Select_Lex::inc_in_sum_expr()
1942
uint st_select_lex::get_in_sum_expr()
1623
uint32_t Select_Lex::get_in_sum_expr()
1944
1625
return in_sum_expr;
1948
TABLE_LIST* st_select_lex::get_table_list()
1628
TableList* Select_Lex::get_table_list()
1950
return (TABLE_LIST*) table_list.first;
1630
return (TableList*) table_list.first;
1953
List<Item>* st_select_lex::get_item_list()
1633
List<Item>* Select_Lex::get_item_list()
1955
1635
return &item_list;
1958
ulong st_select_lex::get_table_join_options()
1960
return table_join_options;
1964
bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num)
1966
if (ref_pointer_array)
1970
We have to create array in prepared statement memory if it is
1973
Query_arena *arena= thd->stmt_arena;
1974
return (ref_pointer_array=
1975
(Item **)arena->alloc(sizeof(Item*) * (n_child_sum_items +
1976
item_list.elements +
1977
select_n_having_items +
1978
select_n_where_fields +
1979
order_group_num)*5)) == 0;
1983
void st_select_lex_unit::print(String *str, enum_query_type query_type)
1638
void Select_Lex::setup_ref_array(Session *session, uint32_t order_group_num)
1640
if (not ref_pointer_array)
1641
ref_pointer_array= new (session->mem) Item*[5 * (n_child_sum_items + item_list.size() + select_n_having_items + select_n_where_fields + order_group_num)];
1644
void Select_Lex_Unit::print(String *str)
1985
1646
bool union_all= !union_distinct;
1986
for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select())
1647
for (Select_Lex *sl= first_select(); sl; sl= sl->next_select())
1988
1649
if (sl != first_select())
2125
1769
query_tables= 0;
2126
1770
query_tables_last= &query_tables;
2127
1771
query_tables_own_last= 0;
2131
We delay real initialization of hash (and therefore related
2132
memory allocation) until first insertion into this hash.
2134
hash_clear(&sroutines);
2136
else if (sroutines.records)
2138
/* Non-zero sroutines.records means that hash was initialized. */
2139
my_hash_reset(&sroutines);
2141
sroutines_list.empty();
2142
sroutines_list_own_last= sroutines_list.next;
2143
sroutines_list_own_elements= 0;
2144
binlog_stmt_flags= 0;
2149
Destroy Query_tables_list object with freeing all resources used by it.
2152
destroy_query_tables_list()
2155
void Query_tables_list::destroy_query_tables_list()
2157
hash_free(&sroutines);
2162
1775
Initialize LEX object.
2168
1781
LEX object initialized with this constructor can be used as part of
2169
THD object for which one can safely call open_tables(), lock_tables()
1782
Session object for which one can safely call open_tables(), lock_tables()
2170
1783
and close_thread_tables() functions. But it is not yet ready for
2171
1784
statement parsing. On should use lex_start() function to prepare LEX
2176
:result(0), yacc_yyss(0), yacc_yyvs(0),
2177
sql_command(SQLCOM_END), option_type(OPT_DEFAULT), is_lex_started(0)
1794
sql_command(SQLCOM_END),
1796
option_type(OPT_DEFAULT),
1799
sum_expr_used(false),
1800
_create_table(NULL),
1802
_create_field(NULL),
2180
my_init_dynamic_array2(&plugins, sizeof(plugin_ref),
2181
plugins_static_buffer,
2182
INITIAL_LEX_PLUGIN_LIST_SIZE,
2183
INITIAL_LEX_PLUGIN_LIST_SIZE);
2184
1805
reset_query_tables_list(true);
2189
Check whether the merging algorithm can be used on this VIEW
2192
st_lex::can_be_merged()
2195
We can apply merge algorithm if it is single SELECT view with
2196
subqueries only in WHERE clause (we do not count SELECTs of underlying
2197
views, and second level subqueries) and we have not grpouping, ordering,
2198
HAVING clause, aggregate functions, DISTINCT clause, LIMIT clause and
2199
several underlying tables.
2202
false - only temporary table algorithm can be used
2203
true - merge algorithm can be used
2206
bool st_lex::can_be_merged()
2208
// TODO: do not forget implement case when select_lex.table_list.elements==0
2210
/* find non VIEW subqueries/unions */
2211
bool selects_allow_merge= select_lex.next_select() == 0;
2212
if (selects_allow_merge)
2214
for (SELECT_LEX_UNIT *tmp_unit= select_lex.first_inner_unit();
2216
tmp_unit= tmp_unit->next_unit())
2218
if (tmp_unit->first_select()->parent_lex == this &&
2219
(tmp_unit->item == 0 ||
2220
(tmp_unit->item->place() != IN_WHERE &&
2221
tmp_unit->item->place() != IN_ON)))
2223
selects_allow_merge= 0;
2229
return (selects_allow_merge &&
2230
select_lex.group_list.elements == 0 &&
2231
select_lex.having == 0 &&
2232
select_lex.with_sum_func == 0 &&
2233
select_lex.table_list.elements >= 1 &&
2234
!(select_lex.options & SELECT_DISTINCT) &&
2235
select_lex.select_limit == 0);
2240
check if command can use VIEW with MERGE algorithm (for top VIEWs)
2243
st_lex::can_use_merged()
2246
Only listed here commands can use merge algorithm in top level
2247
SELECT_LEX (for subqueries will be used merge algorithm if
2248
st_lex::can_not_use_merged() is not true).
2251
false - command can't use merged VIEWs
2252
true - VIEWs with MERGE algorithms can be used
2255
bool st_lex::can_use_merged()
2257
switch (sql_command)
2260
case SQLCOM_CREATE_TABLE:
2262
case SQLCOM_UPDATE_MULTI:
2264
case SQLCOM_DELETE_MULTI:
2266
case SQLCOM_INSERT_SELECT:
2267
case SQLCOM_REPLACE:
2268
case SQLCOM_REPLACE_SELECT:
2277
Check if command can't use merged views in any part of command
2280
st_lex::can_not_use_merged()
2283
Temporary table algorithm will be used on all SELECT levels for queries
2284
listed here (see also st_lex::can_use_merged()).
2287
false - command can't use merged VIEWs
2288
true - VIEWs with MERGE algorithms can be used
2291
bool st_lex::can_not_use_merged()
2293
switch (sql_command)
2296
SQLCOM_SHOW_FIELDS is necessary to make
2297
information schema tables working correctly with views.
2298
see get_schema_tables_result function
2300
case SQLCOM_SHOW_FIELDS:
2308
Detect that we need only table structure of derived table/view
2311
only_view_structure()
2314
true yes, we need only structure
2315
false no, we need data
2318
bool st_lex::only_view_structure()
2320
switch (sql_command) {
2321
case SQLCOM_SHOW_CREATE:
2322
case SQLCOM_SHOW_TABLES:
2323
case SQLCOM_SHOW_FIELDS:
2332
Should Items_ident be printed correctly
2335
need_correct_ident()
2338
true yes, we need only structure
2339
false no, we need data
2343
bool st_lex::need_correct_ident()
2347
case SQLCOM_SHOW_CREATE:
2348
case SQLCOM_SHOW_TABLES:
2356
Get effective type of CHECK OPTION for given view
2359
get_effective_with_check()
2363
It have not sense to set CHECK OPTION for SELECT satement or subqueries,
2367
VIEW_CHECK_NONE no need CHECK OPTION
2368
VIEW_CHECK_LOCAL CHECK OPTION LOCAL
2369
VIEW_CHECK_CASCADED CHECK OPTION CASCADED
2372
uint8 st_lex::get_effective_with_check(TABLE_LIST *view __attribute__((__unused__)))
2379
This method should be called only during parsing.
2380
It is aware of compound statements (stored routine bodies)
2381
and will initialize the destination with the default
2382
database of the stored routine, rather than the default
2383
database of the connection it is parsed in.
2384
E.g. if one has no current database selected, or current database
2385
set to 'bar' and then issues:
2387
CREATE PROCEDURE foo.p1() BEGIN SELECT * FROM t1 END//
2389
t1 is meant to refer to foo.t1, not to bar.t1.
2391
This method is needed to support this rule.
2393
@return true in case of error (parsing should be aborted, false in
2398
st_lex::copy_db_to(char **p_db, size_t *p_db_length) const
2400
return thd->copy_db_to(p_db, p_db_length);
2404
1809
initialize limit counters
2407
st_select_lex_unit::set_limit()
2408
values - SELECT_LEX with initial values for counters
1812
Select_Lex_Unit::set_limit()
1813
values - Select_Lex with initial values for counters
2411
void st_select_lex_unit::set_limit(st_select_lex *sl)
1815
void Select_Lex_Unit::set_limit(Select_Lex *sl)
2413
1817
ha_rows select_limit_val;
2416
1820
val= sl->select_limit ? sl->select_limit->val_uint() : HA_POS_ERROR;
2417
1821
select_limit_val= (ha_rows)val;
2420
Check for overflow : ha_rows can be smaller then ulonglong if
1823
Check for overflow : ha_rows can be smaller then uint64_t if
2421
1824
BIG_TABLES is off.
2423
if (val != (ulonglong)select_limit_val)
1826
if (val != (uint64_t)select_limit_val)
2424
1827
select_limit_val= HA_POS_ERROR;
2426
1828
offset_limit_cnt= (ha_rows)(sl->offset_limit ? sl->offset_limit->val_uint() :
2428
1830
select_limit_cnt= select_limit_val + offset_limit_cnt;
2429
1831
if (select_limit_cnt < select_limit_val)
2430
1832
select_limit_cnt= HA_POS_ERROR; // no limit
2435
1836
Unlink the first table from the global table list and the first table from
2436
1837
outer select (lex->select_lex) local list
2601
Save current state of Query_tables_list for this LEX, and prepare it
2602
for processing of new statemnt.
2605
reset_n_backup_query_tables_list()
2606
backup Pointer to Query_tables_list instance to be used for backup
2609
void st_lex::reset_n_backup_query_tables_list(Query_tables_list *backup __attribute__((__unused__)))
2615
Restore state of Query_tables_list for this LEX from backup.
2618
restore_backup_query_tables_list()
2619
backup Pointer to Query_tables_list instance used for backup
2622
void st_lex::restore_backup_query_tables_list(Query_tables_list *backup __attribute__((__unused__)))
2628
Checks for usage of routines and/or tables in a parsed statement
2631
st_lex:table_or_sp_used()
2634
false No routines and tables used
2635
true Either or both routines and tables are used.
2638
bool st_lex::table_or_sp_used()
2640
if (sroutines.records || query_tables)
2648
Do end-of-prepare fixup for list of tables and their merge-VIEWed tables
2651
fix_prepare_info_in_table_list()
2653
tbl List of tables to process
2656
Perform end-end-of prepare fixup for list of tables, if any of the tables
2657
is a merge-algorithm VIEW, recursively fix up its underlying tables as
2662
static void fix_prepare_info_in_table_list(THD *thd, TABLE_LIST *tbl)
2664
for (; tbl; tbl= tbl->next_local)
2668
tbl->prep_on_expr= tbl->on_expr;
2669
tbl->on_expr= tbl->on_expr->copy_andor_structure(thd);
2671
fix_prepare_info_in_table_list(thd, tbl->merge_underlying_list);
2677
Save WHERE/HAVING/ON clauses and replace them with disposable copies
2680
st_select_lex::fix_prepare_information
2682
conds in/out pointer to WHERE condition to be met at execution
2683
having_conds in/out pointer to HAVING condition to be met at execution
2686
The passed WHERE and HAVING are to be saved for the future executions.
2687
This function saves it, and returns a copy which can be thrashed during
2688
this execution of the statement. By saving/thrashing here we mean only
2690
The function also calls fix_prepare_info_in_table_list that saves all
2694
void st_select_lex::fix_prepare_information(THD *thd, Item **conds,
2695
Item **having_conds)
2697
if (thd->stmt_arena->is_conventional() == false && first_execution)
2703
*conds= where= prep_where->copy_andor_structure(thd);
2707
prep_having= *having_conds;
2708
*having_conds= having= prep_having->copy_andor_structure(thd);
2710
fix_prepare_info_in_table_list(thd, (TABLE_LIST *)table_list.first);
2716
There are st_select_lex::add_table_to_list &
2717
st_select_lex::set_lock_for_tables are in sql_parse.cc
2719
st_select_lex::print is in sql_select.cc
2721
st_select_lex_unit::prepare, st_select_lex_unit::exec,
2722
st_select_lex_unit::cleanup, st_select_lex_unit::reinit_exec_mechanism,
2723
st_select_lex_unit::change_result
1993
There are Select_Lex::add_table_to_list &
1994
Select_Lex::set_lock_for_tables are in sql_parse.cc
1996
Select_Lex::print is in sql_select.cc
1998
Select_Lex_Unit::prepare, Select_Lex_Unit::exec,
1999
Select_Lex_Unit::cleanup, Select_Lex_Unit::reinit_exec_mechanism,
2000
Select_Lex_Unit::change_result
2724
2001
are in sql_union.cc