12
12
You should have received a copy of the GNU General Public License
13
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
106
struct my_parse_error_st {
111
static void my_parse_error(void *arg)
104
static void my_parse_error(const char *s)
113
struct my_parse_error_st *ptr= (struct my_parse_error_st *)arg;
115
const char *s= ptr->s;
116
Session *session= ptr->session;
106
Session *session= current_session;
118
107
Lex_input_stream *lip= session->m_lip;
120
109
const char *yytext= lip->get_tok_start();
158
147
/* "parse error" changed into "syntax error" between bison 1.75 and 1.875 */
159
148
if (strcmp(s,"parse error") == 0 || strcmp(s,"syntax error") == 0)
160
149
s= ER(ER_SYNTAX_ERROR);
162
struct my_parse_error_st pass= { s, session };
163
my_parse_error(&pass);
252
239
@return <code>false</code> if successful, <code>true</code> if an error was
253
240
reported. In the latter case parsing should stop.
255
static bool add_select_to_union_list(Session *session, LEX *lex, bool is_union_distinct)
242
static bool add_select_to_union_list(LEX *lex, bool is_union_distinct)
263
250
if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE)
265
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), session };
266
my_parse_error(&pass);
252
my_parse_error(ER(ER_SYNTAX_ERROR));
269
255
/* This counter shouldn't be incremented for UNION parts */
285
271
@return false if successful, true if an error was reported. In the latter
286
272
case parsing should stop.
288
static bool setup_select_in_parentheses(Session *session, LEX *lex)
274
static bool setup_select_in_parentheses(LEX *lex)
290
276
Select_Lex * sel= lex->current_select;
291
277
if (sel->set_braces(1))
293
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), session };
294
my_parse_error(&pass);
279
my_parse_error(ER(ER_SYNTAX_ERROR));
297
282
if (sel->linkage == UNION_TYPE &&
299
284
sel->master_unit()->first_select()->linkage ==
302
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), session };
303
my_parse_error(&pass);
287
my_parse_error(ER(ER_SYNTAX_ERROR));
306
290
if (sel->linkage == UNION_TYPE &&
320
static Item* reserved_keyword_function(Session *session, const std::string &name, List<Item> *item_list)
304
static Item* reserved_keyword_function(const std::string &name, List<Item> *item_list)
322
306
const plugin::Function *udf= plugin::Function::get(name.c_str(), name.length());
323
307
Item *item= NULL;
327
item= Create_udf_func::s_singleton.create(session, udf, item_list);
311
item= Create_udf_func::s_singleton.create(current_session, udf, item_list);
329
313
my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", name.c_str());
358
342
enum drizzled::sql_var_t var_type;
359
343
drizzled::Key::Keytype key_type;
360
344
enum drizzled::ha_key_alg key_alg;
345
enum drizzled::row_type row_type;
361
346
enum drizzled::column_format_type column_format_type;
362
347
enum drizzled::ha_rkey_function ha_rkey_mode;
363
348
enum drizzled::enum_tx_isolation tx_isolation;
372
357
enum drizzled::index_hint_type index_hint;
373
358
enum drizzled::enum_filetype filetype;
374
359
enum drizzled::ha_build_method build_method;
375
drizzled::message::Table::ForeignKeyConstraint::ForeignKeyOption m_fk_option;
376
drizzled::execute_string_t execute_string;
360
enum drizzled::Foreign_key::fk_option m_fk_option;
1214
1190
opt_create_database_options:
1216
1192
| default_collation_schema {}
1217
| opt_database_custom_options {}
1220
opt_database_custom_options:
1221
custom_database_option
1222
| custom_database_option ',' opt_database_custom_options
1225
custom_database_option:
1228
statement::CreateSchema *statement= (statement::CreateSchema *)Lex->statement;
1229
drizzled::message::Engine::Option *opt= statement->schema_message.mutable_engine()->add_options();
1231
opt->set_name($1.str);
1233
| ident_or_text equal ident_or_text
1235
statement::CreateSchema *statement= (statement::CreateSchema *)Lex->statement;
1236
drizzled::message::Engine::Option *opt= statement->schema_message.mutable_engine()->add_options();
1238
opt->set_name($1.str);
1239
opt->set_state($3.str);
1241
| ident_or_text equal ulonglong_num
1243
statement::CreateSchema *statement= (statement::CreateSchema *)Lex->statement;
1244
char number_as_string[22];
1246
snprintf(number_as_string, sizeof(number_as_string), "%"PRIu64, $3);
1248
drizzled::message::Engine::Option *opt= statement->schema_message.mutable_engine()->add_options();
1250
opt->set_name($1.str);
1251
opt->set_state(number_as_string);
1255
1195
opt_table_options:
1276
1216
create_table_option
1277
1217
| create_table_option create_table_options
1278
1218
| create_table_option ',' create_table_options
1280
1221
create_table_option:
1281
custom_engine_option;
1283
custom_engine_option:
1284
ENGINE_SYM equal ident_or_text
1222
ENGINE_SYM opt_equal ident_or_text
1286
1224
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1225
message::Table::StorageEngine *protoengine;
1226
protoengine= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_engine();
1288
1228
statement->is_engine_set= true;
1290
((statement::CreateTable *)Lex->statement)->create_table_message.mutable_engine()->set_name($3.str);
1230
protoengine->set_name($3.str);
1232
| BLOCK_SIZE_SYM opt_equal ulong_num
1234
message::Table::TableOptions *tableopts;
1235
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1236
tableopts= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_options();
1238
tableopts->set_block_size($3);
1239
statement->create_info.used_fields|= HA_CREATE_USED_BLOCK_SIZE;
1292
1241
| COMMENT_SYM opt_equal TEXT_STRING_sys
1307
1256
statement->create_info.used_fields|= HA_CREATE_USED_AUTO;
1308
1257
tableopts->set_auto_increment_value($3);
1310
| ident_or_text equal ident_or_text
1312
drizzled::message::Engine::Option *opt= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_engine()->add_options();
1314
opt->set_name($1.str);
1315
opt->set_state($3.str);
1317
| ident_or_text equal ulonglong_num
1319
char number_as_string[22];
1320
snprintf(number_as_string, sizeof(number_as_string), "%"PRIu64, $3);
1322
drizzled::message::Engine::Option *opt= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_engine()->add_options();
1323
opt->set_name($1.str);
1324
opt->set_state(number_as_string);
1259
| ROW_FORMAT_SYM opt_equal row_types
1261
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1262
message::Table::TableOptions *table_options= statement->createTableMessage().mutable_options();
1264
statement->create_info.row_type= $3;
1265
statement->create_info.used_fields|= HA_CREATE_USED_ROW_FORMAT;
1266
statement->alter_info.flags.set(ALTER_ROW_FORMAT);
1268
switch(statement->create_info.row_type)
1270
case ROW_TYPE_DEFAULT:
1271
/* No use setting a default row type... just adds redundant info to message */
1273
case ROW_TYPE_FIXED:
1274
table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_FIXED);
1276
case ROW_TYPE_DYNAMIC:
1277
table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_DYNAMIC);
1279
case ROW_TYPE_COMPRESSED:
1280
table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_COMPRESSED);
1282
case ROW_TYPE_REDUNDANT:
1283
table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_REDUNDANT);
1285
case ROW_TYPE_COMPACT:
1286
table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_COMPACT);
1289
table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_PAGE);
1326
1295
| default_collation
1296
| KEY_BLOCK_SIZE opt_equal ulong_num
1298
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1300
statement->create_info.used_fields|= HA_CREATE_USED_KEY_BLOCK_SIZE;
1302
message::Table::TableOptions *tableopts;
1303
tableopts= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_options();
1304
tableopts->set_key_block_size($3);
1329
1308
default_collation:
1360
1339
| FIXED_SYM { $$= COLUMN_FORMAT_TYPE_FIXED; }
1361
1340
| DYNAMIC_SYM { $$= COLUMN_FORMAT_TYPE_DYNAMIC; };
1343
DEFAULT { $$= ROW_TYPE_DEFAULT; }
1344
| FIXED_SYM { $$= ROW_TYPE_FIXED; }
1345
| DYNAMIC_SYM { $$= ROW_TYPE_DYNAMIC; }
1346
| COMPRESSED_SYM { $$= ROW_TYPE_COMPRESSED; }
1347
| REDUNDANT_SYM { $$= ROW_TYPE_REDUNDANT; }
1348
| COMPACT_SYM { $$= ROW_TYPE_COMPACT; }
1349
| PAGE_SYM { $$= ROW_TYPE_PAGE; }
1364
1352
opt_select_from:
1365
1353
opt_limit_clause {}
1410
1398
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1411
Key *key= new Foreign_key($1.str ? $1 : $4, lex->col_list,
1399
Key *key= new Foreign_key($4.str ? $4 : $1, lex->col_list,
1414
1402
statement->fk_delete_opt,
1415
1403
statement->fk_update_opt,
1416
1404
statement->fk_match_option);
1418
1405
statement->alter_info.key_list.push_back(key);
1419
1406
key= new Key(Key::MULTIPLE, $1.str ? $1 : $4,
1420
1407
&default_key_create_info, 1,
1693
1680
if (statement->current_proto_field)
1694
1681
statement->current_proto_field->set_type(message::Table::Field::ENUM);
1698
$$=DRIZZLE_TYPE_UUID;
1700
statement::CreateTable *statement=
1701
(statement::CreateTable *)Lex->statement;
1703
if (statement->current_proto_field)
1704
statement->current_proto_field->set_type(message::Table::Field::UUID);
1708
1685
$$=DRIZZLE_TYPE_LONGLONG;
1970
1947
opt_match_clause:
1972
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_UNDEFINED; }
1949
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= Foreign_key::FK_MATCH_UNDEF; }
1974
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_FULL; }
1951
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= Foreign_key::FK_MATCH_FULL; }
1975
1952
| MATCH PARTIAL
1976
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_PARTIAL; }
1953
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= Foreign_key::FK_MATCH_PARTIAL; }
1977
1954
| MATCH SIMPLE_SYM
1978
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_SIMPLE; }
1955
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= Foreign_key::FK_MATCH_SIMPLE; }
1981
1958
opt_on_update_delete:
1984
((statement::CreateTable *)Lex->statement)->fk_update_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
1985
((statement::CreateTable *)Lex->statement)->fk_delete_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
1961
((statement::CreateTable *)Lex->statement)->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
1962
((statement::CreateTable *)Lex->statement)->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
1987
1964
| ON UPDATE_SYM delete_option
1989
1966
((statement::CreateTable *)Lex->statement)->fk_update_opt= $3;
1990
((statement::CreateTable *)Lex->statement)->fk_delete_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
1967
((statement::CreateTable *)Lex->statement)->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
1992
1969
| ON DELETE_SYM delete_option
1994
((statement::CreateTable *)Lex->statement)->fk_update_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
1971
((statement::CreateTable *)Lex->statement)->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
1995
1972
((statement::CreateTable *)Lex->statement)->fk_delete_opt= $3;
1997
1974
| ON UPDATE_SYM delete_option
2012
RESTRICT { $$= drizzled::message::Table::ForeignKeyConstraint::OPTION_RESTRICT; }
2013
| CASCADE { $$= drizzled::message::Table::ForeignKeyConstraint::OPTION_CASCADE; }
2014
| SET NULL_SYM { $$= drizzled::message::Table::ForeignKeyConstraint::OPTION_SET_NULL; }
2015
| NO_SYM ACTION { $$= drizzled::message::Table::ForeignKeyConstraint::OPTION_NO_ACTION; }
2016
| SET DEFAULT { $$= drizzled::message::Table::ForeignKeyConstraint::OPTION_SET_DEFAULT; }
1989
RESTRICT { $$= Foreign_key::FK_OPTION_RESTRICT; }
1990
| CASCADE { $$= Foreign_key::FK_OPTION_CASCADE; }
1991
| SET NULL_SYM { $$= Foreign_key::FK_OPTION_SET_NULL; }
1992
| NO_SYM ACTION { $$= Foreign_key::FK_OPTION_NO_ACTION; }
1993
| SET DEFAULT { $$= Foreign_key::FK_OPTION_DEFAULT; }
2145
2122
DRIZZLE_YYABORT;
2146
2123
lex->col_list.empty();
2147
2124
lex->select_lex.init_order();
2148
lex->select_lex.db= const_cast<char *>(((TableList*) lex->select_lex.table_list.first)->getSchemaName());
2126
((TableList*) lex->select_lex.table_list.first)->db;
2127
statement->create_info.row_type= ROW_TYPE_NOT_USED;
2149
2128
statement->alter_info.build_method= $2;
2279
2258
| DROP FOREIGN KEY_SYM opt_ident
2281
2260
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2282
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::FOREIGN_KEY,
2284
2262
statement->alter_info.flags.set(ALTER_DROP_INDEX);
2285
2263
statement->alter_info.flags.set(ALTER_FOREIGN_KEY);
2526
2504
select_paren_derived:
2527
2505
SELECT_SYM select_part2_derived
2529
if (setup_select_in_parentheses(YYSession, Lex))
2507
if (setup_select_in_parentheses(Lex))
2530
2508
DRIZZLE_YYABORT;
2532
2510
| '(' select_paren_derived ')'
2539
2517
Select_Lex * sel= lex->current_select;
2540
2518
if (lex->current_select->set_braces(0))
2542
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
2543
my_parse_error(&pass);
2520
my_parse_error(ER(ER_SYNTAX_ERROR));
2544
2521
DRIZZLE_YYABORT;
2546
2523
if (sel->linkage == UNION_TYPE &&
2547
2524
sel->master_unit()->first_select()->braces)
2549
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
2550
my_parse_error(&pass);
2526
my_parse_error(ER(ER_SYNTAX_ERROR));
2551
2527
DRIZZLE_YYABORT;
2874
2850
| bit_expr BETWEEN_SYM bit_expr AND_SYM predicate
2876
$$= new Item_func_between($1,$3,$5);
2851
{ $$= new Item_func_between($1,$3,$5); }
2878
2852
| bit_expr not BETWEEN_SYM bit_expr AND_SYM predicate
2880
2854
Item_func_between *item= new Item_func_between($1,$4,$6);
2884
2858
| bit_expr LIKE simple_expr opt_escape
2886
$$= new Item_func_like($1,$3,$4,Lex->escape_used);
2859
{ $$= new Item_func_like($1,$3,$4,Lex->escape_used); }
2888
2860
| bit_expr not LIKE simple_expr opt_escape
2890
$$= new Item_func_not(new Item_func_like($1,$4,$5, Lex->escape_used));
2892
| bit_expr REGEXP_SYM bit_expr
2894
List<Item> *args= new (YYSession->mem_root) List<Item>;
2895
args->push_back($1);
2896
args->push_back($3);
2897
if (! ($$= reserved_keyword_function(YYSession, "regex", args)))
2902
| bit_expr not REGEXP_SYM bit_expr
2904
List<Item> *args= new (YYSession->mem_root) List<Item>;
2905
args->push_back($1);
2906
args->push_back($4);
2907
args->push_back(new (YYSession->mem_root) Item_int(1));
2908
if (! ($$= reserved_keyword_function(YYSession, "regex", args)))
2861
{ $$= new Item_func_not(new Item_func_like($1,$4,$5, Lex->escape_used)); }
2925
2874
| bit_expr '*' bit_expr %prec '*'
2926
2875
{ $$= new Item_func_mul($1,$3); }
2927
2876
| bit_expr '/' bit_expr %prec '/'
2928
{ $$= new Item_func_div(YYSession,$1,$3); }
2877
{ $$= new Item_func_div($1,$3); }
2929
2878
| bit_expr '%' bit_expr %prec '%'
2930
2879
{ $$= new Item_func_mod($1,$3); }
2931
2880
| bit_expr DIV_SYM bit_expr %prec DIV_SYM
3053
2999
| CURRENT_USER optional_braces
3055
3001
std::string user_str("user");
3056
if (! ($$= reserved_keyword_function(YYSession, user_str, NULL)))
3002
if (! ($$= reserved_keyword_function(user_str, NULL)))
3058
3004
DRIZZLE_YYABORT;
3060
Lex->setCacheable(false);
3062
3007
| DATE_SYM '(' expr ')'
3063
3008
{ $$= new (YYSession->mem_root) Item_date_typecast($3); }
3066
3011
| HOUR_SYM '(' expr ')'
3067
3012
{ $$= new (YYSession->mem_root) Item_func_hour($3); }
3068
3013
| INSERT '(' expr ',' expr ',' expr ',' expr ')'
3069
{ $$= new (YYSession->mem_root) Item_func_insert(*YYSession, $3, $5, $7, $9); }
3014
{ $$= new (YYSession->mem_root) Item_func_insert($3,$5,$7,$9); }
3070
3015
| INTERVAL_SYM '(' expr ',' expr ')' %prec INTERVAL_SYM
3072
3017
Session *session= YYSession;
3117
3062
std::string user_str("user");
3118
if (! ($$= reserved_keyword_function(YYSession, user_str, NULL)))
3063
if (! ($$= reserved_keyword_function(user_str, NULL)))
3120
3065
DRIZZLE_YYABORT;
3122
Lex->setCacheable(false);
3124
3068
| YEAR_SYM '(' expr ')'
3125
3069
{ $$= new (YYSession->mem_root) Item_func_year($3); }
3147
3091
| CURDATE optional_braces
3149
3093
$$= new (YYSession->mem_root) Item_func_curdate_local();
3150
Lex->setCacheable(false);
3152
3095
| DATE_ADD_INTERVAL '(' expr ',' INTERVAL_SYM expr interval ')' %prec INTERVAL_SYM
3153
3096
{ $$= new (YYSession->mem_root) Item_date_add_interval($3,$6,$7,0); }
3158
3101
| NOW_SYM optional_braces
3160
3103
$$= new (YYSession->mem_root) Item_func_now_local();
3161
Lex->setCacheable(false);
3163
3105
| NOW_SYM '(' expr ')'
3165
3107
$$= new (YYSession->mem_root) Item_func_now_local($3);
3166
Lex->setCacheable(false);
3168
3109
| POSITION_SYM '(' bit_expr IN_SYM expr ')'
3169
3110
{ $$ = new (YYSession->mem_root) Item_func_locate($5,$3); }
3192
3133
List<Item> *args= new (YYSession->mem_root) List<Item>;
3193
3134
args->push_back($3);
3194
3135
args->push_back($5);
3195
if (! ($$= reserved_keyword_function(YYSession, reverse_str, args)))
3136
if (! ($$= reserved_keyword_function(reverse_str, args)))
3197
3138
DRIZZLE_YYABORT;
3215
3156
List<Item> *args= new (YYSession->mem_root) List<Item>;
3216
3157
args->push_back($3);
3217
3158
args->push_back($5);
3218
if (! ($$= reserved_keyword_function(YYSession, reverse_str, args)))
3159
if (! ($$= reserved_keyword_function(reverse_str, args)))
3220
3161
DRIZZLE_YYABORT;
3223
3164
| SYSDATE optional_braces
3225
$$= new (YYSession->mem_root) Item_func_sysdate_local();
3226
Lex->setCacheable(false);
3165
{ $$= new (YYSession->mem_root) Item_func_sysdate_local(); }
3228
3166
| SYSDATE '(' expr ')'
3230
$$= new (YYSession->mem_root) Item_func_sysdate_local($3);
3231
Lex->setCacheable(false);
3167
{ $$= new (YYSession->mem_root) Item_func_sysdate_local($3); }
3233
3168
| TIMESTAMP_ADD '(' interval_time_stamp ',' expr ',' expr ')'
3234
3169
{ $$= new (YYSession->mem_root) Item_date_add_interval($7,$5,$3,0); }
3235
3170
| TIMESTAMP_DIFF '(' interval_time_stamp ',' expr ',' expr ')'
3237
3172
| UTC_DATE_SYM optional_braces
3239
3174
$$= new (YYSession->mem_root) Item_func_curdate_utc();
3240
Lex->setCacheable(false);
3242
3176
| UTC_TIMESTAMP_SYM optional_braces
3244
3178
$$= new (YYSession->mem_root) Item_func_now_utc();
3245
Lex->setCacheable(false);
3259
3192
| DATABASE '(' ')'
3261
3194
std::string database_str("database");
3262
if (! ($$= reserved_keyword_function(YYSession, database_str, NULL)))
3195
if (! ($$= reserved_keyword_function(database_str, NULL)))
3264
3197
DRIZZLE_YYABORT;
3266
Lex->setCacheable(false);
3268
| EXECUTE_SYM '(' expr ')' opt_wait
3270
List<Item> *args= new (YYSession->mem_root) List<Item>;
3271
args->push_back($3);
3275
args->push_back(new (YYSession->mem_root) Item_int(1));
3278
if (! ($$= reserved_keyword_function(YYSession, "execute", args)))
3283
3200
| IF '(' expr ',' expr ',' expr ')'
3284
3201
{ $$= new (YYSession->mem_root) Item_func_if($3,$5,$7); }
3285
| KILL_SYM kill_option '(' expr ')'
3287
std::string kill_str("kill");
3288
List<Item> *args= new (YYSession->mem_root) List<Item>;
3289
args->push_back($4);
3293
args->push_back(new (YYSession->mem_root) Item_uint(1));
3296
if (! ($$= reserved_keyword_function(YYSession, kill_str, args)))
3301
3202
| MICROSECOND_SYM '(' expr ')'
3302
3203
{ $$= new (YYSession->mem_root) Item_func_microsecond($3); }
3303
3204
| MOD_SYM '(' expr ',' expr ')'
3305
3206
| QUARTER_SYM '(' expr ')'
3306
3207
{ $$ = new (YYSession->mem_root) Item_func_quarter($3); }
3307
3208
| REPEAT_SYM '(' expr ',' expr ')'
3308
{ $$= new (YYSession->mem_root) Item_func_repeat(*YYSession, $3, $5); }
3209
{ $$= new (YYSession->mem_root) Item_func_repeat($3,$5); }
3309
3210
| REPLACE '(' expr ',' expr ',' expr ')'
3310
{ $$= new (YYSession->mem_root) Item_func_replace(*YYSession, $3, $5, $7); }
3211
{ $$= new (YYSession->mem_root) Item_func_replace($3,$5,$7); }
3311
3212
| REVERSE_SYM '(' expr ')'
3313
3214
std::string reverse_str("reverse");
3314
3215
List<Item> *args= new (YYSession->mem_root) List<Item>;
3315
3216
args->push_back($3);
3316
if (! ($$= reserved_keyword_function(YYSession, reverse_str, args)))
3217
if (! ($$= reserved_keyword_function(reverse_str, args)))
3318
3219
DRIZZLE_YYABORT;
3321
3222
| TRUNCATE_SYM '(' expr ',' expr ')'
3322
3223
{ $$= new (YYSession->mem_root) Item_func_round($3,$5,1); }
3323
| WAIT_SYM '(' expr ')'
3325
std::string wait_str("wait");
3326
List<Item> *args= new (YYSession->mem_root) List<Item>;
3327
args->push_back($3);
3328
if (! ($$= reserved_keyword_function(YYSession, wait_str, args)))
3335
if (! ($$= reserved_keyword_function(YYSession, "uuid", NULL)))
3339
Lex->setCacheable(false);
3341
| WAIT_SYM '(' expr ',' expr ')'
3343
std::string wait_str("wait");
3344
List<Item> *args= new (YYSession->mem_root) List<Item>;
3345
args->push_back($3);
3346
args->push_back($5);
3347
if (! ($$= reserved_keyword_function(YYSession, wait_str, args)))
3513
3384
ident_or_text SET_VAR expr
3515
3386
$$= new Item_func_set_user_var($1, $3);
3516
Lex->setCacheable(false);
3518
3388
| ident_or_text
3520
$$= new Item_func_get_user_var(*YYSession, $1);
3521
Lex->setCacheable(false);
3390
$$= new Item_func_get_user_var($1);
3523
3392
| '@' opt_var_ident_type ident_or_text opt_component
3525
3394
/* disallow "SELECT @@global.global.variable" */
3526
3395
if ($3.str && $4.str && check_reserved_words(&$3))
3528
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
3529
my_parse_error(&pass);
3397
my_parse_error(ER(ER_SYNTAX_ERROR));
3530
3398
DRIZZLE_YYABORT;
3532
3400
if (!($$= get_system_var(YYSession, $2, $3, $4)))
3684
3551
left-associative joins.
3686
3553
table_ref normal_join table_ref %prec TABLE_REF_PRIORITY
3688
DRIZZLE_YYABORT_UNLESS($1 && ($$=$3));
3689
Lex->is_cross= false;
3554
{ DRIZZLE_YYABORT_UNLESS($1 && ($$=$3)); }
3691
3555
| table_ref STRAIGHT_JOIN table_factor
3693
DRIZZLE_YYABORT_UNLESS($1 && ($$=$3)); $3->straight=1;
3556
{ DRIZZLE_YYABORT_UNLESS($1 && ($$=$3)); $3->straight=1; }
3695
3557
| table_ref normal_join table_ref
3698
3560
DRIZZLE_YYABORT_UNLESS($1 && $3);
3699
DRIZZLE_YYABORT_UNLESS( not Lex->is_cross );
3700
3561
/* Change the current name resolution context to a local context. */
3701
3562
if (push_new_name_resolution_context(YYSession, $1, $3))
3702
3563
DRIZZLE_YYABORT;
3829
3690
/* Warning - may return NULL in case of incomplete SELECT */
3693
Select_Lex *sel= Lex->current_select;
3694
sel->table_join_options= 0;
3833
3696
table_ident opt_table_alias opt_key_definition
3835
3698
if (!($$= Lex->current_select->add_table_to_list(YYSession, $2, $3,
3699
Lex->current_select->get_table_join_options(),
3837
3700
Lex->lock_option,
3838
3701
Lex->current_select->pop_index_hints())))
3839
3702
DRIZZLE_YYABORT;
3885
3747
/* Use $2 instead of Lex->current_select as derived table will
3886
3748
alter value of Lex->current_select. */
3887
3749
if (!($3 || $5) && $2->embedding &&
3888
!$2->embedding->getNestedJoin()->join_list.elements)
3750
!$2->embedding->nested_join->join_list.elements)
3890
3752
/* we have a derived table ($3 == NULL) but no alias,
3891
3753
Since we are nested in further parentheses so we
3913
3775
else if (($3->select_lex && $3->select_lex->master_unit()->is_union()) || $5)
3915
3777
/* simple nested joins cannot have aliases or unions */
3916
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
3917
my_parse_error(&pass);
3778
my_parse_error(ER(ER_SYNTAX_ERROR));
3918
3779
DRIZZLE_YYABORT;
3950
3811
Select_Lex * sel= lex->current_select;
3951
3812
if (lex->current_select->set_braces(0))
3953
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
3954
my_parse_error(&pass);
3814
my_parse_error(ER(ER_SYNTAX_ERROR));
3955
3815
DRIZZLE_YYABORT;
3957
3817
if (sel->linkage == UNION_TYPE &&
3958
3818
sel->master_unit()->first_select()->braces)
3960
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
3961
my_parse_error(&pass);
3820
my_parse_error(ER(ER_SYNTAX_ERROR));
3962
3821
DRIZZLE_YYABORT;
4011
3869
lex->derived_tables|= DERIVED_SUBQUERY;
4012
3870
if (!lex->expr_allows_subselect)
4014
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
4015
my_parse_error(&pass);
3872
my_parse_error(ER(ER_SYNTAX_ERROR));
4016
3873
DRIZZLE_YYABORT;
4018
3875
if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE ||
4043
3900
if (!sel->embedding || sel->end_nested_join(lex->session))
4045
3902
/* we are not in parentheses */
4046
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
4047
my_parse_error(&pass);
3903
my_parse_error(ER(ER_SYNTAX_ERROR));
4048
3904
DRIZZLE_YYABORT;
4050
3906
embedding= Lex->current_select->embedding;
4051
3907
$$= embedding &&
4052
!embedding->getNestedJoin()->join_list.elements;
3908
!embedding->nested_join->join_list.elements;
4053
3909
/* return true if we are deeply nested */
4484
4340
OUTFILE TEXT_STRING_filesystem
4487
lex->setCacheable(false);
4488
4343
if (!(lex->exchange= new file_exchange($2.str, 0)) ||
4489
4344
!(lex->result= new select_export(lex->exchange)))
4490
4345
DRIZZLE_YYABORT;
4570
4424
/* empty */ { $$= 0; }
4571
4425
| TEMPORARY_SYM { $$= 1; }
4575
Execute a string as dynamic SQL.
4579
EXECUTE_SYM execute_var_or_string opt_status opt_concurrent opt_wait
4582
statement::Execute *statement= new(std::nothrow) statement::Execute(YYSession, $2, $3, $4, $5);
4583
lex->statement= statement;
4584
if (lex->statement == NULL)
4589
execute_var_or_string:
4600
/* empty */ { $$= 0; }
4601
| WITH NO_SYM RETURN_SYM { $$= 1; }
4605
/* empty */ { $$= 0; }
4606
| CONCURRENT { $$= 1; }
4610
/* empty */ { $$= 0; }
4611
| WAIT_SYM { $$= 1; }
4615
4428
** Insert : add new data to table
4983
4790
select->setShowPredicate($2, "");
4985
else if (schema and not schema->empty())
4792
else if (not session->db.empty())
4987
column_name.append(*schema);
4988
select->setShowPredicate(*schema, "");
4794
column_name.append(session->db);
4795
select->setShowPredicate(session->db, "");
4992
my_error(ER_NO_DB_ERROR, MYF(0));
4799
my_error(ER_NO_DB_ERROR, MYF(0));
5011
4817
if (session->add_item_to_list(my_field))
5012
4818
DRIZZLE_YYABORT;
5014
if (session->add_order_to_list(my_field, true))
5017
/* SHOW TEMPORARY TABLES */
5018
4820
| TEMPORARY_SYM TABLES show_wild
5041
4843
(session->lex->current_select->with_wild)++;
5044
/* SHOW TABLE STATUS */
5045
4846
| TABLE_SYM STATUS_SYM opt_db show_wild
5048
4849
lex->sql_command= SQLCOM_SELECT;
5049
statement::Show *select=
5050
new(std::nothrow) statement::Show(YYSession);
4850
statement::Select *select=
4851
new(std::nothrow) statement::Select(YYSession);
5052
4853
lex->statement= select;
5072
4872
select->setShowPredicate($3, "");
5076
select->setShowPredicate(*schema, "");
5080
my_error(ER_NO_DB_ERROR, MYF(0));
4876
select->setShowPredicate(session->db, "");
5084
4879
if (prepare_new_schema_table(session, lex, "SHOW_TABLE_STATUS"))
5090
4885
DRIZZLE_YYABORT;
5091
4886
(session->lex->current_select->with_wild)++;
5093
/* SHOW COLUMNS FROM table_name */
5094
4888
| COLUMNS from_or_in table_ident opt_db show_wild
5097
4891
Session *session= YYSession;
5098
statement::Show *select;
4892
statement::Select *select;
5100
4894
lex->sql_command= SQLCOM_SELECT;
5102
select= new(std::nothrow) statement::Show(session);
4896
select= new(std::nothrow) statement::Select(session);
5104
4898
lex->statement= select;
5106
4900
if (lex->statement == NULL)
5107
4901
DRIZZLE_YYABORT;
5109
util::string::const_shared_ptr schema(session->schema());
5112
4904
select->setShowPredicate($4, $3->table.str);
5114
4905
else if ($3->db.str)
5116
4906
select->setShowPredicate($3->db.str, $3->table.str);
5120
select->setShowPredicate(*schema, $3->table.str);
5124
my_error(ER_NO_DB_ERROR, MYF(0));
4908
select->setShowPredicate(session->db, $3->table.str);
5129
4911
drizzled::TableIdentifier identifier(select->getShowSchema().c_str(), $3->table.str);
5145
4927
(session->lex->current_select->with_wild)++;
5148
/* SHOW INDEXES from table */
5149
4930
| keys_or_index from_or_in table_ident opt_db where_clause
5152
4933
Session *session= YYSession;
5153
statement::Show *select;
4934
statement::Select *select;
5155
4936
lex->sql_command= SQLCOM_SELECT;
5157
select= new(std::nothrow) statement::Show(session);
4938
select= new(std::nothrow) statement::Select(session);
5159
4940
lex->statement= select;
5161
4942
if (lex->statement == NULL)
5162
4943
DRIZZLE_YYABORT;
5164
util::string::const_shared_ptr schema(session->schema());
5167
4946
select->setShowPredicate($4, $3->table.str);
5169
4947
else if ($3->db.str)
5171
4948
select->setShowPredicate($3->db.str, $3->table.str);
5175
select->setShowPredicate(*schema, $3->table.str);
5179
my_error(ER_NO_DB_ERROR, MYF(0));
4950
select->setShowPredicate(session->db, $3->table.str);
5184
4953
drizzled::TableIdentifier identifier(select->getShowSchema().c_str(), $3->table.str);
5204
4973
(void) create_select_for_variable("warning_count");
5206
lex->statement= new(std::nothrow) statement::Show(YYSession);
4975
lex->statement= new(std::nothrow) statement::Select(YYSession);
5207
4976
if (lex->statement == NULL)
5208
4977
DRIZZLE_YYABORT;
5268
5037
if (session->add_item_to_list(my_field))
5269
5038
DRIZZLE_YYABORT;
5271
| CREATE TABLE_SYM table_ident
5274
lex->sql_command= SQLCOM_SELECT;
5275
statement::Show *select=
5276
new(std::nothrow) statement::Show(YYSession);
5278
lex->statement= select;
5280
if (lex->statement == NULL)
5283
Session *session= YYSession;
5285
if (prepare_new_schema_table(session, lex, "TABLE_SQL_DEFINITION"))
5288
util::string::const_shared_ptr schema(session->schema());
5291
select->setShowPredicate($3->db.str, $3->table.str);
5295
select->setShowPredicate(*schema, $3->table.str);
5299
my_error(ER_NO_DB_ERROR, MYF(0));
5303
std::string key("Table");
5304
std::string value("Create Table");
5306
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "TABLE_NAME");
5307
my_field->is_autogenerated_name= false;
5308
my_field->set_name(key.c_str(), key.length(), system_charset_info);
5310
if (session->add_item_to_list(my_field))
5313
my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "TABLE_SQL_DEFINITION");
5314
my_field->is_autogenerated_name= false;
5315
my_field->set_name(value.c_str(), value.length(), system_charset_info);
5317
if (session->add_item_to_list(my_field))
5320
5040
| PROCESSLIST_SYM
5324
5044
lex->sql_command= SQLCOM_SELECT;
5325
5045
lex->statement=
5326
new(std::nothrow) statement::Show(YYSession);
5046
new(std::nothrow) statement::Select(YYSession);
5327
5047
if (lex->statement == NULL)
5328
5048
DRIZZLE_YYABORT;
5379
5099
DRIZZLE_YYABORT;
5381
5101
| CREATE DATABASE opt_if_not_exists ident
5384
lex->sql_command= SQLCOM_SELECT;
5385
statement::Show *select=
5386
new(std::nothrow) statement::Show(YYSession);
5388
lex->statement= select;
5390
if (lex->statement == NULL)
5393
Session *session= YYSession;
5395
if (prepare_new_schema_table(session, lex, "SCHEMA_SQL_DEFINITION"))
5398
util::string::const_shared_ptr schema(session->schema());
5401
select->setShowPredicate($4.str);
5405
select->setShowPredicate(*schema);
5409
my_error(ER_NO_DB_ERROR, MYF(0));
5413
std::string key("Database");
5414
std::string value("Create Database");
5416
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "SCHEMA_NAME");
5417
my_field->is_autogenerated_name= false;
5418
my_field->set_name(key.c_str(), key.length(), system_charset_info);
5420
if (session->add_item_to_list(my_field))
5423
my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "SCHEMA_SQL_DEFINITION");
5424
my_field->is_autogenerated_name= false;
5425
my_field->set_name(value.c_str(), value.length(), system_charset_info);
5427
if (session->add_item_to_list(my_field))
5103
Lex->sql_command=SQLCOM_SHOW_CREATE_DB;
5104
statement::ShowCreateSchema *statement= new(std::nothrow) statement::ShowCreateSchema(YYSession);
5105
Lex->statement= statement;
5106
if (Lex->statement == NULL)
5108
statement->is_if_not_exists= $3;
5111
| CREATE TABLE_SYM table_ident
5114
lex->sql_command = SQLCOM_SHOW_CREATE;
5115
lex->statement= new(std::nothrow) statement::ShowCreate(YYSession);
5116
if (lex->statement == NULL)
5118
if (!lex->select_lex.add_table_to_list(YYSession, $3, NULL,0))
5432
5123
/* empty */ { $$= 0; }
5460
5151
describe_command table_ident
5462
5153
Session *session= YYSession;
5463
statement::Show *select;
5154
statement::Select *select;
5465
5156
lex->lock_option= TL_READ;
5466
5157
mysql_init_select(lex);
5467
5158
lex->current_select->parsing_place= SELECT_LIST;
5468
5159
lex->sql_command= SQLCOM_SELECT;
5469
select= new(std::nothrow) statement::Show(session);
5160
select= new(std::nothrow) statement::Select(session);
5470
5161
lex->statement= select;
5471
5162
if (lex->statement == NULL)
5472
5163
DRIZZLE_YYABORT;
5473
5164
lex->select_lex.db= 0;
5475
util::string::const_shared_ptr schema(session->schema());
5476
5166
if ($2->db.str)
5478
select->setShowPredicate($2->db.str, $2->table.str);
5482
select->setShowPredicate(*schema, $2->table.str);
5167
select->setShowPredicate($2->db.str, $2->table.str);
5486
my_error(ER_NO_DB_ERROR, MYF(0));
5169
select->setShowPredicate(session->db, $2->table.str);
5491
5172
drizzled::TableIdentifier identifier(select->getShowSchema().c_str(), $2->table.str);
6024
5688
TableList *table=
6025
5689
reinterpret_cast<TableList*>(Lex->current_select->table_list.first);
6026
if (my_strcasecmp(table_alias_charset, $1.str, table->getSchemaName()))
5690
if (my_strcasecmp(table_alias_charset, $1.str, table->db))
6028
5692
my_error(ER_WRONG_DB_NAME, MYF(0), $1.str);
6029
5693
DRIZZLE_YYABORT;
6031
5695
if (my_strcasecmp(table_alias_charset, $3.str,
6032
table->getTableName()))
6034
5698
my_error(ER_WRONG_TABLE_NAME, MYF(0), $3.str);
6035
5699
DRIZZLE_YYABORT;
6373
6040
lex->option_type= $1;
6374
6041
lex->var_list.push_back(new set_var(lex->option_type,
6375
find_sys_var("tx_isolation"),
6042
find_sys_var(YYSession, "tx_isolation"),
6377
6044
new Item_int((int32_t) $5)));
6393
6060
internal_variable_name:
6063
Session *session= YYSession;
6396
6065
/* We have to lookup here since local vars can shadow sysvars */
6398
6067
/* Not an SP local variable */
6399
sys_var *tmp=find_sys_var($1.str, $1.length);
6068
sys_var *tmp=find_sys_var(session, $1.str, $1.length);
6401
6070
DRIZZLE_YYABORT;