1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems, Inc.
4
* Copyright (C) 2008 Sun Microsystems
6
6
* This program is free software; you can redistribute it and/or modify
7
7
* it under the terms of the GNU General Public License as published by
26
26
#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>
28
#include "drizzled/sql_udf.h"
29
#include "drizzled/name_resolution_context.h"
30
#include "drizzled/item/subselect.h"
31
#include "drizzled/item/param.h"
32
#include "drizzled/item/outer_ref.h"
33
#include "drizzled/table_list.h"
34
#include "drizzled/function/math/real.h"
35
#include "drizzled/alter_drop.h"
36
#include "drizzled/alter_column.h"
37
#include "drizzled/key.h"
38
#include "drizzled/foreign_key.h"
39
#include "drizzled/item/param.h"
40
#include "drizzled/index_hint.h"
41
#include "drizzled/statement.h"
48
45
class select_result_interceptor;
50
47
/* YACC and LEX Definitions */
56
53
class Item_outer_ref;
58
} /* namespace drizzled */
61
56
The following hack is needed because mysql_yacc.cc does not define
62
57
YYSTYPE before including this file
65
60
#ifdef DRIZZLE_SERVER
66
/* set_var should change to set_var here ... */
67
# include <drizzled/sys_var.h>
61
# include <drizzled/set_var.h>
68
62
# include <drizzled/item/func.h>
69
63
# ifdef DRIZZLE_YACC
70
64
# define LEX_YYSTYPE void *
72
66
# if defined(DRIZZLE_LEX)
73
# include <drizzled/foreign_key.h>
74
67
# include <drizzled/lex_symbol.h>
75
68
# include <drizzled/sql_yacc.h>
76
69
# define LEX_YYSTYPE YYSTYPE *
250
247
UNCACHEABLE_EXPLAIN
251
248
UNCACHEABLE_PREPARE
253
std::bitset<8> uncacheable;
254
251
enum sub_select_type linkage;
255
252
bool no_table_names_allowed; /* used for global order by */
256
253
bool no_error; /* suppress error message (convert it to warnings) */
258
255
static void *operator new(size_t size)
260
return memory::sql_alloc(size);
257
return sql_alloc(size);
262
static void *operator new(size_t size, memory::Root *mem_root)
263
{ return (void*) mem_root->alloc_root((uint32_t) size); }
259
static void *operator new(size_t size, MEM_ROOT *mem_root)
260
{ return (void*) alloc_root(mem_root, (uint32_t) size); }
264
261
static void operator delete(void *, size_t)
266
static void operator delete(void *, memory::Root *)
262
{ TRASH(ptr, size); }
263
static void operator delete(void *, MEM_ROOT *)
268
265
Select_Lex_Node(): linkage(UNSPECIFIED_TYPE) {}
269
266
virtual ~Select_Lex_Node() {}
285
282
virtual uint32_t get_in_sum_expr();
286
283
virtual TableList* get_table_list();
287
284
virtual List<Item>* get_item_list();
285
virtual uint32_t get_table_join_options();
288
286
virtual TableList *add_table_to_list(Session *session, Table_ident *table,
290
const std::bitset<NUM_OF_TABLE_OPTIONS>& table_options,
291
thr_lock_type flags= TL_UNLOCK,
292
List<Index_hint> *hints= 0,
293
LEX_STRING *option= 0);
288
uint32_t table_options,
289
thr_lock_type flags= TL_UNLOCK,
290
List<Index_hint> *hints= 0,
291
LEX_STRING *option= 0);
294
292
virtual void set_lock_for_tables(thr_lock_type)
297
295
friend class Select_Lex_Unit;
298
friend bool new_select(LEX *lex, bool move_down);
296
friend bool mysql_new_select(LEX *lex, bool move_down);
300
298
void fast_exclude();
405
403
class Select_Lex: public Select_Lex_Node
417
olap(UNSPECIFIED_OLAP_TYPE),
422
is_item_list_lookup(false),
429
type(optimizer::ST_PRIMARY),
434
ref_pointer_array(0),
435
select_n_having_items(0),
439
select_n_where_fields(0),
440
parsing_place(NO_MATTER),
445
inner_sum_func_list(0),
451
n_child_sum_items(0),
454
subquery_in_having(0),
456
exclude_from_table_unique_test(0),
458
cur_pos_in_select_list(0),
460
full_group_by_flag(),
461
current_index_hint_type(INDEX_HINT_IGNORE),
462
current_index_hint_clause(),
467
406
Name_resolution_context context;
469
408
/* An Item representing the WHERE clause */
482
421
List<Item> item_list; /* list of fields & expressions */
483
422
List<String> interval_list;
484
423
bool is_item_list_lookup;
485
Join *join; /* after Join::prepare it is pointer to corresponding JOIN */
424
JOIN *join; /* after JOIN::prepare it is pointer to corresponding JOIN */
486
425
List<TableList> top_join_list; /* join list of the top level */
487
426
List<TableList> *join_list; /* list for the currently parsed join */
488
427
TableList *embedding; /* table embedding to the above list */
493
432
by TableList::next_leaf, so leaf_tables points to the left-most leaf.
495
434
TableList *leaf_tables;
496
enum drizzled::optimizer::select_type type; /* type of select for EXPLAIN */
435
const char *type; /* type of select for EXPLAIN */
498
437
SQL_LIST order_list; /* ORDER clause */
499
438
SQL_LIST *gorder_list;
518
457
enum_parsing_place parsing_place; /* where we are parsing expression */
519
458
bool with_sum_func; /* sum function indicator */
460
uint32_t table_join_options;
521
461
uint32_t in_sum_expr;
522
462
uint32_t select_number; /* number of select (used for EXPLAIN) */
523
463
int8_t nest_level; /* nesting level of select */
615
550
TableList* add_table_to_list(Session *session,
616
551
Table_ident *table,
617
552
LEX_STRING *alias,
618
const std::bitset<NUM_OF_TABLE_OPTIONS>& table_options,
553
uint32_t table_options,
619
554
thr_lock_type flags= TL_UNLOCK,
620
555
List<Index_hint> *hints= 0,
621
556
LEX_STRING *option= 0);
626
561
void add_joined_table(TableList *table);
627
562
TableList *convert_right_join();
628
563
List<Item>* get_item_list();
564
uint32_t get_table_join_options();
629
565
void set_lock_for_tables(thr_lock_type lock_type);
630
566
inline void init_order()
634
570
order_list.next= (unsigned char**) &order_list.first;
637
This method created for reiniting LEX in admin_table() and can be
573
This method created for reiniting LEX in mysql_admin_table() and can be
638
574
used only if you are going remove all Select_Lex & units except belonger
639
575
to LEX (LEX::unit & LEX::select, for other purposes there are
640
576
Select_Lex_Unit::exclude_level & Select_Lex_Unit::exclude_tree
654
591
bool setup_ref_array(Session *session, uint32_t order_group_num);
655
592
void print(Session *session, String *str, enum_query_type query_type);
656
593
static void print_order(String *str,
658
595
enum_query_type query_type);
659
596
void print_limit(Session *session, String *str, enum_query_type query_type);
660
597
void fix_prepare_information(Session *session, Item **conds, Item **having_conds);
703
640
first_select()->next_select()->linkage == UNION_TYPE;
643
enum enum_alter_info_flags
648
ALTER_COLUMN_STORAGE,
656
ALTER_COLUMN_DEFAULT,
668
@brief Parsing data for CREATE or ALTER Table.
670
This structure contains a list of columns or indexes to be created,
677
List<Alter_drop> drop_list;
678
List<Alter_column> alter_list;
680
List<CreateField> create_list;
681
std::bitset<32> flags;
682
enum enum_enable_or_disable keys_onoff;
683
enum tablespace_op_type tablespace_op;
685
enum ha_build_method build_method;
686
CreateField *datetime_field;
687
bool error_if_not_empty;
691
keys_onoff(LEAVE_AS_IS),
692
tablespace_op(NO_TABLESPACE_OP),
694
build_method(HA_BUILD_DEFAULT),
695
datetime_field(NULL),
696
error_if_not_empty(false)
706
keys_onoff= LEAVE_AS_IS;
707
tablespace_op= NO_TABLESPACE_OP;
709
build_method= HA_BUILD_DEFAULT;
711
error_if_not_empty= false;
713
Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root);
715
Alter_info &operator=(const Alter_info &rhs); // not implemented
716
Alter_info(const Alter_info &rhs); // not implemented
706
719
enum xa_option_words
745
758
of Query_tables_list instances which are used as backup storage.
747
760
Query_tables_list() {}
748
virtual ~Query_tables_list() {}
761
~Query_tables_list() {}
750
763
/* Initializes (or resets) Query_tables_list object for "real" use. */
751
764
void reset_query_tables_list(bool init);
802
} /* namespace drizzled */
804
#include <drizzled/lex_input_stream.h>
815
#include "drizzled/lex_input_stream.h"
809
817
/* The state of the lex parsing. This is saved in the Session struct */
810
818
class LEX : public Query_tables_list
834
844
file_exchange *exchange;
835
845
select_result *result;
847
/* An item representing the DEFAULT clause in CREATE/ALTER TABLE */
849
/* An item representing the ON UPDATE clause in CREATE/ALTER TABLE */
850
Item *on_update_value;
851
/* Not really sure what exactly goes in here... Comment text at beginning of statement? */
838
855
* This is current used to store the name of a named key cache
839
856
* or a named savepoint. It should probably be refactored out into
856
873
List<Lex_Column> columns;
857
874
List<Item> *insert_list,field_list,value_list,update_list;
858
875
List<List_item> many_values;
859
SetVarVector var_list;
876
List<set_var_base> var_list;
877
List<Item_param> param_list;
861
879
A stack of name resolution contexts for the query. This stack is used
862
880
at parse time to set local name resolution contexts for various parts
876
894
SQL_LIST save_list;
877
895
CreateField *last_field;
878
896
Item_sum *in_sum_func;
879
plugin::Function *udf;
897
Function_builder *udf;
898
HA_CHECK_OPT check_opt; // check/repair options
899
HA_CREATE_INFO create_info;
900
drizzled::message::Table *create_table_proto;
901
StorageEngine *show_engine;
902
KEY_CREATE_INFO key_create_info;
882
905
This variable is used in post-parse stage to declare that sum-functions,
890
913
nesting_map allow_sum_func;
891
914
enum_sql_command sql_command;
892
statement::Statement *statement;
915
drizzled::statement::Statement *statement;
894
917
Usually `expr` rule of yacc is quite reused but some commands better
895
918
not support subqueries which comes standard with this rule, like
901
924
thr_lock_type lock_option;
902
925
enum enum_duplicates duplicates;
926
enum enum_tx_isolation tx_isolation;
927
enum enum_ha_read_modes ha_read_mode;
904
929
enum ha_rkey_function ha_rkey_mode;
905
930
enum xa_option_words xa_opt;
907
sql_var_t option_type;
932
enum enum_var_type option_type;
934
enum column_format_type column_format;
935
enum Foreign_key::fk_match_opt fk_match_option;
936
enum Foreign_key::fk_option fk_update_opt;
937
enum Foreign_key::fk_option fk_delete_opt;
938
/* Options used in START TRANSACTION statement */
939
uint32_t start_transaction_opt;
910
941
uint8_t describe;
915
946
uint8_t derived_tables;
948
/* True if "IF EXISTS" used in DROP statement */
950
/* True if "TEMPORARY" used in DROP/CREATE statement */
954
/* Only true when FULL symbol is found (e.g. SHOW FULL PROCESSLIST) */
957
/* Was the CHAIN option using in COMMIT/ROLLBACK? */
959
/* Was the RELEASE option used in COMMIT/ROLLBACK? */
917
961
/* Was the IGNORE symbol found in statement */
963
Alter_info alter_info;
966
Pointers to part of LOAD DATA statement that should be rewritten
967
during replication ("LOCAL 'filename' REPLACE INTO" part).
969
const char *fname_start;
970
const char *fname_end;
921
973
During name resolution search only in the table list given by
936
988
statement in a session. It's re-used by doing lex_end, lex_start
941
995
TableList *unlink_first_table(bool *link_to_local);
942
996
void link_first_table_back(TableList *first, bool link_to_local);
943
997
void first_lists_tables_same();
999
bool only_view_structure();
1000
bool need_correct_ident();
945
1002
void cleanup_after_one_table_open();
947
1004
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;
1001
void setSumExprUsed()
1003
sum_expr_used= true;
1006
bool isSumExprUsed()
1008
return sum_expr_used;
1011
void start(Session *session);
1014
message::Table *table()
1016
if (not _create_table)
1017
_create_table= new message::Table;
1019
return _create_table;
1022
message::Table::Field *field()
1024
return _create_field;
1027
void setField(message::Table::Field *arg)
1045
message::Table *_create_table;
1046
message::Table::Field *_create_field;
1050
1048
extern void lex_start(Session *session);
1049
extern void lex_end(LEX *lex);
1051
1050
extern void trim_whitespace(const CHARSET_INFO * const cs, LEX_STRING *str);
1052
1051
extern bool is_lex_native_function(const LEX_STRING *name);
1054
bool check_for_sql_keyword(drizzled::st_lex_symbol const&);
1055
bool check_for_sql_keyword(drizzled::lex_string_t const&);
1058
1054
@} (End of group Semantic_Analysis)
1061
} /* namespace drizzled */
1063
1057
#endif /* DRIZZLE_SERVER */
1064
1058
#endif /* DRIZZLED_SQL_LEX_H */