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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
104
static void my_parse_error(const char *s)
106
struct my_parse_error_st {
111
static void my_parse_error(void *arg)
106
Session *session= current_session;
113
struct my_parse_error_st *ptr= (struct my_parse_error_st *)arg;
115
const char *s= ptr->s;
116
Session *session= ptr->session;
107
118
Lex_input_stream *lip= session->m_lip;
109
120
const char *yytext= lip->get_tok_start();
147
158
/* "parse error" changed into "syntax error" between bison 1.75 and 1.875 */
148
159
if (strcmp(s,"parse error") == 0 || strcmp(s,"syntax error") == 0)
149
160
s= ER(ER_SYNTAX_ERROR);
162
struct my_parse_error_st pass= { s, session };
163
my_parse_error(&pass);
239
252
@return <code>false</code> if successful, <code>true</code> if an error was
240
253
reported. In the latter case parsing should stop.
242
static bool add_select_to_union_list(LEX *lex, bool is_union_distinct)
255
static bool add_select_to_union_list(Session *session, LEX *lex, bool is_union_distinct)
250
263
if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE)
252
my_parse_error(ER(ER_SYNTAX_ERROR));
265
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), session };
266
my_parse_error(&pass);
255
269
/* This counter shouldn't be incremented for UNION parts */
271
285
@return false if successful, true if an error was reported. In the latter
272
286
case parsing should stop.
274
static bool setup_select_in_parentheses(LEX *lex)
288
static bool setup_select_in_parentheses(Session *session, LEX *lex)
276
290
Select_Lex * sel= lex->current_select;
277
291
if (sel->set_braces(1))
279
my_parse_error(ER(ER_SYNTAX_ERROR));
293
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), session };
294
my_parse_error(&pass);
282
297
if (sel->linkage == UNION_TYPE &&
284
299
sel->master_unit()->first_select()->linkage ==
287
my_parse_error(ER(ER_SYNTAX_ERROR));
302
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), session };
303
my_parse_error(&pass);
290
306
if (sel->linkage == UNION_TYPE &&
304
static Item* reserved_keyword_function(const std::string &name, List<Item> *item_list)
320
static Item* reserved_keyword_function(Session *session, const std::string &name, List<Item> *item_list)
306
322
const plugin::Function *udf= plugin::Function::get(name.c_str(), name.length());
307
323
Item *item= NULL;
311
item= Create_udf_func::s_singleton.create(current_session, udf, item_list);
327
item= Create_udf_func::s_singleton.create(session, udf, item_list);
313
329
my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", name.c_str());
342
358
enum drizzled::sql_var_t var_type;
343
359
drizzled::Key::Keytype key_type;
344
360
enum drizzled::ha_key_alg key_alg;
345
enum drizzled::row_type row_type;
346
361
enum drizzled::column_format_type column_format_type;
347
362
enum drizzled::ha_rkey_function ha_rkey_mode;
348
363
enum drizzled::enum_tx_isolation tx_isolation;
357
372
enum drizzled::index_hint_type index_hint;
358
373
enum drizzled::enum_filetype filetype;
359
374
enum drizzled::ha_build_method build_method;
360
enum drizzled::Foreign_key::fk_option m_fk_option;
375
drizzled::message::Table::ForeignKeyConstraint::ForeignKeyOption m_fk_option;
902
914
insert_values update delete truncate rename
903
915
show describe load alter flush
904
916
begin commit rollback savepoint release
905
analyze check start checksum
906
918
field_list field_list_item field_spec kill column_def key_def
907
919
select_item_list select_item values_list no_braces
908
920
opt_limit_clause delete_limit_clause fields opt_values values
1191
1204
opt_create_database_options:
1193
1206
| default_collation_schema {}
1207
| opt_database_custom_options {}
1210
opt_database_custom_options:
1211
custom_database_option
1212
| custom_database_option ',' opt_database_custom_options
1215
custom_database_option:
1218
statement::CreateSchema *statement= (statement::CreateSchema *)Lex->statement;
1219
drizzled::message::Engine::Option *opt= statement->schema_message.mutable_engine()->add_options();
1221
opt->set_name($1.str);
1223
| ident_or_text equal ident_or_text
1225
statement::CreateSchema *statement= (statement::CreateSchema *)Lex->statement;
1226
drizzled::message::Engine::Option *opt= statement->schema_message.mutable_engine()->add_options();
1228
opt->set_name($1.str);
1229
opt->set_state($3.str);
1231
| ident_or_text equal ulonglong_num
1233
statement::CreateSchema *statement= (statement::CreateSchema *)Lex->statement;
1234
char number_as_string[22];
1236
snprintf(number_as_string, sizeof(number_as_string), "%"PRIu64, $3);
1238
drizzled::message::Engine::Option *opt= statement->schema_message.mutable_engine()->add_options();
1240
opt->set_name($1.str);
1241
opt->set_state(number_as_string);
1196
1245
opt_table_options:
1217
1266
create_table_option
1218
1267
| create_table_option create_table_options
1219
1268
| create_table_option ',' create_table_options
1222
1270
create_table_option:
1223
ENGINE_SYM opt_equal ident_or_text
1271
custom_engine_option;
1273
custom_engine_option:
1274
ENGINE_SYM equal ident_or_text
1225
1276
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1226
message::Table::StorageEngine *protoengine;
1227
protoengine= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_engine();
1229
1278
statement->is_engine_set= true;
1231
protoengine->set_name($3.str);
1233
| BLOCK_SIZE_SYM opt_equal ulong_num
1235
message::Table::TableOptions *tableopts;
1236
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1237
tableopts= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_options();
1239
tableopts->set_block_size($3);
1240
statement->create_info.used_fields|= HA_CREATE_USED_BLOCK_SIZE;
1280
((statement::CreateTable *)Lex->statement)->create_table_message.mutable_engine()->set_name($3.str);
1242
1282
| COMMENT_SYM opt_equal TEXT_STRING_sys
1257
1297
statement->create_info.used_fields|= HA_CREATE_USED_AUTO;
1258
1298
tableopts->set_auto_increment_value($3);
1260
| ROW_FORMAT_SYM opt_equal row_types
1262
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1263
message::Table::TableOptions *table_options= statement->createTableMessage().mutable_options();
1265
statement->create_info.row_type= $3;
1266
statement->create_info.used_fields|= HA_CREATE_USED_ROW_FORMAT;
1267
statement->alter_info.flags.set(ALTER_ROW_FORMAT);
1269
switch(statement->create_info.row_type)
1271
case ROW_TYPE_DEFAULT:
1272
/* No use setting a default row type... just adds redundant info to message */
1274
case ROW_TYPE_FIXED:
1275
table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_FIXED);
1277
case ROW_TYPE_DYNAMIC:
1278
table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_DYNAMIC);
1280
case ROW_TYPE_COMPRESSED:
1281
table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_COMPRESSED);
1283
case ROW_TYPE_REDUNDANT:
1284
table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_REDUNDANT);
1286
case ROW_TYPE_COMPACT:
1287
table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_COMPACT);
1290
table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_PAGE);
1300
| ident_or_text equal ident_or_text
1302
drizzled::message::Engine::Option *opt= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_engine()->add_options();
1304
opt->set_name($1.str);
1305
opt->set_state($3.str);
1307
| ident_or_text equal ulonglong_num
1309
char number_as_string[22];
1310
snprintf(number_as_string, sizeof(number_as_string), "%"PRIu64, $3);
1312
drizzled::message::Engine::Option *opt= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_engine()->add_options();
1313
opt->set_name($1.str);
1314
opt->set_state(number_as_string);
1296
1316
| default_collation
1297
| KEY_BLOCK_SIZE opt_equal ulong_num
1299
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1301
statement->create_info.used_fields|= HA_CREATE_USED_KEY_BLOCK_SIZE;
1303
message::Table::TableOptions *tableopts;
1304
tableopts= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_options();
1305
tableopts->set_key_block_size($3);
1309
1319
default_collation:
1340
1350
| FIXED_SYM { $$= COLUMN_FORMAT_TYPE_FIXED; }
1341
1351
| DYNAMIC_SYM { $$= COLUMN_FORMAT_TYPE_DYNAMIC; };
1344
DEFAULT { $$= ROW_TYPE_DEFAULT; }
1345
| FIXED_SYM { $$= ROW_TYPE_FIXED; }
1346
| DYNAMIC_SYM { $$= ROW_TYPE_DYNAMIC; }
1347
| COMPRESSED_SYM { $$= ROW_TYPE_COMPRESSED; }
1348
| REDUNDANT_SYM { $$= ROW_TYPE_REDUNDANT; }
1349
| COMPACT_SYM { $$= ROW_TYPE_COMPACT; }
1350
| PAGE_SYM { $$= ROW_TYPE_PAGE; }
1353
1354
opt_select_from:
1354
1355
opt_limit_clause {}
1399
1400
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1400
Key *key= new Foreign_key($4.str ? $4 : $1, lex->col_list,
1401
Key *key= new Foreign_key($1.str ? $1 : $4, lex->col_list,
1403
1404
statement->fk_delete_opt,
1404
1405
statement->fk_update_opt,
1405
1406
statement->fk_match_option);
1406
1408
statement->alter_info.key_list.push_back(key);
1407
1409
key= new Key(Key::MULTIPLE, $1.str ? $1 : $4,
1408
1410
&default_key_create_info, 1,
1948
1950
opt_match_clause:
1950
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= Foreign_key::FK_MATCH_UNDEF; }
1952
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_UNDEFINED; }
1952
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= Foreign_key::FK_MATCH_FULL; }
1954
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_FULL; }
1953
1955
| MATCH PARTIAL
1954
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= Foreign_key::FK_MATCH_PARTIAL; }
1956
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_PARTIAL; }
1955
1957
| MATCH SIMPLE_SYM
1956
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= Foreign_key::FK_MATCH_SIMPLE; }
1958
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_SIMPLE; }
1959
1961
opt_on_update_delete:
1962
((statement::CreateTable *)Lex->statement)->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
1963
((statement::CreateTable *)Lex->statement)->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
1964
((statement::CreateTable *)Lex->statement)->fk_update_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
1965
((statement::CreateTable *)Lex->statement)->fk_delete_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
1965
1967
| ON UPDATE_SYM delete_option
1967
1969
((statement::CreateTable *)Lex->statement)->fk_update_opt= $3;
1968
((statement::CreateTable *)Lex->statement)->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
1970
((statement::CreateTable *)Lex->statement)->fk_delete_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
1970
1972
| ON DELETE_SYM delete_option
1972
((statement::CreateTable *)Lex->statement)->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
1974
((statement::CreateTable *)Lex->statement)->fk_update_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
1973
1975
((statement::CreateTable *)Lex->statement)->fk_delete_opt= $3;
1975
1977
| ON UPDATE_SYM delete_option
1990
RESTRICT { $$= Foreign_key::FK_OPTION_RESTRICT; }
1991
| CASCADE { $$= Foreign_key::FK_OPTION_CASCADE; }
1992
| SET NULL_SYM { $$= Foreign_key::FK_OPTION_SET_NULL; }
1993
| NO_SYM ACTION { $$= Foreign_key::FK_OPTION_NO_ACTION; }
1994
| SET DEFAULT { $$= Foreign_key::FK_OPTION_DEFAULT; }
1992
RESTRICT { $$= drizzled::message::Table::ForeignKeyConstraint::OPTION_RESTRICT; }
1993
| CASCADE { $$= drizzled::message::Table::ForeignKeyConstraint::OPTION_CASCADE; }
1994
| SET NULL_SYM { $$= drizzled::message::Table::ForeignKeyConstraint::OPTION_SET_NULL; }
1995
| NO_SYM ACTION { $$= drizzled::message::Table::ForeignKeyConstraint::OPTION_NO_ACTION; }
1996
| SET DEFAULT { $$= drizzled::message::Table::ForeignKeyConstraint::OPTION_SET_DEFAULT; }
2123
2125
DRIZZLE_YYABORT;
2124
2126
lex->col_list.empty();
2125
2127
lex->select_lex.init_order();
2127
((TableList*) lex->select_lex.table_list.first)->db;
2128
statement->create_info.row_type= ROW_TYPE_NOT_USED;
2128
lex->select_lex.db= const_cast<char *>(((TableList*) lex->select_lex.table_list.first)->getSchemaName());
2129
2129
statement->alter_info.build_method= $2;
2259
2259
| DROP FOREIGN KEY_SYM opt_ident
2261
2261
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2262
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::FOREIGN_KEY,
2263
2264
statement->alter_info.flags.set(ALTER_DROP_INDEX);
2264
2265
statement->alter_info.flags.set(ALTER_FOREIGN_KEY);
2418
CHECKSUM_SYM table_or_tables
2421
lex->sql_command = SQLCOM_CHECKSUM;
2422
lex->statement= new(std::nothrow) statement::Checksum(YYSession);
2423
if (lex->statement == NULL)
2432
2418
ANALYZE_SYM table_or_tables
2520
2506
select_paren_derived:
2521
2507
SELECT_SYM select_part2_derived
2523
if (setup_select_in_parentheses(Lex))
2509
if (setup_select_in_parentheses(YYSession, Lex))
2524
2510
DRIZZLE_YYABORT;
2526
2512
| '(' select_paren_derived ')'
2533
2519
Select_Lex * sel= lex->current_select;
2534
2520
if (lex->current_select->set_braces(0))
2536
my_parse_error(ER(ER_SYNTAX_ERROR));
2522
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
2523
my_parse_error(&pass);
2537
2524
DRIZZLE_YYABORT;
2539
2526
if (sel->linkage == UNION_TYPE &&
2540
2527
sel->master_unit()->first_select()->braces)
2542
my_parse_error(ER(ER_SYNTAX_ERROR));
2529
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
2530
my_parse_error(&pass);
2543
2531
DRIZZLE_YYABORT;
2890
2878
| bit_expr '*' bit_expr %prec '*'
2891
2879
{ $$= new Item_func_mul($1,$3); }
2892
2880
| bit_expr '/' bit_expr %prec '/'
2893
{ $$= new Item_func_div($1,$3); }
2881
{ $$= new Item_func_div(YYSession,$1,$3); }
2894
2882
| bit_expr '%' bit_expr %prec '%'
2895
2883
{ $$= new Item_func_mod($1,$3); }
2896
2884
| bit_expr DIV_SYM bit_expr %prec DIV_SYM
3015
3006
| CURRENT_USER optional_braces
3017
3008
std::string user_str("user");
3018
if (! ($$= reserved_keyword_function(user_str, NULL)))
3009
if (! ($$= reserved_keyword_function(YYSession, user_str, NULL)))
3020
3011
DRIZZLE_YYABORT;
3013
Lex->setCacheable(false);
3023
3015
| DATE_SYM '(' expr ')'
3024
3016
{ $$= new (YYSession->mem_root) Item_date_typecast($3); }
3027
3019
| HOUR_SYM '(' expr ')'
3028
3020
{ $$= new (YYSession->mem_root) Item_func_hour($3); }
3029
3021
| INSERT '(' expr ',' expr ',' expr ',' expr ')'
3030
{ $$= new (YYSession->mem_root) Item_func_insert($3,$5,$7,$9); }
3022
{ $$= new (YYSession->mem_root) Item_func_insert(*YYSession, $3, $5, $7, $9); }
3031
3023
| INTERVAL_SYM '(' expr ',' expr ')' %prec INTERVAL_SYM
3033
3025
Session *session= YYSession;
3078
3070
std::string user_str("user");
3079
if (! ($$= reserved_keyword_function(user_str, NULL)))
3071
if (! ($$= reserved_keyword_function(YYSession, user_str, NULL)))
3081
3073
DRIZZLE_YYABORT;
3075
Lex->setCacheable(false);
3084
3077
| YEAR_SYM '(' expr ')'
3085
3078
{ $$= new (YYSession->mem_root) Item_func_year($3); }
3107
3100
| CURDATE optional_braces
3109
3102
$$= new (YYSession->mem_root) Item_func_curdate_local();
3103
Lex->setCacheable(false);
3111
3105
| DATE_ADD_INTERVAL '(' expr ',' INTERVAL_SYM expr interval ')' %prec INTERVAL_SYM
3112
3106
{ $$= new (YYSession->mem_root) Item_date_add_interval($3,$6,$7,0); }
3117
3111
| NOW_SYM optional_braces
3119
3113
$$= new (YYSession->mem_root) Item_func_now_local();
3114
Lex->setCacheable(false);
3121
3116
| NOW_SYM '(' expr ')'
3123
3118
$$= new (YYSession->mem_root) Item_func_now_local($3);
3119
Lex->setCacheable(false);
3125
3121
| POSITION_SYM '(' bit_expr IN_SYM expr ')'
3126
3122
{ $$ = new (YYSession->mem_root) Item_func_locate($5,$3); }
3149
3145
List<Item> *args= new (YYSession->mem_root) List<Item>;
3150
3146
args->push_back($3);
3151
3147
args->push_back($5);
3152
if (! ($$= reserved_keyword_function(reverse_str, args)))
3148
if (! ($$= reserved_keyword_function(YYSession, reverse_str, args)))
3154
3150
DRIZZLE_YYABORT;
3172
3168
List<Item> *args= new (YYSession->mem_root) List<Item>;
3173
3169
args->push_back($3);
3174
3170
args->push_back($5);
3175
if (! ($$= reserved_keyword_function(reverse_str, args)))
3171
if (! ($$= reserved_keyword_function(YYSession, reverse_str, args)))
3177
3173
DRIZZLE_YYABORT;
3180
3176
| SYSDATE optional_braces
3181
{ $$= new (YYSession->mem_root) Item_func_sysdate_local(); }
3178
$$= new (YYSession->mem_root) Item_func_sysdate_local();
3179
Lex->setCacheable(false);
3182
3181
| SYSDATE '(' expr ')'
3183
{ $$= new (YYSession->mem_root) Item_func_sysdate_local($3); }
3183
$$= new (YYSession->mem_root) Item_func_sysdate_local($3);
3184
Lex->setCacheable(false);
3184
3186
| TIMESTAMP_ADD '(' interval_time_stamp ',' expr ',' expr ')'
3185
3187
{ $$= new (YYSession->mem_root) Item_date_add_interval($7,$5,$3,0); }
3186
3188
| TIMESTAMP_DIFF '(' interval_time_stamp ',' expr ',' expr ')'
3188
3190
| UTC_DATE_SYM optional_braces
3190
3192
$$= new (YYSession->mem_root) Item_func_curdate_utc();
3193
Lex->setCacheable(false);
3192
3195
| UTC_TIMESTAMP_SYM optional_braces
3194
3197
$$= new (YYSession->mem_root) Item_func_now_utc();
3198
Lex->setCacheable(false);
3208
3212
| DATABASE '(' ')'
3210
3214
std::string database_str("database");
3211
if (! ($$= reserved_keyword_function(database_str, NULL)))
3215
if (! ($$= reserved_keyword_function(YYSession, database_str, NULL)))
3213
3217
DRIZZLE_YYABORT;
3219
Lex->setCacheable(false);
3216
3221
| IF '(' expr ',' expr ',' expr ')'
3217
3222
{ $$= new (YYSession->mem_root) Item_func_if($3,$5,$7); }
3222
3227
| QUARTER_SYM '(' expr ')'
3223
3228
{ $$ = new (YYSession->mem_root) Item_func_quarter($3); }
3224
3229
| REPEAT_SYM '(' expr ',' expr ')'
3225
{ $$= new (YYSession->mem_root) Item_func_repeat($3,$5); }
3230
{ $$= new (YYSession->mem_root) Item_func_repeat(*YYSession, $3, $5); }
3226
3231
| REPLACE '(' expr ',' expr ',' expr ')'
3227
{ $$= new (YYSession->mem_root) Item_func_replace($3,$5,$7); }
3232
{ $$= new (YYSession->mem_root) Item_func_replace(*YYSession, $3, $5, $7); }
3228
3233
| REVERSE_SYM '(' expr ')'
3230
3235
std::string reverse_str("reverse");
3231
3236
List<Item> *args= new (YYSession->mem_root) List<Item>;
3232
3237
args->push_back($3);
3233
if (! ($$= reserved_keyword_function(reverse_str, args)))
3238
if (! ($$= reserved_keyword_function(YYSession, reverse_str, args)))
3235
3240
DRIZZLE_YYABORT;
3400
3406
ident_or_text SET_VAR expr
3402
3408
$$= new Item_func_set_user_var($1, $3);
3409
Lex->setCacheable(false);
3404
3411
| ident_or_text
3406
$$= new Item_func_get_user_var($1);
3413
$$= new Item_func_get_user_var(*YYSession, $1);
3414
Lex->setCacheable(false);
3408
3416
| '@' opt_var_ident_type ident_or_text opt_component
3410
3418
/* disallow "SELECT @@global.global.variable" */
3411
3419
if ($3.str && $4.str && check_reserved_words(&$3))
3413
my_parse_error(ER(ER_SYNTAX_ERROR));
3421
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
3422
my_parse_error(&pass);
3414
3423
DRIZZLE_YYABORT;
3416
3425
if (!($$= get_system_var(YYSession, $2, $3, $4)))
3567
3577
left-associative joins.
3569
3579
table_ref normal_join table_ref %prec TABLE_REF_PRIORITY
3570
{ DRIZZLE_YYABORT_UNLESS($1 && ($$=$3)); }
3581
DRIZZLE_YYABORT_UNLESS($1 && ($$=$3));
3582
Lex->is_cross= false;
3571
3584
| table_ref STRAIGHT_JOIN table_factor
3572
{ DRIZZLE_YYABORT_UNLESS($1 && ($$=$3)); $3->straight=1; }
3586
DRIZZLE_YYABORT_UNLESS($1 && ($$=$3)); $3->straight=1;
3573
3588
| table_ref normal_join table_ref
3576
3591
DRIZZLE_YYABORT_UNLESS($1 && $3);
3592
DRIZZLE_YYABORT_UNLESS( not Lex->is_cross );
3577
3593
/* Change the current name resolution context to a local context. */
3578
3594
if (push_new_name_resolution_context(YYSession, $1, $3))
3579
3595
DRIZZLE_YYABORT;
3706
3722
/* Warning - may return NULL in case of incomplete SELECT */
3709
Select_Lex *sel= Lex->current_select;
3710
sel->table_join_options= 0;
3712
3726
table_ident opt_table_alias opt_key_definition
3714
3728
if (!($$= Lex->current_select->add_table_to_list(YYSession, $2, $3,
3715
Lex->current_select->get_table_join_options(),
3716
3730
Lex->lock_option,
3717
3731
Lex->current_select->pop_index_hints())))
3718
3732
DRIZZLE_YYABORT;
3763
3778
/* Use $2 instead of Lex->current_select as derived table will
3764
3779
alter value of Lex->current_select. */
3765
3780
if (!($3 || $5) && $2->embedding &&
3766
!$2->embedding->nested_join->join_list.elements)
3781
!$2->embedding->getNestedJoin()->join_list.elements)
3768
3783
/* we have a derived table ($3 == NULL) but no alias,
3769
3784
Since we are nested in further parentheses so we
3791
3806
else if (($3->select_lex && $3->select_lex->master_unit()->is_union()) || $5)
3793
3808
/* simple nested joins cannot have aliases or unions */
3794
my_parse_error(ER(ER_SYNTAX_ERROR));
3809
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
3810
my_parse_error(&pass);
3795
3811
DRIZZLE_YYABORT;
3827
3843
Select_Lex * sel= lex->current_select;
3828
3844
if (lex->current_select->set_braces(0))
3830
my_parse_error(ER(ER_SYNTAX_ERROR));
3846
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
3847
my_parse_error(&pass);
3831
3848
DRIZZLE_YYABORT;
3833
3850
if (sel->linkage == UNION_TYPE &&
3834
3851
sel->master_unit()->first_select()->braces)
3836
my_parse_error(ER(ER_SYNTAX_ERROR));
3853
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
3854
my_parse_error(&pass);
3837
3855
DRIZZLE_YYABORT;
3885
3904
lex->derived_tables|= DERIVED_SUBQUERY;
3886
3905
if (!lex->expr_allows_subselect)
3888
my_parse_error(ER(ER_SYNTAX_ERROR));
3907
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
3908
my_parse_error(&pass);
3889
3909
DRIZZLE_YYABORT;
3891
3911
if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE ||
3916
3936
if (!sel->embedding || sel->end_nested_join(lex->session))
3918
3938
/* we are not in parentheses */
3919
my_parse_error(ER(ER_SYNTAX_ERROR));
3939
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
3940
my_parse_error(&pass);
3920
3941
DRIZZLE_YYABORT;
3922
3943
embedding= Lex->current_select->embedding;
3923
3944
$$= embedding &&
3924
!embedding->nested_join->join_list.elements;
3945
!embedding->getNestedJoin()->join_list.elements;
3925
3946
/* return true if we are deeply nested */
4356
4377
OUTFILE TEXT_STRING_filesystem
4380
lex->setCacheable(false);
4359
4381
if (!(lex->exchange= new file_exchange($2.str, 0)) ||
4360
4382
!(lex->result= new select_export(lex->exchange)))
4361
4383
DRIZZLE_YYABORT;
4440
4463
/* empty */ { $$= 0; }
4441
4464
| TEMPORARY_SYM { $$= 1; }
4468
Execute a string as dynamic SQL.
4472
EXECUTE_SYM execute_var_or_string
4477
execute_var_or_string:
4481
statement::Execute *statement= new(std::nothrow) statement::Execute(YYSession);
4482
lex->statement= statement;
4483
if (lex->statement == NULL)
4486
statement->setQuery($1);
4491
statement::Execute *statement= new(std::nothrow) statement::Execute(YYSession);
4492
lex->statement= statement;
4493
if (lex->statement == NULL)
4496
statement->setVar();
4497
statement->setQuery($2);
4444
4501
** Insert : add new data to table
4833
4895
if (session->add_item_to_list(my_field))
4834
4896
DRIZZLE_YYABORT;
4898
if (session->add_order_to_list(my_field, true))
4901
/* SHOW TEMPORARY TABLES */
4836
4902
| TEMPORARY_SYM TABLES show_wild
4859
4925
(session->lex->current_select->with_wild)++;
4928
/* SHOW TABLE STATUS */
4862
4929
| TABLE_SYM STATUS_SYM opt_db show_wild
4865
4932
lex->sql_command= SQLCOM_SELECT;
4866
statement::Select *select=
4867
new(std::nothrow) statement::Select(YYSession);
4933
statement::Show *select=
4934
new(std::nothrow) statement::Show(YYSession);
4869
4936
lex->statement= select;
4901
4968
DRIZZLE_YYABORT;
4902
4969
(session->lex->current_select->with_wild)++;
4971
/* SHOW COLUMNS FROM table_name */
4904
4972
| COLUMNS from_or_in table_ident opt_db show_wild
4907
4975
Session *session= YYSession;
4908
statement::Select *select;
4976
statement::Show *select;
4910
4978
lex->sql_command= SQLCOM_SELECT;
4912
select= new(std::nothrow) statement::Select(session);
4980
select= new(std::nothrow) statement::Show(session);
4914
4982
lex->statement= select;
4943
5011
(session->lex->current_select->with_wild)++;
5014
/* SHOW INDEXES from table */
4946
5015
| keys_or_index from_or_in table_ident opt_db where_clause
4949
5018
Session *session= YYSession;
4950
statement::Select *select;
5019
statement::Show *select;
4952
5021
lex->sql_command= SQLCOM_SELECT;
4954
select= new(std::nothrow) statement::Select(session);
5023
select= new(std::nothrow) statement::Show(session);
4956
5025
lex->statement= select;
4989
5058
(void) create_select_for_variable("warning_count");
4991
lex->statement= new(std::nothrow) statement::Select(YYSession);
5060
lex->statement= new(std::nothrow) statement::Show(YYSession);
4992
5061
if (lex->statement == NULL)
4993
5062
DRIZZLE_YYABORT;
4997
5066
(void) create_select_for_variable("error_count");
4999
lex->statement= new(std::nothrow) statement::Select(YYSession);
5068
lex->statement= new(std::nothrow) statement::Show(YYSession);
5000
5069
if (lex->statement == NULL)
5001
5070
DRIZZLE_YYABORT;
5053
5122
if (session->add_item_to_list(my_field))
5054
5123
DRIZZLE_YYABORT;
5125
| CREATE TABLE_SYM table_ident
5128
lex->sql_command= SQLCOM_SELECT;
5129
statement::Show *select=
5130
new(std::nothrow) statement::Show(YYSession);
5132
lex->statement= select;
5134
if (lex->statement == NULL)
5137
Session *session= YYSession;
5139
if (prepare_new_schema_table(session, lex, "TABLE_SQL_DEFINITION"))
5143
select->setShowPredicate($3->db.str, $3->table.str);
5145
select->setShowPredicate(session->db, $3->table.str);
5147
std::string key("Table");
5148
std::string value("Create Table");
5150
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "TABLE_NAME");
5151
my_field->is_autogenerated_name= false;
5152
my_field->set_name(key.c_str(), key.length(), system_charset_info);
5154
if (session->add_item_to_list(my_field))
5157
my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "TABLE_SQL_DEFINITION");
5158
my_field->is_autogenerated_name= false;
5159
my_field->set_name(value.c_str(), value.length(), system_charset_info);
5161
if (session->add_item_to_list(my_field))
5056
5164
| PROCESSLIST_SYM
5060
5168
lex->sql_command= SQLCOM_SELECT;
5061
5169
lex->statement=
5062
new(std::nothrow) statement::Select(YYSession);
5170
new(std::nothrow) statement::Show(YYSession);
5063
5171
if (lex->statement == NULL)
5064
5172
DRIZZLE_YYABORT;
5115
5223
DRIZZLE_YYABORT;
5117
5225
| CREATE DATABASE opt_if_not_exists ident
5119
Lex->sql_command=SQLCOM_SHOW_CREATE_DB;
5120
statement::ShowCreateSchema *statement= new(std::nothrow) statement::ShowCreateSchema(YYSession);
5121
Lex->statement= statement;
5122
if (Lex->statement == NULL)
5124
statement->is_if_not_exists= $3;
5127
| CREATE TABLE_SYM table_ident
5130
lex->sql_command = SQLCOM_SHOW_CREATE;
5131
lex->statement= new(std::nothrow) statement::ShowCreate(YYSession);
5132
if (lex->statement == NULL)
5134
if (!lex->select_lex.add_table_to_list(YYSession, $3, NULL,0))
5228
lex->sql_command= SQLCOM_SELECT;
5229
statement::Show *select=
5230
new(std::nothrow) statement::Show(YYSession);
5232
lex->statement= select;
5234
if (lex->statement == NULL)
5237
Session *session= YYSession;
5239
if (prepare_new_schema_table(session, lex, "SCHEMA_SQL_DEFINITION"))
5243
select->setShowPredicate($4.str);
5245
select->setShowPredicate(session->db);
5247
std::string key("Database");
5248
std::string value("Create Database");
5250
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "SCHEMA_NAME");
5251
my_field->is_autogenerated_name= false;
5252
my_field->set_name(key.c_str(), key.length(), system_charset_info);
5254
if (session->add_item_to_list(my_field))
5257
my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "SCHEMA_SQL_DEFINITION");
5258
my_field->is_autogenerated_name= false;
5259
my_field->set_name(value.c_str(), value.length(), system_charset_info);
5261
if (session->add_item_to_list(my_field))
5139
5266
/* empty */ { $$= 0; }
5167
5294
describe_command table_ident
5169
5296
Session *session= YYSession;
5170
statement::Select *select;
5297
statement::Show *select;
5172
5299
lex->lock_option= TL_READ;
5173
5300
mysql_init_select(lex);
5174
5301
lex->current_select->parsing_place= SELECT_LIST;
5175
5302
lex->sql_command= SQLCOM_SELECT;
5176
select= new(std::nothrow) statement::Select(session);
5303
select= new(std::nothrow) statement::Show(session);
5177
5304
lex->statement= select;
5178
5305
if (lex->statement == NULL)
5179
5306
DRIZZLE_YYABORT;
5704
5831
TableList *table=
5705
5832
reinterpret_cast<TableList*>(Lex->current_select->table_list.first);
5706
if (my_strcasecmp(table_alias_charset, $1.str, table->db))
5833
if (my_strcasecmp(table_alias_charset, $1.str, table->getSchemaName()))
5708
5835
my_error(ER_WRONG_DB_NAME, MYF(0), $1.str);
5709
5836
DRIZZLE_YYABORT;
5711
5838
if (my_strcasecmp(table_alias_charset, $3.str,
5839
table->getTableName()))
5714
5841
my_error(ER_WRONG_TABLE_NAME, MYF(0), $3.str);
5715
5842
DRIZZLE_YYABORT;