25
25
** The type will be void*, so it must be cast to (Session*) when used.
26
26
** Use the YYSession macro for this.
29
#define YYSession (session)
28
#define YYPARSE_PARAM yysession
29
#define YYLEX_PARAM yysession
30
#define YYSession (static_cast<Session *>(yysession))
31
32
#define YYENABLE_NLS 0
32
33
#define YYLTYPE_IS_TRIVIAL 0
34
36
#define YYINITDEPTH 100
35
37
#define YYMAXDEPTH 3200 /* Because of 64K stack */
36
#define Lex (session->getLex())
38
#define Lex (YYSession->lex)
40
#include <drizzled/parser.h>
42
#include "drizzled/parser.h"
42
int yylex(union ParserType *yylval, drizzled::Session *session);
44
int yylex(void *yylval, void *yysession);
44
46
#define yyoverflow(A,B,C,D,E,F) \
46
48
unsigned long val= *(F); \
47
49
if (drizzled::my_yyoverflow((B), (D), &val)) \
49
yyerror(NULL, (char*) (A)); \
51
yyerror((char*) (A)); \
103
108
to abort from the parser.
106
static void base_sql_error(drizzled::Session *session, const char *s)
111
static void DRIZZLEerror(const char *s)
108
parser::errorOn(session, s);
111
116
} /* namespace drizzled; */
113
118
using namespace drizzled;
118
123
unsigned long ulong_num;
157
162
namespace drizzled
159
bool my_yyoverflow(short **a, union ParserType **b, unsigned long *yystacksize);
164
bool my_yyoverflow(short **a, YYSTYPE **b, unsigned long *yystacksize);
166
%name-prefix="base_sql_"
167
%parse-param { drizzled::Session *session }
168
%lex-param { drizzled::Session *session }
169
%pure_parser /* We have threads */
173
172
Currently there are 70 shift/reduce conflicts.
393
395
%token NATIONAL_SYM /* SQL-2003-R */
394
396
%token NATURAL /* SQL-2003-R */
395
397
%token NE /* OPERATOR */
396
399
%token NEW_SYM /* SQL-2003-R */
397
400
%token NEXT_SYM /* SQL-2003-N */
398
401
%token NONE_SYM /* SQL-2003-R */
439
442
%token REPEATABLE_SYM /* SQL-2003-N */
440
443
%token REPEAT_SYM /* MYSQL-FUNC */
441
444
%token REPLACE /* MYSQL-FUNC */
444
446
%token RETURNS_SYM /* SQL-2003-R */
445
447
%token RETURN_SYM /* SQL-2003-R */
552
554
%token YEAR_SYM /* SQL-2003-R */
553
555
%token ZEROFILL_SYM
555
/* Lowest to highest */
556
557
%left JOIN_SYM INNER_SYM STRAIGHT_JOIN CROSS LEFT RIGHT
557
558
/* A dummy token to force the priority of table_ref production in a join. */
558
%left TABLE_REF_PRIORITY
565
%nonassoc EQUAL_SYM GE '>' LE '<' NE
566
%nonassoc LIKE REGEXP_SYM
567
%nonassoc BETWEEN_SYM
569
%nonassoc IS NULL_SYM TRUE_SYM FALSE_SYM
559
%left TABLE_REF_PRIORITY
564
%left BETWEEN_SYM CASE_SYM WHEN_SYM THEN_SYM ELSE
565
%left EQ EQUAL_SYM GE GT_SYM LE LT NE IS LIKE REGEXP_SYM IN_SYM
571
567
%left '*' '/' '%' DIV_SYM MOD_SYM
572
570
%right BINARY COLLATE_SYM
573
571
%left INTERVAL_SYM
579
574
IDENT IDENT_QUOTED TEXT_STRING DECIMAL_NUM FLOAT_NUM NUM LONG_NUM HEX_NUM
728
723
opt_precision opt_ignore opt_column
729
724
set unlock string_list
730
725
ref_list opt_match_clause opt_on_update_delete use
731
opt_delete_option varchar
726
opt_delete_options opt_delete_option varchar
732
727
opt_outer table_list table_name
733
728
opt_option opt_place
734
729
opt_attribute opt_attribute_list attribute
750
746
%type <num> index_hint_clause
751
747
%type <filetype> data_file
750
'-' '+' '*' '/' '%' '(' ')'
751
',' '!' '{' '}' AND_SYM OR_SYM BETWEEN_SYM CASE_SYM
752
THEN_SYM WHEN_SYM DIV_SYM MOD_SYM DELETE_SYM
779
if (!(YYSession->getLex()->select_lex.options & OPTION_FOUND_COMMENT))
779
Session *session= YYSession;
780
if (!(session->lex->select_lex.options & OPTION_FOUND_COMMENT))
781
782
my_message(ER_EMPTY_QUERY, ER(ER_EMPTY_QUERY), MYF(0));
786
YYSession->getLex()->statement= new statement::EmptyQuery(YYSession);
787
session->lex->statement= new statement::EmptyQuery(YYSession);
789
790
| verb_clause END_OF_INPUT {}
970
971
statement::CreateSchema *statement= (statement::CreateSchema *)Lex->statement;
971
972
statement->schema_message.mutable_engine()->add_options()->set_name($1.str);
973
| REPLICATION opt_equal TRUE_SYM
975
parser::buildReplicationOption(Lex, true);
977
| REPLICATION opt_equal FALSE_SYM
979
parser::buildReplicationOption(Lex, false);
981
974
| ident_or_text equal ident_or_text
983
976
parser::buildSchemaOption(Lex, $1.str, $3);
1030
1023
Lex->table()->mutable_options()->set_auto_increment_value($3);
1032
| REPLICATION opt_equal TRUE_SYM
1034
Lex->table()->mutable_options()->set_dont_replicate(false);
1036
| REPLICATION opt_equal FALSE_SYM
1038
Lex->table()->mutable_options()->set_dont_replicate(true);
1040
1025
| ROW_FORMAT_SYM equal row_format_or_text
1042
1027
parser::buildEngineOption(Lex, "ROW_FORMAT", $3);
1130
1115
| constraint opt_check_constraint
1132
Lex->col_list.clear(); /* Alloced by memory::sql_alloc */
1117
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1134
1119
| opt_constraint check_constraint
1136
Lex->col_list.clear(); /* Alloced by memory::sql_alloc */
1121
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1802
1791
| DROP FOREIGN KEY_SYM opt_ident
1804
parser::buildAddAlterDropIndex(Lex, $4.str, true);
1793
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1794
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::FOREIGN_KEY,
1796
statement->alter_info.flags.set(ALTER_DROP_INDEX);
1797
statement->alter_info.flags.set(ALTER_FOREIGN_KEY);
1806
1799
| DROP PRIMARY_SYM KEY_SYM
1808
parser::buildAddAlterDropIndex(Lex, "PRIMARY");
1801
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1803
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY,
1805
statement->alter_info.flags.set(ALTER_DROP_INDEX);
1810
1807
| DROP key_or_index field_ident
1812
parser::buildAddAlterDropIndex(Lex, $3.str);
1809
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1811
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY,
1813
statement->alter_info.flags.set(ALTER_DROP_INDEX);
1814
1815
| DISABLE_SYM KEYS
2164
if (YYSession->add_item_to_list( new Item_field(&YYSession->getLex()->current_select->context, NULL, NULL, "*")))
2166
if (YYSession->add_item_to_list( new Item_field(&YYSession->lex->current_select->
2165
2169
DRIZZLE_YYABORT;
2167
(YYSession->getLex()->current_select->with_wild)++;
2170
(YYSession->lex->current_select->with_wild)++;
2341
2344
{ $$= new Item_func_isnotnull($1); }
2342
2345
| bool_pri EQUAL_SYM predicate %prec EQUAL_SYM
2343
2346
{ $$= new Item_func_equal($1,$3); }
2344
| bool_pri comp_op predicate %prec '='
2347
| bool_pri comp_op predicate %prec EQ
2345
2348
{ $$= (*$2)(0)->create($1,$3); }
2346
| bool_pri comp_op all_or_any '(' subselect ')' %prec '='
2349
| bool_pri comp_op all_or_any '(' subselect ')' %prec EQ
2347
2350
{ $$= all_any_subquery_creator($1, $2, $3, $5); }
2460
'=' { $$ = &comp_eq_creator; }
2463
EQ { $$ = &comp_eq_creator; }
2461
2464
| GE { $$ = &comp_ge_creator; }
2462
| '>' { $$ = &comp_gt_creator; }
2465
| GT_SYM { $$ = &comp_gt_creator; }
2463
2466
| LE { $$ = &comp_le_creator; }
2464
| '<' { $$ = &comp_lt_creator; }
2467
| LT { $$ = &comp_lt_creator; }
2465
2468
| NE { $$ = &comp_ne_creator; }
2476
2479
| function_call_nonkeyword
2477
2480
| function_call_generic
2478
2481
| function_call_conflict
2479
| simple_expr COLLATE_SYM ident_or_text %prec UMINUS
2482
| simple_expr COLLATE_SYM ident_or_text %prec NEG
2481
2484
Item *i1= new (YYSession->mem_root) Item_string($3.str,
2490
2493
Lex->setSumExprUsed();
2492
| '+' simple_expr %prec UMINUS { $$= $2; }
2493
| '-' simple_expr %prec UMINUS
2495
| '+' simple_expr %prec NEG { $$= $2; }
2496
| '-' simple_expr %prec NEG
2494
2497
{ $$= new (YYSession->mem_root) Item_func_neg($2); }
2495
2498
| '(' subselect ')'
2512
2515
$$= new (YYSession->mem_root) Item_exists_subselect($3);
2514
2517
| '{' ident expr '}' { $$= $3; }
2515
| BINARY simple_expr %prec UMINUS
2518
| BINARY simple_expr %prec NEG
2517
2520
$$= create_func_cast(YYSession, $2, ITEM_CAST_CHAR, NULL, NULL,
2518
2521
&my_charset_bin);
2559
2562
{ $$= new (YYSession->mem_root) Item_func_char(*$3); }
2560
2563
| CURRENT_USER optional_braces
2562
if (! ($$= parser::reserved_keyword_function(YYSession, "user", NULL)))
2565
std::string user_str("user");
2566
if (! ($$= parser::reserved_keyword_function(YYSession, user_str, NULL)))
2564
2568
DRIZZLE_YYABORT;
2679
2683
{ $$= new (YYSession->mem_root) Item_date_add_interval($3, $6, $7, 1); }
2680
2684
| SUBSTRING '(' expr ',' expr ',' expr ')'
2686
std::string reverse_str("substr");
2682
2687
List<Item> *args= new (YYSession->mem_root) List<Item>;
2683
2688
args->push_back($3);
2684
2689
args->push_back($5);
2685
2690
args->push_back($7);
2686
if (! ($$= parser::reserved_keyword_function(YYSession, "substr", args)))
2691
if (! ($$= parser::reserved_keyword_function(YYSession, reverse_str, args)))
2688
2693
DRIZZLE_YYABORT;
2691
2696
| SUBSTRING '(' expr ',' expr ')'
2698
std::string reverse_str("substr");
2693
2699
List<Item> *args= new (YYSession->mem_root) List<Item>;
2694
2700
args->push_back($3);
2695
2701
args->push_back($5);
2696
if (! ($$= parser::reserved_keyword_function(YYSession, "substr", args)))
2702
if (! ($$= parser::reserved_keyword_function(YYSession, reverse_str, args)))
2698
2704
DRIZZLE_YYABORT;
2701
2707
| SUBSTRING '(' expr FROM expr FOR_SYM expr ')'
2709
std::string reverse_str("substr");
2703
2710
List<Item> *args= new (YYSession->mem_root) List<Item>;
2704
2711
args->push_back($3);
2705
2712
args->push_back($5);
2706
2713
args->push_back($7);
2707
if (! ($$= parser::reserved_keyword_function(YYSession, "substr", args)))
2714
if (! ($$= parser::reserved_keyword_function(YYSession, reverse_str, args)))
2709
2716
DRIZZLE_YYABORT;
2712
2719
| SUBSTRING '(' expr FROM expr ')'
2721
std::string reverse_str("substr");
2714
2722
List<Item> *args= new (YYSession->mem_root) List<Item>;
2715
2723
args->push_back($3);
2716
2724
args->push_back($5);
2717
if (! ($$= parser::reserved_keyword_function(YYSession, "substr", args)))
2725
if (! ($$= parser::reserved_keyword_function(YYSession, reverse_str, args)))
2719
2727
DRIZZLE_YYABORT;
2790
2798
{ $$= new (YYSession->mem_root) Item_func_if($3,$5,$7); }
2791
2799
| KILL_SYM kill_option '(' expr ')'
2801
std::string kill_str("kill");
2793
2802
List<Item> *args= new (YYSession->mem_root) List<Item>;
2794
2803
args->push_back($4);
2798
2807
args->push_back(new (YYSession->mem_root) Item_uint(1));
2801
if (! ($$= parser::reserved_keyword_function(YYSession, "kill", args)))
2810
if (! ($$= parser::reserved_keyword_function(YYSession, kill_str, args)))
2803
2812
DRIZZLE_YYABORT;
2817
2826
{ $$= new (YYSession->mem_root) Item_func_round($3,$5,1); }
2818
2827
| WAIT_SYM '(' expr ')'
2829
std::string wait_str("wait");
2820
2830
List<Item> *args= new (YYSession->mem_root) List<Item>;
2821
2831
args->push_back($3);
2822
if (! ($$= parser::reserved_keyword_function(YYSession, "wait", args)))
2832
if (! ($$= parser::reserved_keyword_function(YYSession, wait_str, args)))
2824
2834
DRIZZLE_YYABORT;
2835
2845
| WAIT_SYM '(' expr ',' expr ')'
2847
std::string wait_str("wait");
2837
2848
List<Item> *args= new (YYSession->mem_root) List<Item>;
2838
2849
args->push_back($3);
2839
2850
args->push_back($5);
2840
if (! ($$= parser::reserved_keyword_function(YYSession, "wait", args)))
2851
if (! ($$= parser::reserved_keyword_function(YYSession, wait_str, args)))
2842
2853
DRIZZLE_YYABORT;
4231
4243
Lex->duplicates= DUP_ERROR;
4232
4244
if (not Lex->select_lex.add_table_to_list(YYSession, $3, NULL,0))
4233
4245
DRIZZLE_YYABORT;
4235
4249
if (Lex->select_lex.get_table_list()->derived)
4237
4251
/* it is single table update and it is update of derived table */
4279
4293
/* Delete rows from a table */
4282
DELETE_SYM opt_delete_option FROM table_ident
4284
4298
Lex->statement= new statement::Delete(YYSession);
4285
4299
init_select(Lex);
4286
4300
Lex->lock_option= TL_WRITE_DEFAULT;
4287
4302
Lex->select_lex.init_order();
4304
opt_delete_options single_multi
4289
if (!Lex->current_select->add_table_to_list(YYSession, $4, NULL, TL_OPTION_UPDATING,
4310
if (!Lex->current_select->add_table_to_list(YYSession, $2, NULL, TL_OPTION_UPDATING,
4290
4311
Lex->lock_option))
4291
4312
DRIZZLE_YYABORT;
4582
4607
$12, NULL, TL_OPTION_UPDATING,
4583
4608
Lex->lock_option))
4584
4609
DRIZZLE_YYABORT;
4585
Lex->field_list.clear();
4586
Lex->update_list.clear();
4587
Lex->value_list.clear();
4610
Lex->field_list.empty();
4611
Lex->update_list.empty();
4612
Lex->value_list.empty();
4589
4614
opt_field_term opt_line_term opt_ignore_lines opt_field_or_var_spec
4590
4615
opt_load_data_set_spec