26
26
#include <drizzled/message/table.pb.h>
28
#include "drizzled/plugin/function.h"
28
#include "drizzled/sql_udf.h"
29
29
#include "drizzled/name_resolution_context.h"
30
30
#include "drizzled/item/subselect.h"
31
#include "drizzled/item/param.h"
32
#include "drizzled/item/outer_ref.h"
31
33
#include "drizzled/table_list.h"
32
34
#include "drizzled/function/math/real.h"
33
35
#include "drizzled/alter_drop.h"
34
36
#include "drizzled/alter_column.h"
35
#include "drizzled/alter_info.h"
36
#include "drizzled/key_part_spec.h"
37
#include "drizzled/key.h"
38
#include "drizzled/foreign_key.h"
39
#include "drizzled/item/param.h"
37
40
#include "drizzled/index_hint.h"
38
#include "drizzled/statement.h"
39
#include "drizzled/optimizer/explain_plan.h"
47
42
class select_result_interceptor;
55
50
class Item_outer_ref;
57
} /* namespace drizzled */
60
53
The following hack is needed because mysql_yacc.cc does not define
61
54
YYSTYPE before including this file
64
57
#ifdef DRIZZLE_SERVER
65
/* set_var should change to set_var here ... */
66
# include <drizzled/sys_var.h>
58
# include <drizzled/set_var.h>
67
59
# include <drizzled/item/func.h>
68
60
# ifdef DRIZZLE_YACC
69
61
# define LEX_YYSTYPE void *
71
63
# if defined(DRIZZLE_LEX)
72
# include <drizzled/foreign_key.h>
73
64
# include <drizzled/lex_symbol.h>
74
65
# include <drizzled/sql_yacc.h>
75
66
# define LEX_YYSTYPE YYSTYPE *
249
244
UNCACHEABLE_EXPLAIN
250
245
UNCACHEABLE_PREPARE
252
std::bitset<8> uncacheable;
253
248
enum sub_select_type linkage;
254
249
bool no_table_names_allowed; /* used for global order by */
255
250
bool no_error; /* suppress error message (convert it to warnings) */
257
252
static void *operator new(size_t size)
259
return memory::sql_alloc(size);
254
return sql_alloc(size);
261
static void *operator new(size_t size, memory::Root *mem_root)
262
{ return (void*) mem_root->alloc_root((uint32_t) size); }
256
static void *operator new(size_t size, MEM_ROOT *mem_root)
257
{ return (void*) alloc_root(mem_root, (uint32_t) size); }
263
258
static void operator delete(void *, size_t)
265
static void operator delete(void *, memory::Root *)
259
{ TRASH(ptr, size); }
260
static void operator delete(void *, MEM_ROOT *)
267
262
Select_Lex_Node(): linkage(UNSPECIFIED_TYPE) {}
268
263
virtual ~Select_Lex_Node() {}
284
279
virtual uint32_t get_in_sum_expr();
285
280
virtual TableList* get_table_list();
286
281
virtual List<Item>* get_item_list();
282
virtual uint32_t get_table_join_options();
287
283
virtual TableList *add_table_to_list(Session *session, Table_ident *table,
289
const std::bitset<NUM_OF_TABLE_OPTIONS>& table_options,
290
thr_lock_type flags= TL_UNLOCK,
291
List<Index_hint> *hints= 0,
292
LEX_STRING *option= 0);
285
uint32_t table_options,
286
thr_lock_type flags= TL_UNLOCK,
287
List<Index_hint> *hints= 0,
288
LEX_STRING *option= 0);
293
289
virtual void set_lock_for_tables(thr_lock_type)
404
400
class Select_Lex: public Select_Lex_Node
416
olap(UNSPECIFIED_OLAP_TYPE),
421
is_item_list_lookup(false),
428
type(optimizer::ST_PRIMARY),
433
ref_pointer_array(0),
434
select_n_having_items(0),
438
select_n_where_fields(0),
439
parsing_place(NO_MATTER),
444
inner_sum_func_list(0),
450
n_child_sum_items(0),
452
subquery_in_having(0),
454
exclude_from_table_unique_test(0),
456
cur_pos_in_select_list(0),
458
full_group_by_flag(),
459
current_index_hint_type(INDEX_HINT_IGNORE),
460
current_index_hint_clause(),
465
403
Name_resolution_context context;
467
405
/* An Item representing the WHERE clause */
480
418
List<Item> item_list; /* list of fields & expressions */
481
419
List<String> interval_list;
482
420
bool is_item_list_lookup;
483
Join *join; /* after Join::prepare it is pointer to corresponding JOIN */
421
JOIN *join; /* after JOIN::prepare it is pointer to corresponding JOIN */
484
422
List<TableList> top_join_list; /* join list of the top level */
485
423
List<TableList> *join_list; /* list for the currently parsed join */
486
424
TableList *embedding; /* table embedding to the above list */
491
429
by TableList::next_leaf, so leaf_tables points to the left-most leaf.
493
431
TableList *leaf_tables;
494
enum drizzled::optimizer::select_type type; /* type of select for EXPLAIN */
432
const char *type; /* type of select for EXPLAIN */
496
434
SQL_LIST order_list; /* ORDER clause */
497
435
SQL_LIST *gorder_list;
516
454
enum_parsing_place parsing_place; /* where we are parsing expression */
517
455
bool with_sum_func; /* sum function indicator */
457
uint32_t table_join_options;
519
458
uint32_t in_sum_expr;
520
459
uint32_t select_number; /* number of select (used for EXPLAIN) */
521
460
int8_t nest_level; /* nesting level of select */
570
509
1 - aggregate functions are used in this select,
571
510
defined as SUM_FUNC_USED.
573
std::bitset<2> full_group_by_flag;
512
uint8_t full_group_by_flag;
575
513
void init_query();
576
514
void init_select();
577
515
Select_Lex_Unit* master_unit();
609
547
TableList* add_table_to_list(Session *session,
610
548
Table_ident *table,
611
549
LEX_STRING *alias,
612
const std::bitset<NUM_OF_TABLE_OPTIONS>& table_options,
550
uint32_t table_options,
613
551
thr_lock_type flags= TL_UNLOCK,
614
552
List<Index_hint> *hints= 0,
615
553
LEX_STRING *option= 0);
620
558
void add_joined_table(TableList *table);
621
559
TableList *convert_right_join();
622
560
List<Item>* get_item_list();
561
uint32_t get_table_join_options();
623
562
void set_lock_for_tables(thr_lock_type lock_type);
624
563
inline void init_order()
648
588
bool setup_ref_array(Session *session, uint32_t order_group_num);
649
589
void print(Session *session, String *str, enum_query_type query_type);
650
590
static void print_order(String *str,
652
592
enum_query_type query_type);
653
593
void print_limit(Session *session, String *str, enum_query_type query_type);
654
594
void fix_prepare_information(Session *session, Item **conds, Item **having_conds);
697
637
first_select()->next_select()->linkage == UNION_TYPE;
640
#define ALTER_ADD_COLUMN (1L << 0)
641
#define ALTER_DROP_COLUMN (1L << 1)
642
#define ALTER_CHANGE_COLUMN (1L << 2)
643
#define ALTER_COLUMN_STORAGE (1L << 3)
644
#define ALTER_COLUMN_FORMAT (1L << 4)
645
#define ALTER_COLUMN_ORDER (1L << 5)
646
#define ALTER_ADD_INDEX (1L << 6)
647
#define ALTER_DROP_INDEX (1L << 7)
648
#define ALTER_RENAME (1L << 8)
649
#define ALTER_ORDER (1L << 9)
650
#define ALTER_OPTIONS (1L << 10)
651
#define ALTER_COLUMN_DEFAULT (1L << 11)
652
#define ALTER_KEYS_ONOFF (1L << 12)
653
#define ALTER_STORAGE (1L << 13)
654
#define ALTER_ROW_FORMAT (1L << 14)
655
#define ALTER_CONVERT (1L << 15)
656
#define ALTER_FORCE (1L << 16)
657
#define ALTER_RECREATE (1L << 17)
658
#define ALTER_TABLE_REORG (1L << 24)
659
#define ALTER_FOREIGN_KEY (1L << 31)
662
@brief Parsing data for CREATE or ALTER Table.
664
This structure contains a list of columns or indexes to be created,
671
List<Alter_drop> drop_list;
672
List<Alter_column> alter_list;
674
List<Create_field> create_list;
676
enum enum_enable_or_disable keys_onoff;
677
enum tablespace_op_type tablespace_op;
679
enum ha_build_method build_method;
680
Create_field *datetime_field;
681
bool error_if_not_empty;
685
keys_onoff(LEAVE_AS_IS),
686
tablespace_op(NO_TABLESPACE_OP),
688
build_method(HA_BUILD_DEFAULT),
689
datetime_field(NULL),
690
error_if_not_empty(false)
700
keys_onoff= LEAVE_AS_IS;
701
tablespace_op= NO_TABLESPACE_OP;
703
build_method= HA_BUILD_DEFAULT;
705
error_if_not_empty= false;
707
Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root);
709
Alter_info &operator=(const Alter_info &rhs); // not implemented
710
Alter_info(const Alter_info &rhs); // not implemented
700
713
enum xa_option_words
828
838
file_exchange *exchange;
829
839
select_result *result;
841
/* An item representing the DEFAULT clause in CREATE/ALTER TABLE */
843
/* An item representing the ON UPDATE clause in CREATE/ALTER TABLE */
844
Item *on_update_value;
845
/* Not really sure what exactly goes in here... Comment text at beginning of statement? */
832
849
* This is current used to store the name of a named key cache
833
850
* or a named savepoint. It should probably be refactored out into
851
868
List<Item> *insert_list,field_list,value_list,update_list;
852
869
List<List_item> many_values;
853
870
List<set_var_base> var_list;
871
List<Item_param> param_list;
855
873
A stack of name resolution contexts for the query. This stack is used
856
874
at parse time to set local name resolution contexts for various parts
869
887
SQL_LIST auxiliary_table_list;
870
888
SQL_LIST save_list;
871
CreateField *last_field;
889
Create_field *last_field;
872
890
Item_sum *in_sum_func;
873
plugin::Function *udf;
891
Function_builder *udf;
892
HA_CHECK_OPT check_opt; // check/repair options
893
HA_CREATE_INFO create_info;
894
drizzled::message::Table *create_table_proto;
895
KEY_CREATE_INFO key_create_info;
876
898
This variable is used in post-parse stage to declare that sum-functions,
884
906
nesting_map allow_sum_func;
885
907
enum_sql_command sql_command;
886
statement::Statement *statement;
888
909
Usually `expr` rule of yacc is quite reused but some commands better
889
910
not support subqueries which comes standard with this rule, like
895
916
thr_lock_type lock_option;
896
917
enum enum_duplicates duplicates;
918
enum enum_tx_isolation tx_isolation;
919
enum enum_ha_read_modes ha_read_mode;
898
921
enum ha_rkey_function ha_rkey_mode;
899
922
enum xa_option_words xa_opt;
923
bool lock_transactional; /* For LOCK Table ... IN ... MODE */
901
sql_var_t option_type;
925
enum enum_var_type option_type;
927
enum column_format_type column_format;
928
enum Foreign_key::fk_match_opt fk_match_option;
929
enum Foreign_key::fk_option fk_update_opt;
930
enum Foreign_key::fk_option fk_delete_opt;
931
/* Options used in START TRANSACTION statement */
932
uint32_t start_transaction_opt;
935
In LEX representing update which were transformed to multi-update
936
stores total number of tables. For LEX representing multi-delete
937
holds number of tables from which we will delete records.
939
uint32_t table_count;
904
940
uint8_t describe;
906
942
A flag that indicates what kinds of derived tables are present in the
909
945
uint8_t derived_tables;
947
/* True if "IF EXISTS" used in DROP statement */
949
/* True if "TEMPORARY" used in DROP/CREATE statement */
953
/* Only true when FULL symbol is found (e.g. SHOW FULL PROCESSLIST) */
956
/* Was the CHAIN option using in COMMIT/ROLLBACK? */
958
/* Was the RELEASE option used in COMMIT/ROLLBACK? */
911
960
/* Was the IGNORE symbol found in statement */
962
Alter_info alter_info;
965
Pointers to part of LOAD DATA statement that should be rewritten
966
during replication ("LOCAL 'filename' REPLACE INTO" part).
968
const char *fname_start;
969
const char *fname_end;
915
972
During name resolution search only in the table list given by
938
995
void link_first_table_back(TableList *first, bool link_to_local);
939
996
void first_lists_tables_same();
998
bool only_view_structure();
999
bool need_correct_ident();
941
1001
void cleanup_after_one_table_open();
943
1003
bool push_context(Name_resolution_context *context)
985
bool is_cross; // CROSS keyword was used
990
void setCacheable(bool val)
997
sum_expr_used= false;
1000
void setSumExprUsed()
1002
sum_expr_used= true;
1005
bool isSumExprUsed()
1007
return sum_expr_used;
1010
void start(Session *session);
1018
1047
extern void lex_start(Session *session);
1048
extern void lex_end(LEX *lex);
1019
1049
extern void trim_whitespace(const CHARSET_INFO * const cs, LEX_STRING *str);
1020
1050
extern bool is_lex_native_function(const LEX_STRING *name);