17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef DRIZZLED_SQL_LEX_H
21
#define DRIZZLED_SQL_LEX_H
24
23
@defgroup Semantic_Analysis Semantic Analysis
26
25
#include <drizzled/message/table.pb.h>
28
#include "drizzled/plugin/function.h"
29
#include "drizzled/name_resolution_context.h"
30
#include "drizzled/item/subselect.h"
31
#include "drizzled/table_list.h"
32
#include "drizzled/function/math/real.h"
33
#include "drizzled/alter_drop.h"
34
#include "drizzled/alter_column.h"
35
#include "drizzled/alter_info.h"
36
#include "drizzled/key_part_spec.h"
37
#include "drizzled/index_hint.h"
38
#include "drizzled/statement.h"
39
#include "drizzled/optimizer/explain_plan.h"
26
#include <drizzled/name_resolution_context.h>
27
#include <drizzled/table_list.h>
28
#include <drizzled/function/math/real.h>
29
#include <drizzled/key_part_spec.h>
30
#include <drizzled/index_hint.h>
31
#include <drizzled/optimizer/explain_plan.h>
38
namespace plugin { class Function; }
39
namespace statement { class Statement; }
47
47
class select_result_interceptor;
49
49
/* YACC and LEX Definitions */
71
71
# if defined(DRIZZLE_LEX)
72
72
# include <drizzled/foreign_key.h>
73
73
# include <drizzled/lex_symbol.h>
74
# include <drizzled/comp_creator.h>
74
75
# include <drizzled/sql_yacc.h>
75
76
# define LEX_YYSTYPE YYSTYPE *
382
383
inline void unclean() { cleaned= 0; }
383
384
void reinit_exec_mechanism();
385
void print(String *str, enum_query_type query_type);
386
void print(String *str);
387
388
bool add_fake_select_lex(Session *session);
388
389
void init_prepare_fake_select_lex(Session *session);
473
474
Item::cond_result having_value;
474
475
/* point on lex in which it was created, used in view subquery detection */
477
478
/* FROM clause - points to the beginning of the TableList::next_local list. */
478
479
SQL_LIST table_list;
479
480
SQL_LIST group_list; /* GROUP BY clause. */
491
492
by TableList::next_leaf, so leaf_tables points to the left-most leaf.
493
494
TableList *leaf_tables;
494
enum drizzled::optimizer::select_type type; /* type of select for EXPLAIN */
495
drizzled::optimizer::select_type type; /* type of select for EXPLAIN */
496
497
SQL_LIST order_list; /* ORDER clause */
497
498
SQL_LIST *gorder_list;
628
633
order_list.next= (unsigned char**) &order_list.first;
631
This method created for reiniting LEX in mysql_admin_table() and can be
636
This method created for reiniting LEX in admin_table() and can be
632
637
used only if you are going remove all Select_Lex & units except belonger
633
638
to LEX (LEX::unit & LEX::select, for other purposes there are
634
639
Select_Lex_Unit::exclude_level & Select_Lex_Unit::exclude_tree
648
653
bool setup_ref_array(Session *session, uint32_t order_group_num);
649
void print(Session *session, String *str, enum_query_type query_type);
650
static void print_order(String *str,
652
enum_query_type query_type);
653
void print_limit(Session *session, String *str, enum_query_type query_type);
654
void print(Session *session, String *str);
655
static void print_order(String *str, Order *order);
657
void print_limit(Session *session, String *str);
654
658
void fix_prepare_information(Session *session, Item **conds, Item **having_conds);
656
660
Destroy the used execution plan (JOIN) of this subtree (this
664
668
void cleanup_all_joins(bool full);
666
void set_index_hint_type(enum index_hint_type type, index_clause_map clause);
670
void set_index_hint_type(index_hint_type type, index_clause_map clause);
669
673
Add a index hint to the tagged list of hints. The type and clause of the
670
674
hint will be the current ones (set by set_index_hint())
672
bool add_index_hint (Session *session, char *str, uint32_t length);
676
void add_index_hint(Session *session, char *str, uint32_t length);
674
678
/* make a list to hold index hints */
675
679
void alloc_index_hints (Session *session);
687
691
/* current index hint kind. used in filling up index_hints */
688
enum index_hint_type current_index_hint_type;
692
index_hint_type current_index_hint_type;
689
693
index_clause_map current_index_hint_clause;
690
694
/* a list of USE/FORCE/IGNORE INDEX */
691
695
List<Index_hint> *index_hints;
811
815
/* list of all Select_Lex */
812
816
Select_Lex *all_selects_list;
814
/* This is the "scale" for DECIMAL (S,P) notation */
818
/* This is the "scale" for DECIMAL (S,P) notation */
816
820
/* This is the decimal precision in DECIMAL(S,P) notation */
820
* This is used kind of like the "ident" member variable below, as
824
* This is used kind of like the "ident" member variable below, as
821
825
* a place to store certain names of identifiers. Unfortunately, it
822
826
* is used differently depending on the Command (SELECT on a derived
823
827
* table vs CREATE)
833
837
* or a named savepoint. It should probably be refactored out into
834
838
* the eventual Command class built for the Keycache and Savepoint
837
841
LEX_STRING ident;
839
843
unsigned char* yacc_yyss, *yacc_yyvs;
840
844
/* The owning Session of this LEX */
841
845
Session *session;
842
const CHARSET_INFO *charset;
846
const charset_info_st *charset;
843
847
bool text_string_is_7bit;
844
848
/* store original leaf_tables for INSERT SELECT and PS/SP */
845
849
TableList *leaf_tables_insert;
850
854
List<Lex_Column> columns;
851
855
List<Item> *insert_list,field_list,value_list,update_list;
852
856
List<List_item> many_values;
853
List<set_var_base> var_list;
857
SetVarVector var_list;
855
859
A stack of name resolution contexts for the query. This stack is used
856
860
at parse time to set local name resolution contexts for various parts
941
943
void cleanup_after_one_table_open();
943
bool push_context(Name_resolution_context *context)
945
void push_context(Name_resolution_context *context)
945
return context_stack.push_front(context);
947
context_stack.push_front(context);
948
950
void pop_context()
955
957
Name_resolution_context *current_context()
957
return context_stack.head();
959
return &context_stack.front();
960
Restore the LEX and Session in case of a parse error.
962
static void cleanup_lex_after_parse_error(Session *session);
965
963
@brief check if the statement is a single-level join
1010
1009
void start(Session *session);
1012
message::Table *table()
1014
if (not _create_table)
1015
_create_table= new message::Table;
1017
return _create_table;
1020
message::AlterTable *alter_table();
1022
message::Table::Field *field()
1024
return _create_field;
1027
void setField(message::Table::Field *arg)
1014
1043
bool cacheable;
1015
1044
bool sum_expr_used;
1045
message::Table *_create_table;
1046
message::AlterTable *_alter_table;
1047
message::Table::Field *_create_field;
1018
1051
extern void lex_start(Session *session);
1019
extern void trim_whitespace(const CHARSET_INFO * const cs, LEX_STRING *str);
1052
extern void trim_whitespace(const charset_info_st * const cs, LEX_STRING *str);
1020
1053
extern bool is_lex_native_function(const LEX_STRING *name);
1055
bool check_for_sql_keyword(drizzled::st_lex_symbol const&);
1056
bool check_for_sql_keyword(drizzled::lex_string_t const&);
1023
1059
@} (End of group Semantic_Analysis)