1
/* Copyright (C) 2000-2006 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
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 */
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16
20
#ifndef DRIZZLE_SERVER_SQL_LEX_H
17
21
#define DRIZZLE_SERVER_SQL_LEX_H
20
24
@defgroup Semantic_Analysis Semantic Analysis
27
#include <drizzled/sql_udf.h>
28
#include <drizzled/name_resolution_context.h>
29
#include <drizzled/item/subselect.h>
30
#include <drizzled/item/param.h>
31
#include <drizzled/item/outer_ref.h>
32
#include <drizzled/table_list.h>
33
#include <drizzled/function/real.h>
34
#include <drizzled/alter_drop.h>
35
#include <drizzled/alter_column.h>
36
#include <drizzled/key.h>
37
#include <drizzled/foreign_key.h>
38
#include <drizzled/item/param.h>
40
class select_result_interceptor;
41
class virtual_column_info;
23
43
/* YACC and LEX Definitions */
25
45
/* These may not be declared yet */
27
47
class sql_exchange;
30
51
#ifdef DRIZZLE_SERVER
52
When a command is added here, be sure it's also added in mysqld.cc
53
in "struct show_var_st status_vars[]= {" ...
55
If the command returns a result set or is not allowed in stored
56
functions or triggers, please also make sure that
57
sp_get_flags_for_command (sp_head.cc) returns proper flags for the
61
enum enum_sql_command {
62
SQLCOM_SELECT, SQLCOM_CREATE_TABLE, SQLCOM_CREATE_INDEX, SQLCOM_ALTER_TABLE,
63
SQLCOM_UPDATE, SQLCOM_INSERT, SQLCOM_INSERT_SELECT,
64
SQLCOM_DELETE, SQLCOM_TRUNCATE, SQLCOM_DROP_TABLE, SQLCOM_DROP_INDEX,
65
SQLCOM_SHOW_DATABASES, SQLCOM_SHOW_TABLES, SQLCOM_SHOW_FIELDS,
66
SQLCOM_SHOW_KEYS, SQLCOM_SHOW_VARIABLES, SQLCOM_SHOW_STATUS,
67
SQLCOM_SHOW_ENGINE_LOGS, SQLCOM_SHOW_ENGINE_STATUS, SQLCOM_SHOW_ENGINE_MUTEX,
68
SQLCOM_SHOW_PROCESSLIST, SQLCOM_SHOW_MASTER_STAT, SQLCOM_SHOW_SLAVE_STAT,
69
SQLCOM_SHOW_CREATE, SQLCOM_SHOW_CHARSETS,
70
SQLCOM_SHOW_COLLATIONS, SQLCOM_SHOW_CREATE_DB, SQLCOM_SHOW_TABLE_STATUS,
71
SQLCOM_LOAD,SQLCOM_SET_OPTION,SQLCOM_LOCK_TABLES,SQLCOM_UNLOCK_TABLES,
72
SQLCOM_CHANGE_DB, SQLCOM_CREATE_DB, SQLCOM_DROP_DB, SQLCOM_ALTER_DB,
73
SQLCOM_REPAIR, SQLCOM_REPLACE, SQLCOM_REPLACE_SELECT,
74
SQLCOM_OPTIMIZE, SQLCOM_CHECK,
75
SQLCOM_ASSIGN_TO_KEYCACHE,
76
SQLCOM_FLUSH, SQLCOM_KILL, SQLCOM_ANALYZE,
77
SQLCOM_ROLLBACK, SQLCOM_ROLLBACK_TO_SAVEPOINT,
78
SQLCOM_COMMIT, SQLCOM_SAVEPOINT, SQLCOM_RELEASE_SAVEPOINT,
79
SQLCOM_SLAVE_START, SQLCOM_SLAVE_STOP,
80
SQLCOM_BEGIN, SQLCOM_CHANGE_MASTER,
82
SQLCOM_RESET, SQLCOM_PURGE, SQLCOM_PURGE_BEFORE, SQLCOM_SHOW_BINLOGS,
83
SQLCOM_SHOW_OPEN_TABLES,
84
SQLCOM_SHOW_SLAVE_HOSTS, SQLCOM_DELETE_MULTI, SQLCOM_UPDATE_MULTI,
85
SQLCOM_SHOW_BINLOG_EVENTS,
86
SQLCOM_SHOW_WARNS, SQLCOM_EMPTY_QUERY, SQLCOM_SHOW_ERRORS,
88
SQLCOM_BINLOG_BASE64_EVENT,
91
When a command is added here, be sure it's also added in mysqld.cc
92
in "struct show_var_st status_vars[]= {" ...
94
/* This should be the last !!! */
98
72
// describe/explain types
99
73
#define DESCRIBE_NORMAL 1
100
74
#define DESCRIBE_EXTENDED 2
125
99
Enum is used for making it possible to detect if the user
126
100
changed variable or if it should be left at old value
128
enum {LEX_MI_UNCHANGED, LEX_MI_DISABLE, LEX_MI_ENABLE}
129
ssl, ssl_verify_server_cert, heartbeat_opt;
130
char *ssl_key, *ssl_cert, *ssl_ca, *ssl_capath, *ssl_cipher;
102
enum {LEX_MI_UNCHANGED, LEX_MI_DISABLE, LEX_MI_ENABLE} heartbeat_opt;
131
103
char *relay_log_name;
132
104
uint32_t relay_log_pos;
133
105
} LEX_MASTER_INFO;
342
314
static void *operator new(size_t size, MEM_ROOT *mem_root)
343
315
{ return (void*) alloc_root(mem_root, (uint32_t) size); }
344
static void operator delete(void *ptr __attribute__((unused)),
345
size_t size __attribute__((unused)))
316
static void operator delete(void *, size_t)
346
317
{ TRASH(ptr, size); }
347
static void operator delete(void *ptr __attribute__((unused)),
348
MEM_ROOT *mem_root __attribute__((unused)))
318
static void operator delete(void *, MEM_ROOT *)
350
320
st_select_lex_node(): linkage(UNSPECIFIED_TYPE) {}
351
321
virtual ~st_select_lex_node() {}
365
335
virtual bool set_braces(bool value);
366
336
virtual bool inc_in_sum_expr();
367
337
virtual uint32_t get_in_sum_expr();
368
virtual TABLE_LIST* get_table_list();
338
virtual TableList* get_table_list();
369
339
virtual List<Item>* get_item_list();
370
340
virtual uint32_t get_table_join_options();
371
virtual TABLE_LIST *add_table_to_list(THD *thd, Table_ident *table,
341
virtual TableList *add_table_to_list(Session *session, Table_ident *table,
372
342
LEX_STRING *alias,
373
343
uint32_t table_options,
374
344
thr_lock_type flags= TL_UNLOCK,
375
345
List<Index_hint> *hints= 0,
376
346
LEX_STRING *option= 0);
377
virtual void set_lock_for_tables(thr_lock_type lock_type __attribute__((unused)))
347
virtual void set_lock_for_tables(thr_lock_type)
380
350
friend class st_select_lex_unit;
381
friend bool mysql_new_select(struct st_lex *lex, bool move_down);
351
friend bool mysql_new_select(LEX *lex, bool move_down);
383
353
void fast_exclude();
385
355
typedef class st_select_lex_node SELECT_LEX_NODE;
388
SELECT_LEX_UNIT - unit of selects (UNION, INTERSECT, ...) group
358
SELECT_LEX_UNIT - unit of selects (UNION, INTERSECT, ...) group
392
362
class select_result;
394
364
class select_union;
395
365
class st_select_lex_unit: public st_select_lex_node {
397
TABLE_LIST result_table_list;
367
TableList result_table_list;
398
368
select_union *union_result;
399
TABLE *table; /* temporary table using for appending UNION results */
369
Table *table; /* temporary table using for appending UNION results */
401
371
select_result *result;
402
372
uint64_t found_rows_for_union;
449
419
st_select_lex* outer_select();
450
420
st_select_lex* first_select()
452
return my_reinterpret_cast(st_select_lex*)(slave);
422
return reinterpret_cast<st_select_lex*>(slave);
454
424
st_select_lex_unit* next_unit()
456
return my_reinterpret_cast(st_select_lex_unit*)(next);
426
return reinterpret_cast<st_select_lex_unit*>(next);
458
428
st_select_lex* return_after_parsing() { return return_to; }
459
429
void exclude_level();
460
430
void exclude_tree();
462
432
/* UNION methods */
463
bool prepare(THD *thd, select_result *result, uint32_t additional_options);
433
bool prepare(Session *session, select_result *result, uint32_t additional_options);
466
436
inline void unclean() { cleaned= 0; }
469
439
void print(String *str, enum_query_type query_type);
471
bool add_fake_select_lex(THD *thd);
472
void init_prepare_fake_select_lex(THD *thd);
441
bool add_fake_select_lex(Session *session);
442
void init_prepare_fake_select_lex(Session *session);
473
443
bool change_result(select_result_interceptor *result,
474
444
select_result_interceptor *old_result);
475
445
void set_limit(st_select_lex *values);
476
void set_thd(THD *thd_arg) { thd= thd_arg; }
477
inline bool is_union ();
446
void set_session(Session *session_arg) { session= session_arg; }
447
inline bool is_union ();
479
friend void lex_start(THD *thd);
449
friend void lex_start(Session *session);
480
450
friend int subselect_union_engine::exec();
482
452
List<Item> *get_unit_column_types();
493
463
Name_resolution_context context;
495
465
Item *where, *having; /* WHERE & HAVING clauses */
496
Item *prep_where; /* saved WHERE clause for prepared statement processing */
497
Item *prep_having;/* saved HAVING clause for prepared statement processing */
498
466
/* Saved values of the WHERE and HAVING clauses*/
499
467
Item::cond_result cond_value, having_value;
500
468
/* point on lex in which it was created, used in view subquery detection */
502
470
enum olap_type olap;
503
/* FROM clause - points to the beginning of the TABLE_LIST::next_local list. */
471
/* FROM clause - points to the beginning of the TableList::next_local list. */
504
472
SQL_LIST table_list;
505
473
SQL_LIST group_list; /* GROUP BY clause. */
506
474
List<Item> item_list; /* list of fields & expressions */
507
475
List<String> interval_list;
508
476
bool is_item_list_lookup;
510
Despite their names, the following are used in unions. This should
478
Despite their names, the following are used in unions. This should
511
479
be rewritten. -Brian
513
481
List<Item_real_func> *ftfunc_list;
514
482
List<Item_real_func> ftfunc_list_alloc;
515
483
JOIN *join; /* after JOIN::prepare it is pointer to corresponding JOIN */
516
List<TABLE_LIST> top_join_list; /* join list of the top level */
517
List<TABLE_LIST> *join_list; /* list for the currently parsed join */
518
TABLE_LIST *embedding; /* table embedding to the above list */
519
List<TABLE_LIST> sj_nests;
484
List<TableList> top_join_list; /* join list of the top level */
485
List<TableList> *join_list; /* list for the currently parsed join */
486
TableList *embedding; /* table embedding to the above list */
487
List<TableList> sj_nests;
521
489
Beginning of the list of leaves in a FROM clause, where the leaves
522
490
inlcude all base tables including view tables. The tables are connected
523
by TABLE_LIST::next_leaf, so leaf_tables points to the left-most leaf.
491
by TableList::next_leaf, so leaf_tables points to the left-most leaf.
525
TABLE_LIST *leaf_tables;
493
TableList *leaf_tables;
526
494
const char *type; /* type of select for EXPLAIN */
528
496
SQL_LIST order_list; /* ORDER clause */
547
515
uint32_t select_n_where_fields;
548
516
enum_parsing_place parsing_place; /* where we are parsing expression */
549
517
bool with_sum_func; /* sum function indicator */
551
PS or SP cond natural joins was alredy processed with permanent
552
arena and all additional items which we need alredy stored in it
554
bool conds_processed_with_permanent_arena;
556
519
uint32_t table_join_options;
557
520
uint32_t in_sum_expr;
558
521
uint32_t select_number; /* number of select (used for EXPLAIN) */
559
522
int nest_level; /* nesting level of select */
560
Item_sum *inner_sum_func_list; /* list of sum func in nested selects */
523
Item_sum *inner_sum_func_list; /* list of sum func in nested selects */
561
524
uint32_t with_wild; /* item list contain '*' */
562
525
bool braces; /* SELECT ... UNION (SELECT ... ) <- this braces */
563
526
/* true when having fix field called in processing of this SELECT */
578
541
bool subquery_in_having;
579
542
/* true <=> this SELECT is correlated w.r.t. some ancestor select */
580
543
bool is_correlated;
582
This variable is required to ensure proper work of subqueries and
583
stored procedures. Generally, one should use the states of
584
Query_arena to determine if it's a statement prepare or first
585
execution of a stored procedure. However, in case when there was an
586
error during the first execution of a stored procedure, the SP body
587
is not expelled from the SP cache. Therefore, a deeply nested
588
subquery might be left unoptimized. So we need this per-subquery
589
variable to inidicate the optimization/execution state of every
590
subquery. Prepared statements work OK in that regard, as in
591
case of an error during prepare the PS is not created.
593
bool first_execution;
594
bool first_cond_optimization;
595
544
/* exclude this select from check of unique_table() */
596
545
bool exclude_from_table_unique_test;
597
546
/* List of fields that aren't under an aggregate function */
600
549
int cur_pos_in_select_list;
602
551
List<udf_func> udf_list; /* udf function calls stack */
604
553
This is a copy of the original JOIN USING list that comes from
605
554
the parser. The parser :
606
1. Sets the natural_join of the second TABLE_LIST in the join
555
1. Sets the natural_join of the second TableList in the join
607
556
and the st_select_lex::prev_join_using.
608
2. Makes a parent TABLE_LIST and sets its is_natural_join/
557
2. Makes a parent TableList and sets its is_natural_join/
609
558
join_using_fields members.
610
3. Uses the wrapper TABLE_LIST as a table in the upper level.
559
3. Uses the wrapper TableList as a table in the upper level.
611
560
We cannot assign directly to join_using_fields in the parser because
612
at stage (1.) the parent TABLE_LIST is not constructed yet and
561
at stage (1.) the parent TableList is not constructed yet and
613
562
the assignment will override the JOIN USING fields of the lower level
614
563
joins on the right.
627
576
void init_query();
628
577
void init_select();
629
578
st_select_lex_unit* master_unit();
630
st_select_lex_unit* first_inner_unit()
632
return (st_select_lex_unit*) slave;
579
st_select_lex_unit* first_inner_unit()
581
return (st_select_lex_unit*) slave;
634
583
st_select_lex* outer_select();
635
584
st_select_lex* next_select() { return (st_select_lex*) next; }
636
st_select_lex* next_select_in_list()
585
st_select_lex* next_select_in_list()
638
587
return (st_select_lex*) link_next;
652
601
bool inc_in_sum_expr();
653
602
uint32_t get_in_sum_expr();
655
bool add_item_to_list(THD *thd, Item *item);
656
bool add_group_to_list(THD *thd, Item *item, bool asc);
657
bool add_order_to_list(THD *thd, Item *item, bool asc);
658
TABLE_LIST* add_table_to_list(THD *thd, Table_ident *table,
604
bool add_item_to_list(Session *session, Item *item);
605
bool add_group_to_list(Session *session, Item *item, bool asc);
606
bool add_order_to_list(Session *session, Item *item, bool asc);
607
TableList* add_table_to_list(Session *session, Table_ident *table,
659
608
LEX_STRING *alias,
660
609
uint32_t table_options,
661
610
thr_lock_type flags= TL_UNLOCK,
662
611
List<Index_hint> *hints= 0,
663
612
LEX_STRING *option= 0);
664
TABLE_LIST* get_table_list();
665
bool init_nested_join(THD *thd);
666
TABLE_LIST *end_nested_join(THD *thd);
667
TABLE_LIST *nest_last_join(THD *thd);
668
void add_joined_table(TABLE_LIST *table);
669
TABLE_LIST *convert_right_join();
613
TableList* get_table_list();
614
bool init_nested_join(Session *session);
615
TableList *end_nested_join(Session *session);
616
TableList *nest_last_join(Session *session);
617
void add_joined_table(TableList *table);
618
TableList *convert_right_join();
670
619
List<Item>* get_item_list();
671
620
uint32_t get_table_join_options();
672
621
void set_lock_for_tables(thr_lock_type lock_type);
685
634
void cut_subtree() { slave= 0; }
686
635
bool test_limit();
688
friend void lex_start(THD *thd);
637
friend void lex_start(Session *session);
689
638
st_select_lex() : n_sum_items(0), n_child_sum_items(0) {}
690
639
void make_empty_select()
695
bool setup_ref_array(THD *thd, uint32_t order_group_num);
696
void print(THD *thd, String *str, enum_query_type query_type);
644
bool setup_ref_array(Session *session, uint32_t order_group_num);
645
void print(Session *session, String *str, enum_query_type query_type);
697
646
static void print_order(String *str,
699
648
enum_query_type query_type);
700
void print_limit(THD *thd, String *str, enum_query_type query_type);
701
void fix_prepare_information(THD *thd, Item **conds, Item **having_conds);
649
void print_limit(Session *session, String *str, enum_query_type query_type);
650
void fix_prepare_information(Session *session, Item **conds, Item **having_conds);
703
652
Destroy the used execution plan (JOIN) of this subtree (this
704
653
SELECT_LEX and all nested SELECT_LEXes and SELECT_LEX_UNITs).
713
662
void set_index_hint_type(enum index_hint_type type, index_clause_map clause);
716
665
Add a index hint to the tagged list of hints. The type and clause of the
717
hint will be the current ones (set by set_index_hint())
666
hint will be the current ones (set by set_index_hint())
719
bool add_index_hint (THD *thd, char *str, uint32_t length);
668
bool add_index_hint (Session *session, char *str, uint32_t length);
721
670
/* make a list to hold index hints */
722
void alloc_index_hints (THD *thd);
671
void alloc_index_hints (Session *session);
723
672
/* read and clear the index hints */
724
List<Index_hint>* pop_index_hints(void)
673
List<Index_hint>* pop_index_hints(void)
726
675
List<Index_hint> *hints= index_hints;
727
676
index_hints= NULL;
842
791
/* Global list of all tables used by this statement */
843
TABLE_LIST *query_tables;
792
TableList *query_tables;
844
793
/* Pointer to next_global member of last element in the previous list. */
845
TABLE_LIST **query_tables_last;
794
TableList **query_tables_last;
847
796
If non-0 then indicates that query requires prelocking and points to
848
797
next_global member of last own element in query table list (i.e. last
849
798
table which was not added to it as part of preparation to prelocking).
850
799
0 - indicates that this query does not need prelocking.
852
TABLE_LIST **query_tables_own_last;
854
Set of stored routines called by statement.
855
(Note that we use lazy-initialization for this hash).
857
enum { START_SROUTINES_HASH_SIZE= 16 };
860
List linking elements of 'sroutines' set. Allows you to add new elements
861
to this set as you iterate through the list of existing elements.
862
'sroutines_list_own_last' is pointer to ::next member of last element of
863
this list which represents routine which is explicitly used by query.
864
'sroutines_list_own_elements' number of explicitly used routines.
865
We use these two members for restoring of 'sroutines_list' to the state
866
in which it was right after query parsing.
868
SQL_LIST sroutines_list;
869
uchar **sroutines_list_own_last;
870
uint32_t sroutines_list_own_elements;
801
TableList **query_tables_own_last;
873
804
These constructor and destructor serve for creation/destruction
889
820
If you are using this function, you must ensure that the table
890
821
object, in particular table->db member, is initialized.
892
void add_to_query_tables(TABLE_LIST *table)
823
void add_to_query_tables(TableList *table)
894
825
*(table->prev_global= query_tables_last)= table;
895
826
query_tables_last= &table->next_global;
897
828
/* Return pointer to first not-own table in query-tables or 0 */
898
TABLE_LIST* first_not_own_table()
829
TableList* first_not_own_table()
900
831
return ( query_tables_own_last ? *query_tables_own_last : 0);
908
839
query_tables_own_last= 0;
913
Has the parser/scanner detected that this statement is unsafe?
915
inline bool is_stmt_unsafe() const {
916
return binlog_stmt_flags & (1U << BINLOG_STMT_FLAG_UNSAFE);
920
Flag the current (top-level) statement as unsafe.
922
The flag will be reset after the statement has finished.
925
inline void set_stmt_unsafe() {
926
binlog_stmt_flags|= (1U << BINLOG_STMT_FLAG_UNSAFE);
929
inline void clear_stmt_unsafe() {
930
binlog_stmt_flags&= ~(1U << BINLOG_STMT_FLAG_UNSAFE);
934
true if the parsed tree contains references to stored procedures
935
or functions, false otherwise
937
bool uses_stored_routines() const
938
{ return sroutines_list.elements != 0; }
941
enum enum_binlog_stmt_flag {
942
BINLOG_STMT_FLAG_UNSAFE,
943
BINLOG_STMT_FLAG_COUNT
947
Tells if the parsing stage detected properties of the statement,
948
for example: that some items require row-based binlogging to give
949
a reliable binlog/replication, or if we will use stored functions
950
or triggers which themselves need require row-based binlogging.
952
uint32_t binlog_stmt_flags;
1239
1128
return m_body_utf8_ptr - m_body_utf8;
1242
void body_utf8_start(THD *thd, const char *begin_ptr);
1131
void body_utf8_start(Session *session, const char *begin_ptr);
1243
1132
void body_utf8_append(const char *ptr);
1244
1133
void body_utf8_append(const char *ptr, const char *end_ptr);
1245
void body_utf8_append_literal(THD *thd,
1134
void body_utf8_append_literal(Session *session,
1246
1135
const LEX_STRING *txt,
1247
1136
const CHARSET_INFO * const txt_cs,
1248
1137
const char *end_ptr);
1250
1139
/** Current thread. */
1253
1142
/** Current line number. */
1254
1143
uint32_t yylineno;
1358
1247
Ending position of the TEXT_STRING or IDENT in the pre-processed
1361
NOTE: this member must be used within MYSQLlex() function only.
1250
NOTE: this member must be used within DRIZZLElex() function only.
1363
1252
const char *m_cpp_text_end;
1366
1255
Character set specified by the character-set-introducer.
1368
NOTE: this member must be used within MYSQLlex() function only.
1257
NOTE: this member must be used within DRIZZLElex() function only.
1370
1259
const CHARSET_INFO *m_underscore_cs;
1374
/* The state of the lex parsing. This is saved in the THD struct */
1263
/* The state of the lex parsing. This is saved in the Session struct */
1376
typedef struct st_lex : public Query_tables_list
1265
class LEX : public Query_tables_list
1378
1268
SELECT_LEX_UNIT unit; /* most upper unit */
1379
1269
SELECT_LEX select_lex; /* first SELECT_LEX */
1380
1270
/* current SELECT_LEX in parsing */
1386
1276
LEX_STRING name;
1387
1277
char *help_arg;
1388
1278
char* to_log; /* For PURGE MASTER LOGS TO */
1389
char* x509_subject,*x509_issuer,*ssl_cipher;
1391
1280
sql_exchange *exchange;
1392
1281
select_result *result;
1393
1282
Item *default_value, *on_update_value;
1394
1283
LEX_STRING comment, ident;
1396
uchar* yacc_yyss, *yacc_yyvs;
1399
/* maintain a list of used plugins for this LEX */
1400
DYNAMIC_ARRAY plugins;
1401
plugin_ref plugins_static_buffer[INITIAL_LEX_PLUGIN_LIST_SIZE];
1285
unsigned char* yacc_yyss, *yacc_yyvs;
1287
virtual_column_info *vcol_info;
1403
1289
const CHARSET_INFO *charset;
1404
1290
bool text_string_is_7bit;
1405
1291
/* store original leaf_tables for INSERT SELECT and PS/SP */
1406
TABLE_LIST *leaf_tables_insert;
1292
TableList *leaf_tables_insert;
1408
1294
List<Key_part_spec> col_list;
1409
1295
List<Key_part_spec> ref_list;
1500
1393
Alter_info alter_info;
1503
field_list was created for view and should be removed before PS/SP
1506
bool empty_field_list_on_rset;
1509
1396
Pointers to part of LOAD DATA statement that should be rewritten
1510
1397
during replication ("LOCAL 'filename' REPLACE INTO" part).
1512
1399
const char *fname_start;
1513
1400
const char *fname_end;
1516
During name resolution search only in the table list given by
1403
During name resolution search only in the table list given by
1517
1404
Name_resolution_context::first_name_resolution_table and
1518
1405
Name_resolution_context::last_name_resolution_table
1519
(see Item_field::fix_fields()).
1406
(see Item_field::fix_fields()).
1521
1408
bool use_only_table_context;
1523
1410
bool escape_used;
1524
1411
bool is_lex_started; /* If lex_start() did run. For debugging. */
1530
1417
destroy_query_tables_list();
1531
plugin_unlock_list(NULL, (plugin_ref *)plugins.buffer, plugins.elements);
1532
delete_dynamic(&plugins);
1535
TABLE_LIST *unlink_first_table(bool *link_to_local);
1536
void link_first_table_back(TABLE_LIST *first, bool link_to_local);
1420
TableList *unlink_first_table(bool *link_to_local);
1421
void link_first_table_back(TableList *first, bool link_to_local);
1537
1422
void first_lists_tables_same();
1539
bool can_be_merged();
1540
bool can_use_merged();
1541
bool can_not_use_merged();
1542
1424
bool only_view_structure();
1543
1425
bool need_correct_ident();
1561
1443
return context_stack.head();
1564
Restore the LEX and THD in case of a parse error.
1446
Restore the LEX and Session in case of a parse error.
1566
static void cleanup_lex_after_parse_error(THD *thd);
1568
void reset_n_backup_query_tables_list(Query_tables_list *backup);
1569
void restore_backup_query_tables_list(Query_tables_list *backup);
1571
bool table_or_sp_used();
1448
static void cleanup_lex_after_parse_error(Session *session);
1574
1451
@brief check if the statement is a single-level join
1575
1452
@return result of the check
1576
@retval true The statement doesn't contain subqueries, unions and
1453
@retval true The statement doesn't contain subqueries, unions and
1577
1454
stored procedure calls.
1578
1455
@retval false There are subqueries, UNIONs or stored procedure calls.
1580
bool is_single_level_stmt()
1457
bool is_single_level_stmt()
1583
1460
This check exploits the fact that the last added to all_select_list is
1584
on its top. So select_lex (as the first added) will be at the tail
1461
on its top. So select_lex (as the first added) will be at the tail
1587
if (&select_lex == all_selects_list && !sroutines.records)
1464
if (&select_lex == all_selects_list)
1589
1466
assert(!all_selects_list->next_select_in_list());
1596
struct st_lex_local: public st_lex
1473
struct st_lex_local: public LEX
1598
1475
static void *operator new(size_t size) throw()
1604
1481
return (void*) alloc_root(mem_root, (uint32_t) size);
1606
static void operator delete(void *ptr __attribute__((unused)),
1607
size_t size __attribute__((unused)))
1483
static void operator delete(void *, size_t)
1608
1484
{ TRASH(ptr, size); }
1609
static void operator delete(void *ptr __attribute__((unused)),
1610
MEM_ROOT *mem_root __attribute__((unused)))
1485
static void operator delete(void *, MEM_ROOT *)
1611
1486
{ /* Never called */ }
1614
1489
extern void lex_init(void);
1615
1490
extern void lex_free(void);
1616
extern void lex_start(THD *thd);
1491
extern void lex_start(Session *session);
1617
1492
extern void lex_end(LEX *lex);
1619
1494
extern void trim_whitespace(const CHARSET_INFO * const cs, LEX_STRING *str);
1621
1496
extern bool is_lex_native_function(const LEX_STRING *name);
1498
int lex_casecmp(const char *s, const char *t, uint32_t len);
1624
1501
@} (End of group Semantic_Analysis)