46
46
#define yyoverflow(A,B,C,D,E,F) \
48
unsigned long val= *(F); \
49
49
if (drizzled::my_yyoverflow((B), (D), &val)) \
51
51
yyerror((char*) (A)); \
60
60
#define DRIZZLE_YYABORT \
63
LEX::cleanup_lex_after_parse_error(YYSession);\
67
66
#define DRIZZLE_YYABORT_UNLESS(A) \
70
parser::error_t pass= { ER(ER_SYNTAX_ERROR), YYSession };\
71
parser::my_parse_error(pass);\
69
parser::my_parse_error(YYSession->m_lip);\
113
111
static void DRIZZLEerror(const char *s)
115
Session *session= current_session;
118
Restore the original LEX if it was replaced when parsing
119
a stored procedure. We must ensure that a parsing error
120
does not leave any side effects in the Session.
122
LEX::cleanup_lex_after_parse_error(session);
124
/* "parse error" changed into "syntax error" between bison 1.75 and 1.875 */
125
if (strcmp(s,"parse error") == 0 || strcmp(s,"syntax error") == 0)
126
s= ER(ER_SYNTAX_ERROR);
128
parser::error_t pass= { s, session };
129
parser::my_parse_error(pass);
132
116
} /* namespace drizzled; */
852
835
| CREATE opt_table_options TABLE_SYM opt_if_not_exists table_ident
854
Lex->sql_command= SQLCOM_CREATE_TABLE;
855
837
Lex->statement= new statement::CreateTable(YYSession, $5, $2);
857
839
if (not Lex->select_lex.add_table_to_list(YYSession, $5, NULL,
867
849
| CREATE build_method
869
Lex->sql_command= SQLCOM_CREATE_INDEX;
870
statement::CreateIndex *statement= new statement::CreateIndex(YYSession);
871
Lex->statement= statement;
873
statement->alter_info.flags.set(ALTER_ADD_INDEX);
874
statement->alter_info.build_method= $2;
875
Lex->col_list.empty();
876
statement->change=NULL;
851
Lex->statement= new statement::CreateIndex(YYSession, $2);
878
853
opt_unique INDEX_SYM ident key_alg ON table_ident '(' key_list ')' key_options
954
928
Lex->lock_option= TL_READ;
955
929
if (Lex->sql_command == SQLCOM_INSERT)
957
Lex->sql_command= SQLCOM_INSERT_SELECT;
958
931
delete Lex->statement;
959
932
Lex->statement= new statement::InsertSelect(YYSession);
961
934
else if (Lex->sql_command == SQLCOM_REPLACE)
963
Lex->sql_command= SQLCOM_REPLACE_SELECT;
964
936
delete Lex->statement;
965
937
Lex->statement= new statement::ReplaceSelect(YYSession);
2270
2236
Select_Lex * sel= Lex->current_select;
2271
2237
if (Lex->current_select->set_braces(0))
2273
parser::error_t pass= { ER(ER_SYNTAX_ERROR), YYSession };
2274
parser::my_parse_error(pass);
2239
parser::my_parse_error(YYSession->m_lip);
2275
2240
DRIZZLE_YYABORT;
2277
2242
if (sel->linkage == UNION_TYPE &&
2278
2243
sel->master_unit()->first_select()->braces)
2280
parser::error_t pass= { ER(ER_SYNTAX_ERROR), YYSession };
2281
parser::my_parse_error(pass);
2245
parser::my_parse_error(YYSession->m_lip);
2282
2246
DRIZZLE_YYABORT;
3278
3242
/* disallow "SELECT @@global.global.variable" */
3279
3243
if ($3.str && $4.str && parser::check_reserved_words(&$3))
3281
parser::error_t pass= { ER(ER_SYNTAX_ERROR), YYSession };
3282
parser::my_parse_error(pass);
3245
parser::my_parse_error(YYSession->m_lip);
3283
3246
DRIZZLE_YYABORT;
3285
3248
if (!($$= get_system_var(YYSession, $2, $3, $4)))
3321
3284
if (Lex->current_select->inc_in_sum_expr())
3323
parser::error_t pass= { ER(ER_SYNTAX_ERROR), YYSession };
3324
parser::my_parse_error(pass);
3286
parser::my_parse_error(YYSession->m_lip);
3325
3287
DRIZZLE_YYABORT;
3609
3571
if (sel->set_braces(1))
3611
parser::error_t pass= { ER(ER_SYNTAX_ERROR), YYSession };
3612
parser::my_parse_error(pass);
3573
parser::my_parse_error(YYSession->m_lip);
3613
3574
DRIZZLE_YYABORT;
3615
3576
/* select in braces, can't contain global parameters */
3673
3634
else if (($3->select_lex && $3->select_lex->master_unit()->is_union()) || $5)
3675
3636
/* simple nested joins cannot have aliases or unions */
3676
parser::error_t pass= { ER(ER_SYNTAX_ERROR), YYSession };
3677
parser::my_parse_error(pass);
3637
parser::my_parse_error(YYSession->m_lip);
3678
3638
DRIZZLE_YYABORT;
3709
3669
Select_Lex * sel= Lex->current_select;
3710
3670
if (Lex->current_select->set_braces(0))
3712
parser::error_t pass= { ER(ER_SYNTAX_ERROR), YYSession };
3713
parser::my_parse_error(pass);
3672
parser::my_parse_error(YYSession->m_lip);
3714
3673
DRIZZLE_YYABORT;
3716
3675
if (sel->linkage == UNION_TYPE &&
3717
3676
sel->master_unit()->first_select()->braces)
3719
parser::error_t pass= { ER(ER_SYNTAX_ERROR), YYSession };
3720
parser::my_parse_error(pass);
3678
parser::my_parse_error(YYSession->m_lip);
3721
3679
DRIZZLE_YYABORT;
3766
3723
Lex->derived_tables|= DERIVED_SUBQUERY;
3767
3724
if (not Lex->expr_allows_subselect)
3769
parser::error_t pass= { ER(ER_SYNTAX_ERROR), YYSession };
3770
parser::my_parse_error(pass);
3726
parser::my_parse_error(YYSession->m_lip);
3771
3727
DRIZZLE_YYABORT;
3773
3729
if (Lex->current_select->linkage == GLOBAL_OPTIONS_TYPE || new_select(Lex, 1))
3795
3751
if (!sel->embedding || sel->end_nested_join(Lex->session))
3797
3753
/* we are not in parentheses */
3798
parser::error_t pass= { ER(ER_SYNTAX_ERROR), YYSession };
3799
parser::my_parse_error(pass);
3754
parser::my_parse_error(YYSession->m_lip);
3800
3755
DRIZZLE_YYABORT;
3802
3757
embedding= Lex->current_select->embedding;
4071
Select_Lex *sel= Lex->current_select;
4072
Select_Lex_Unit *unit= sel-> master_unit();
4073
if (sel->linkage != GLOBAL_OPTIONS_TYPE &&
4074
sel->olap != UNSPECIFIED_OLAP_TYPE &&
4075
(sel->linkage != UNION_TYPE || sel->braces))
4077
my_error(ER_WRONG_USAGE, MYF(0),
4078
"CUBE/ROLLUP", "ORDER BY");
4026
if (not parser::buildOrderBy(YYSession))
4079
4027
DRIZZLE_YYABORT;
4081
if (Lex->sql_command != SQLCOM_ALTER_TABLE && !unit->fake_select_lex)
4084
A query of the of the form (SELECT ...) ORDER BY order_list is
4085
executed in the same way as the query
4086
SELECT ... ORDER BY order_list
4087
unless the SELECT construct contains ORDER BY or LIMIT clauses.
4088
Otherwise we create a fake Select_Lex if it has not been created
4091
Select_Lex *first_sl= unit->first_select();
4092
if (!unit->is_union() &&
4093
(first_sl->order_list.elements ||
4094
first_sl->select_limit) &&
4095
unit->add_fake_select_lex(Lex->session))
4103
4033
order_list ',' order_ident order_dir
4104
{ if (YYSession->add_order_to_list($3,(bool) $4)) DRIZZLE_YYABORT; }
4035
if (YYSession->add_order_to_list($3,(bool) $4))
4105
4038
| order_ident order_dir
4106
{ if (YYSession->add_order_to_list($1,(bool) $2)) DRIZZLE_YYABORT; }
4040
if (YYSession->add_order_to_list($1,(bool) $2))
4178
NUM { int error; $$= (ulong) internal::my_strtoll10($1.str, (char**) 0, &error); }
4179
| HEX_NUM { $$= (ulong) strtol($1.str, (char**) 0, 16); }
4180
| LONG_NUM { int error; $$= (ulong) internal::my_strtoll10($1.str, (char**) 0, &error); }
4181
| ULONGLONG_NUM { int error; $$= (ulong) internal::my_strtoll10($1.str, (char**) 0, &error); }
4182
| DECIMAL_NUM { int error; $$= (ulong) internal::my_strtoll10($1.str, (char**) 0, &error); }
4183
| FLOAT_NUM { int error; $$= (ulong) internal::my_strtoll10($1.str, (char**) 0, &error); }
4114
NUM { int error; $$= (unsigned long) internal::my_strtoll10($1.str, (char**) 0, &error); }
4115
| HEX_NUM { $$= (unsigned long) strtol($1.str, (char**) 0, 16); }
4116
| LONG_NUM { int error; $$= (unsigned long) internal::my_strtoll10($1.str, (char**) 0, &error); }
4117
| ULONGLONG_NUM { int error; $$= (unsigned long) internal::my_strtoll10($1.str, (char**) 0, &error); }
4118
| DECIMAL_NUM { int error; $$= (unsigned long) internal::my_strtoll10($1.str, (char**) 0, &error); }
4119
| FLOAT_NUM { int error; $$= (unsigned long) internal::my_strtoll10($1.str, (char**) 0, &error); }
4265
4201
| DROP opt_temporary table_or_tables if_exists table_list
4267
Lex->sql_command = SQLCOM_DROP_TABLE;
4268
4203
statement::DropTable *statement= new statement::DropTable(YYSession);
4269
4204
Lex->statement= statement;
4270
4205
statement->drop_temporary= $2;
4273
4208
| DROP build_method INDEX_SYM ident ON table_ident {}
4275
Lex->sql_command= SQLCOM_DROP_INDEX;
4276
4210
statement::DropIndex *statement= new statement::DropIndex(YYSession);
4277
4211
Lex->statement= statement;
4278
4212
statement->alter_info.flags.set(ALTER_DROP_INDEX);
4285
4219
| DROP DATABASE if_exists schema_name
4287
Lex->sql_command= SQLCOM_DROP_DB;
4288
4221
statement::DropSchema *statement= new statement::DropSchema(YYSession);
4289
4222
Lex->statement= statement;
4290
4223
statement->drop_if_exists=$3;
4514
4445
UPDATE_SYM opt_ignore table_ident
4516
4447
init_select(Lex);
4517
Lex->sql_command= SQLCOM_UPDATE;
4518
4448
Lex->statement= new statement::Update(YYSession);
4519
4449
Lex->lock_option= TL_UNLOCK; /* Will be set later */
4520
4450
Lex->duplicates= DUP_ERROR;
4606
4535
TRUNCATE_SYM opt_table_sym table_name
4608
Lex->sql_command= SQLCOM_TRUNCATE;
4609
4537
Lex->statement= new statement::Truncate(YYSession);
4610
4538
Lex->select_lex.options= 0;
4611
4539
Lex->select_lex.init_order();
4839
4765
KILL_SYM kill_option expr
4843
Lex->type= ONLY_KILL_QUERY;
4846
Lex->value_list.empty();
4847
Lex->value_list.push_front($3);
4848
Lex->sql_command= SQLCOM_KILL;
4849
Lex->statement= new statement::Kill(YYSession);
4767
Lex->statement= new statement::Kill(YYSession, $3, $2);
5229
5145
$$= (sel->parsing_place != IN_HAVING ||
5230
5146
sel->get_in_sum_expr() > 0) ?
5231
(Item*) new Item_field(Lex->current_context(), $1.str, $3.str,
5233
(Item*) new Item_ref(Lex->current_context(), $1.str, $3.str,
5147
(Item*) new Item_field(Lex->current_context(), $1.str, $3.str, $5.str) :
5148
(Item*) new Item_ref(Lex->current_context(), $1.str, $3.str, $5.str);
5705
5611
COMMIT_SYM opt_work opt_chain opt_release
5707
Lex->sql_command= SQLCOM_COMMIT;
5708
statement::Commit *statement= new statement::Commit(YYSession);
5709
Lex->statement= statement;
5710
statement->tx_chain= $3;
5711
statement->tx_release= $4;
5613
Lex->statement= new statement::Commit(YYSession, $3, $4);
5716
5618
ROLLBACK_SYM opt_work opt_chain opt_release
5718
Lex->sql_command= SQLCOM_ROLLBACK;
5719
statement::Rollback *statement= new statement::Rollback(YYSession);
5720
Lex->statement= statement;
5721
statement->tx_chain= $3;
5722
statement->tx_release= $4;
5620
Lex->statement= new statement::Rollback(YYSession, $3, $4);
5724
5622
| ROLLBACK_SYM opt_work TO_SYM opt_savepoint savepoint_ident
5726
Lex->sql_command= SQLCOM_ROLLBACK_TO_SAVEPOINT;
5727
Lex->statement= new statement::RollbackToSavepoint(YYSession);
5624
Lex->statement= new statement::RollbackToSavepoint(YYSession, $5);
5733
5629
SAVEPOINT_SYM savepoint_ident
5735
Lex->sql_command= SQLCOM_SAVEPOINT;
5736
Lex->statement= new statement::Savepoint(YYSession);
5631
Lex->statement= new statement::Savepoint(YYSession, $2);
5742
5636
RELEASE_SYM SAVEPOINT_SYM savepoint_ident
5744
Lex->sql_command= SQLCOM_RELEASE_SAVEPOINT;
5745
Lex->statement= new statement::ReleaseSavepoint(YYSession);
5638
Lex->statement= new statement::ReleaseSavepoint(YYSession, $3);
5854
5746
if (not Lex->expr_allows_subselect)
5856
parser::error_t pass= { ER(ER_SYNTAX_ERROR), YYSession };
5857
parser::my_parse_error(pass);
5748
parser::my_parse_error(YYSession->m_lip);
5858
5749
DRIZZLE_YYABORT;