35
35
#define DRIZZLE_YACC
36
36
#define YYINITDEPTH 100
37
37
#define YYMAXDEPTH 3200 /* Because of 64K stack */
38
#define Lex (YYTHD->lex)
39
#define Select Lex->current_select
38
#define Lex (YYSession->lex)
40
39
#include <drizzled/server_includes.h>
41
#include "lex_symbol.h"
42
#include <storage/myisam/myisam.h>
43
#include <drizzled/drizzled_error_messages.h>
45
int yylex(void *yylval, void *yythd);
40
#include <drizzled/lex_symbol.h>
41
#include <drizzled/function/locate.h>
42
#include <drizzled/function/str/char.h>
43
#include <drizzled/function/str/collation.h>
44
#include <drizzled/function/str/database.h>
45
#include <drizzled/function/str/insert.h>
46
#include <drizzled/function/str/left.h>
47
#include <drizzled/function/str/repeat.h>
48
#include <drizzled/function/str/replace.h>
49
#include <drizzled/function/str/reverse.h>
50
#include <drizzled/function/str/right.h>
51
#include <drizzled/function/str/set_collation.h>
52
#include <drizzled/function/str/substr.h>
53
#include <drizzled/function/str/trim.h>
54
#include <drizzled/function/str/user.h>
55
#include <drizzled/function/str/weight_string.h>
57
#include <drizzled/function/time/curdate.h>
58
#include <drizzled/function/time/date_add_interval.h>
59
#include <drizzled/function/time/dayofmonth.h>
60
#include <drizzled/function/time/extract.h>
61
#include <drizzled/function/time/hour.h>
62
#include <drizzled/function/time/microsecond.h>
63
#include <drizzled/function/time/minute.h>
64
#include <drizzled/function/time/month.h>
65
#include <drizzled/function/time/now.h>
66
#include <drizzled/function/time/quarter.h>
67
#include <drizzled/function/time/second.h>
68
#include <drizzled/function/time/sysdate_local.h>
69
#include <drizzled/function/time/timestamp_diff.h>
70
#include <drizzled/function/time/typecast.h>
71
#include <drizzled/function/time/year.h>
73
#include <drizzled/error.h>
74
#include <drizzled/nested_join.h>
75
#include <drizzled/sql_parse.h>
76
#include <drizzled/item/copy_string.h>
77
#include <drizzled/item/cmpfunc.h>
78
#include <drizzled/item/uint.h>
79
#include <drizzled/item/null.h>
80
#include <drizzled/session.h>
81
#include <drizzled/item/func.h>
82
#include <drizzled/sql_base.h>
83
#include <drizzled/item/create.h>
84
#include <drizzled/item/default_value.h>
85
#include <drizzled/item/insert_value.h>
86
#include <drizzled/lex_string.h>
87
#include <drizzled/function/get_system_var.h>
88
#include <mysys/thr_lock.h>
89
#include <drizzled/message/table.pb.h>
90
#include <drizzled/statement.h>
91
#include <drizzled/statement/alter_schema.h>
92
#include <drizzled/statement/alter_table.h>
93
#include <drizzled/statement/analyze.h>
94
#include <drizzled/statement/change_schema.h>
95
#include <drizzled/statement/check.h>
96
#include <drizzled/statement/checksum.h>
97
#include <drizzled/statement/commit.h>
98
#include <drizzled/statement/create_index.h>
99
#include <drizzled/statement/create_schema.h>
100
#include <drizzled/statement/create_table.h>
101
#include <drizzled/statement/delete.h>
102
#include <drizzled/statement/drop_index.h>
103
#include <drizzled/statement/drop_schema.h>
104
#include <drizzled/statement/drop_table.h>
105
#include <drizzled/statement/empty_query.h>
106
#include <drizzled/statement/flush.h>
107
#include <drizzled/statement/insert.h>
108
#include <drizzled/statement/insert_select.h>
109
#include <drizzled/statement/kill.h>
110
#include <drizzled/statement/load.h>
111
#include <drizzled/statement/optimize.h>
112
#include <drizzled/statement/release_savepoint.h>
113
#include <drizzled/statement/rename_table.h>
114
#include <drizzled/statement/replace.h>
115
#include <drizzled/statement/replace_select.h>
116
#include <drizzled/statement/rollback.h>
117
#include <drizzled/statement/rollback_to_savepoint.h>
118
#include <drizzled/statement/savepoint.h>
119
#include <drizzled/statement/select.h>
120
#include <drizzled/statement/set_option.h>
121
#include <drizzled/statement/show_create.h>
122
#include <drizzled/statement/show_create_schema.h>
123
#include <drizzled/statement/show_engine_status.h>
124
#include <drizzled/statement/show_errors.h>
125
#include <drizzled/statement/show_processlist.h>
126
#include <drizzled/statement/show_status.h>
127
#include <drizzled/statement/show_warnings.h>
128
#include <drizzled/statement/start_transaction.h>
129
#include <drizzled/statement/truncate.h>
130
#include <drizzled/statement/unlock_tables.h>
131
#include <drizzled/statement/update.h>
133
using namespace drizzled;
139
int yylex(void *yylval, void *yysession);
47
141
#define yyoverflow(A,B,C,D,E,F) \
1016
1010
%type <build_method> build_method
1019
query verb_clause create change select drop insert replace insert2
1013
query verb_clause create select drop insert replace insert2
1020
1014
insert_values update delete truncate rename
1021
show describe load alter optimize keycache flush
1022
reset purge begin commit rollback savepoint release
1023
slave master_def master_defs master_file_def slave_until_opts
1024
repair analyze check start checksum
1015
show describe load alter optimize flush
1016
begin commit rollback savepoint release
1017
analyze check start checksum
1025
1018
field_list field_list_item field_spec kill column_def key_def
1026
keycache_list assign_to_keycache
1027
1019
select_item_list select_item values_list no_braces
1028
1020
opt_limit_clause delete_limit_clause fields opt_values values
1029
1021
opt_precision opt_ignore opt_column
1030
set lock unlock string_list field_options field_option
1031
field_opt_list opt_binary table_lock_list table_lock
1022
set unlock string_list
1032
1024
ref_list opt_match_clause opt_on_update_delete use
1033
1025
opt_delete_options opt_delete_option varchar
1034
opt_outer table_list table_name table_alias_ref_list table_alias_ref
1026
opt_outer table_list table_name
1035
1027
opt_option opt_place
1036
1028
opt_attribute opt_attribute_list attribute
1037
1029
flush_options flush_option
1038
1030
equal optional_braces
1039
1031
opt_mi_check_type opt_to mi_check_types normal_join
1040
1032
table_to_table_list table_to_table opt_table_list opt_as
1041
single_multi table_wild_list table_wild_one opt_wild
1042
1034
union_clause union_list
1043
precision subselect_start charset
1035
precision subselect_start
1044
1036
subselect_end select_var_list select_var_list_init opt_len
1045
1037
opt_extended_describe
1047
1039
opt_field_or_var_spec fields_or_vars opt_load_data_set_spec
1049
1040
init_key_options key_options key_opts key_opt key_using_alg
1149
CHANGE MASTER_SYM TO_SYM
1152
lex->sql_command = SQLCOM_CHANGE_MASTER;
1153
memset(&lex->mi, 0, sizeof(lex->mi));
1161
| master_defs ',' master_def
1165
MASTER_HOST_SYM EQ TEXT_STRING_sys
1167
Lex->mi.host = $3.str;
1169
| MASTER_USER_SYM EQ TEXT_STRING_sys
1171
Lex->mi.user = $3.str;
1173
| MASTER_PASSWORD_SYM EQ TEXT_STRING_sys
1175
Lex->mi.password = $3.str;
1177
| MASTER_PORT_SYM EQ ulong_num
1181
| MASTER_CONNECT_RETRY_SYM EQ ulong_num
1183
Lex->mi.connect_retry = $3;
1185
| MASTER_HEARTBEAT_PERIOD_SYM EQ NUM_literal
1187
Lex->mi.heartbeat_period= (float) $3->val_real();
1188
if (Lex->mi.heartbeat_period > SLAVE_MAX_HEARTBEAT_PERIOD ||
1189
Lex->mi.heartbeat_period < 0.0)
1191
char buf[sizeof(SLAVE_MAX_HEARTBEAT_PERIOD*4)];
1192
sprintf(buf, "%d seconds", SLAVE_MAX_HEARTBEAT_PERIOD);
1193
my_error(ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE,
1195
" is negative or exceeds the maximum ",
1199
if (Lex->mi.heartbeat_period > slave_net_timeout)
1201
push_warning_printf(YYTHD, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1202
ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE,
1203
ER(ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE),
1204
" exceeds the value of `slave_net_timeout' sec.",
1205
" A sensible value for the period should be"
1206
" less than the timeout.");
1208
if (Lex->mi.heartbeat_period < 0.001)
1210
if (Lex->mi.heartbeat_period != 0.0)
1212
push_warning_printf(YYTHD, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1213
ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE,
1214
ER(ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE),
1215
" is less than 1 msec.",
1216
" The period is reset to zero which means"
1217
" no heartbeats will be sending");
1218
Lex->mi.heartbeat_period= 0.0;
1220
Lex->mi.heartbeat_opt= LEX_MASTER_INFO::LEX_MI_DISABLE;
1222
Lex->mi.heartbeat_opt= LEX_MASTER_INFO::LEX_MI_ENABLE;
1229
MASTER_LOG_FILE_SYM EQ TEXT_STRING_sys
1231
Lex->mi.log_file_name = $3.str;
1233
| MASTER_LOG_POS_SYM EQ ulonglong_num
1237
If the user specified a value < BIN_LOG_HEADER_SIZE, adjust it
1238
instead of causing subsequent errors.
1239
We need to do it in this file, because only there we know that
1240
MASTER_LOG_POS has been explicitely specified. On the contrary
1241
in change_master() (sql_repl.cc) we cannot distinguish between 0
1242
(MASTER_LOG_POS explicitely specified as 0) and 0 (unspecified),
1243
whereas we want to distinguish (specified 0 means "read the binlog
1244
from 0" (4 in fact), unspecified means "don't change the position
1245
(keep the preceding value)").
1247
Lex->mi.pos = max((uint64_t)BIN_LOG_HEADER_SIZE, Lex->mi.pos);
1249
| RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
1251
Lex->mi.relay_log_name = $3.str;
1253
| RELAY_LOG_POS_SYM EQ ulong_num
1255
Lex->mi.relay_log_pos = $3;
1256
/* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
1257
Lex->mi.relay_log_pos = max((uint32_t)BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
1261
1131
/* create a table */
1264
1134
CREATE opt_table_options TABLE_SYM opt_if_not_exists table_ident
1136
Session *session= YYSession;
1137
LEX *lex= session->lex;
1268
1138
lex->sql_command= SQLCOM_CREATE_TABLE;
1269
if (!lex->select_lex.add_table_to_list(thd, $5, NULL,
1139
statement::CreateTable *statement= new(std::nothrow) statement::CreateTable(YYSession);
1140
lex->statement= statement;
1141
if (lex->statement == NULL)
1143
if (!lex->select_lex.add_table_to_list(session, $5, NULL,
1270
1144
TL_OPTION_UPDATING,
1272
1146
DRIZZLE_YYABORT;
1273
lex->alter_info.reset();
1274
1147
lex->col_list.empty();
1276
memset(&lex->create_info, 0, sizeof(lex->create_info));
1277
lex->create_info.options=$2 | $4;
1278
lex->create_info.db_type= ha_default_handlerton(thd);
1279
lex->create_info.default_table_charset= NULL;
1148
statement->change=NULL;
1149
statement->create_info.options=$2 | $4;
1150
statement->create_info.db_type= ha_default_storage_engine(session);
1151
statement->create_info.default_table_charset= NULL;
1280
1152
lex->name.str= 0;
1281
lex->name.length= 0;
1154
message::Table *proto= &statement->create_table_proto;
1156
proto->set_name($5->table.str);
1157
if($2 & HA_LEX_CREATE_TMP_TABLE)
1158
proto->set_type(message::Table::TEMPORARY);
1160
proto->set_type(message::Table::STANDARD);
1163
message::Table::StorageEngine *protoengine;
1164
protoengine= proto->mutable_engine();
1165
drizzled::plugin::StorageEngine *engine= ha_default_storage_engine(session);
1167
protoengine->set_name(engine->getName());
1285
LEX *lex= YYTHD->lex;
1172
LEX *lex= YYSession->lex;
1173
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1286
1174
lex->current_select= &lex->select_lex;
1287
if (!lex->create_info.db_type)
1289
lex->create_info.db_type= ha_default_handlerton(YYTHD);
1290
push_warning_printf(YYTHD, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1291
ER_WARN_USING_OTHER_HANDLER,
1292
ER(ER_WARN_USING_OTHER_HANDLER),
1293
ha_resolve_storage_engine_name(lex->create_info.db_type),
1175
assert(statement->create_info.db_type);
1297
| CREATE build_method opt_unique INDEX_SYM ident key_alg
1177
| CREATE build_method
1301
1180
lex->sql_command= SQLCOM_CREATE_INDEX;
1302
if (!lex->current_select->add_table_to_list(lex->thd, $8,
1181
statement::CreateIndex *statement= new(std::nothrow) statement::CreateIndex(YYSession);
1182
lex->statement= statement;
1183
if (lex->statement == NULL)
1185
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1186
statement->alter_info.build_method= $2;
1187
lex->col_list.empty();
1188
statement->change=NULL;
1190
opt_unique INDEX_SYM ident key_alg ON table_ident '(' key_list ')' key_options
1193
statement::CreateIndex *statement= (statement::CreateIndex *)Lex->statement;
1195
if (!lex->current_select->add_table_to_list(lex->session, $9,
1304
1197
TL_OPTION_UPDATING))
1305
1198
DRIZZLE_YYABORT;
1306
lex->alter_info.reset();
1307
lex->alter_info.flags= ALTER_ADD_INDEX;
1308
lex->alter_info.build_method= $2;
1309
lex->col_list.empty();
1312
'(' key_list ')' key_options
1316
key= new Key($3, $5, &lex->key_create_info, 0,
1318
lex->alter_info.key_list.push_back(key);
1200
key= new Key($4, $6, &statement->key_create_info, 0, lex->col_list);
1201
statement->alter_info.key_list.push_back(key);
1319
1202
lex->col_list.empty();
1321
1204
| CREATE DATABASE opt_if_not_exists ident
1323
Lex->create_info.default_table_charset= NULL;
1324
Lex->create_info.used_fields= 0;
1208
lex->sql_command=SQLCOM_CREATE_DB;
1209
statement::CreateSchema *statement= new(std::nothrow) statement::CreateSchema(YYSession);
1210
lex->statement= statement;
1211
if (lex->statement == NULL)
1213
statement->create_info.options=$3;
1326
1215
opt_create_database_options
1329
lex->sql_command=SQLCOM_CREATE_DB;
1331
lex->create_info.options=$3;
1463
1353
create_table_option:
1464
1354
ENGINE_SYM opt_equal storage_engines
1466
Lex->create_info.db_type= $3;
1467
Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE;
1469
| MAX_ROWS opt_equal ulonglong_num
1471
Lex->create_info.max_rows= $3;
1472
Lex->create_info.used_fields|= HA_CREATE_USED_MAX_ROWS;
1474
| MIN_ROWS opt_equal ulonglong_num
1476
Lex->create_info.min_rows= $3;
1477
Lex->create_info.used_fields|= HA_CREATE_USED_MIN_ROWS;
1479
| AVG_ROW_LENGTH opt_equal ulong_num
1481
Lex->create_info.avg_row_length=$3;
1482
Lex->create_info.used_fields|= HA_CREATE_USED_AVG_ROW_LENGTH;
1356
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1358
statement->create_info.db_type= $3;
1359
statement->create_info.used_fields|= HA_CREATE_USED_ENGINE;
1362
message::Table::StorageEngine *protoengine;
1363
protoengine= ((statement::CreateTable *)Lex->statement)->create_table_proto.mutable_engine();
1365
protoengine->set_name($3->getName());
1484
1368
| BLOCK_SIZE_SYM opt_equal ulong_num
1486
Lex->create_info.block_size= $3;
1487
Lex->create_info.used_fields|= HA_CREATE_USED_BLOCK_SIZE;
1370
message::Table::TableOptions *tableopts;
1371
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1372
tableopts= ((statement::CreateTable *)Lex->statement)->create_table_proto.mutable_options();
1374
tableopts->set_block_size($3);
1375
statement->create_info.used_fields|= HA_CREATE_USED_BLOCK_SIZE;
1489
1377
| COMMENT_SYM opt_equal TEXT_STRING_sys
1491
Lex->create_info.comment=$3;
1492
Lex->create_info.used_fields|= HA_CREATE_USED_COMMENT;
1379
message::Table::TableOptions *tableopts;
1380
tableopts= ((statement::CreateTable *)Lex->statement)->create_table_proto.mutable_options();
1382
tableopts->set_comment($3.str);
1494
1384
| AUTO_INC opt_equal ulonglong_num
1496
Lex->create_info.auto_increment_value=$3;
1497
Lex->create_info.used_fields|= HA_CREATE_USED_AUTO;
1499
| PACK_KEYS_SYM opt_equal ulong_num
1503
Lex->create_info.table_options|= HA_OPTION_NO_PACK_KEYS;
1506
Lex->create_info.table_options|= HA_OPTION_PACK_KEYS;
1509
my_parse_error(ER(ER_SYNTAX_ERROR));
1512
Lex->create_info.used_fields|= HA_CREATE_USED_PACK_KEYS;
1514
| PACK_KEYS_SYM opt_equal DEFAULT
1516
Lex->create_info.table_options&=
1517
~(HA_OPTION_PACK_KEYS | HA_OPTION_NO_PACK_KEYS);
1518
Lex->create_info.used_fields|= HA_CREATE_USED_PACK_KEYS;
1520
| CHECKSUM_SYM opt_equal ulong_num
1522
Lex->create_info.table_options|= $3 ? HA_OPTION_CHECKSUM : HA_OPTION_NO_CHECKSUM;
1523
Lex->create_info.used_fields|= HA_CREATE_USED_CHECKSUM;
1525
| TABLE_CHECKSUM_SYM opt_equal ulong_num
1527
Lex->create_info.table_options|= $3 ? HA_OPTION_CHECKSUM : HA_OPTION_NO_CHECKSUM;
1528
Lex->create_info.used_fields|= HA_CREATE_USED_CHECKSUM;
1530
| PAGE_CHECKSUM_SYM opt_equal choice
1532
Lex->create_info.used_fields|= HA_CREATE_USED_PAGE_CHECKSUM;
1533
Lex->create_info.page_checksum= $3;
1535
| DELAY_KEY_WRITE_SYM opt_equal ulong_num
1537
Lex->create_info.table_options|= $3 ? HA_OPTION_DELAY_KEY_WRITE : HA_OPTION_NO_DELAY_KEY_WRITE;
1538
Lex->create_info.used_fields|= HA_CREATE_USED_DELAY_KEY_WRITE;
1386
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1388
statement->create_info.auto_increment_value=$3;
1389
statement->create_info.used_fields|= HA_CREATE_USED_AUTO;
1540
1391
| ROW_FORMAT_SYM opt_equal row_types
1542
Lex->create_info.row_type= $3;
1543
Lex->create_info.used_fields|= HA_CREATE_USED_ROW_FORMAT;
1544
Lex->alter_info.flags|= ALTER_ROW_FORMAT;
1393
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1395
statement->create_info.row_type= $3;
1396
statement->create_info.used_fields|= HA_CREATE_USED_ROW_FORMAT;
1397
statement->alter_info.flags.set(ALTER_ROW_FORMAT);
1547
1399
| default_collation
1548
| DATA_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys
1550
Lex->create_info.data_file_name= $4.str;
1551
Lex->create_info.used_fields|= HA_CREATE_USED_DATADIR;
1553
| INDEX_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys
1555
Lex->create_info.index_file_name= $4.str;
1556
Lex->create_info.used_fields|= HA_CREATE_USED_INDEXDIR;
1558
| CONNECTION_SYM opt_equal TEXT_STRING_sys
1560
Lex->create_info.connect_string.str= $3.str;
1561
Lex->create_info.connect_string.length= $3.length;
1562
Lex->create_info.used_fields|= HA_CREATE_USED_CONNECTION;
1564
1400
| KEY_BLOCK_SIZE opt_equal ulong_num
1566
Lex->create_info.used_fields|= HA_CREATE_USED_KEY_BLOCK_SIZE;
1567
Lex->create_info.key_block_size= $3;
1569
| TRANSACTIONAL_SYM opt_equal choice
1571
Lex->create_info.used_fields|= HA_CREATE_USED_TRANSACTIONAL;
1572
Lex->create_info.transactional= $3;
1402
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1577
opt_default charset opt_equal charset_name_or_default
1579
HA_CREATE_INFO *cinfo= &Lex->create_info;
1580
if ((cinfo->used_fields & HA_CREATE_USED_DEFAULT_CHARSET) &&
1581
cinfo->default_table_charset && $4 &&
1582
!my_charset_same(cinfo->default_table_charset,$4))
1584
my_error(ER_CONFLICTING_DECLARATIONS, MYF(0),
1585
"CHARACTER SET ", cinfo->default_table_charset->csname,
1586
"CHARACTER SET ", $4->csname);
1589
Lex->create_info.default_table_charset= $4;
1590
Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET;
1404
statement->create_info.used_fields|= HA_CREATE_USED_KEY_BLOCK_SIZE;
1405
statement->create_info.key_block_size= $3;
1594
1409
default_collation:
1595
1410
opt_default COLLATE_SYM opt_equal collation_name_or_default
1597
HA_CREATE_INFO *cinfo= &Lex->create_info;
1412
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1414
HA_CREATE_INFO *cinfo= &statement->create_info;
1598
1415
if ((cinfo->used_fields & HA_CREATE_USED_DEFAULT_CHARSET) &&
1599
1416
cinfo->default_table_charset && $4 &&
1600
1417
!my_charset_same(cinfo->default_table_charset,$4))
1679
1508
key_type opt_ident key_alg '(' key_list ')' key_options
1682
Key *key= new Key($1, $2, &lex->key_create_info, 0,
1511
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1512
Key *key= new Key($1, $2, &statement->key_create_info, 0,
1683
1513
lex->col_list);
1684
lex->alter_info.key_list.push_back(key);
1514
statement->alter_info.key_list.push_back(key);
1685
1515
lex->col_list.empty(); /* Alloced by sql_alloc */
1687
1517
| opt_constraint constraint_key_type opt_ident key_alg
1688
1518
'(' key_list ')' key_options
1691
Key *key= new Key($2, $3.str ? $3 : $1, &lex->key_create_info, 0,
1521
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1522
Key *key= new Key($2, $3.str ? $3 : $1, &statement->key_create_info, 0,
1692
1523
lex->col_list);
1693
lex->alter_info.key_list.push_back(key);
1524
statement->alter_info.key_list.push_back(key);
1694
1525
lex->col_list.empty(); /* Alloced by sql_alloc */
1696
1527
| opt_constraint FOREIGN KEY_SYM opt_ident '(' key_list ')' references
1530
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1699
1531
Key *key= new Foreign_key($4.str ? $4 : $1, lex->col_list,
1704
lex->fk_match_option);
1705
lex->alter_info.key_list.push_back(key);
1534
statement->fk_delete_opt,
1535
statement->fk_update_opt,
1536
statement->fk_match_option);
1537
statement->alter_info.key_list.push_back(key);
1706
1538
key= new Key(Key::MULTIPLE, $1.str ? $1 : $4,
1707
1539
&default_key_create_info, 1,
1708
1540
lex->col_list);
1709
lex->alter_info.key_list.push_back(key);
1541
statement->alter_info.key_list.push_back(key);
1710
1542
lex->col_list.empty(); /* Alloced by sql_alloc */
1711
1543
/* Only used for ALTER TABLE. Ignored otherwise. */
1712
lex->alter_info.flags|= ALTER_FOREIGN_KEY;
1544
statement->alter_info.flags.set(ALTER_FOREIGN_KEY);
1714
1546
| constraint opt_check_constraint
1578
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1746
1579
lex->length=lex->dec=0;
1748
lex->default_value= lex->on_update_value= 0;
1749
lex->comment=null_lex_str;
1581
statement->default_value= statement->on_update_value= 0;
1582
statement->comment= null_lex_str;
1750
1583
lex->charset=NULL;
1751
lex->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
1584
statement->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
1756
if (add_field_to_list(lex->thd, &$1, (enum enum_field_types) $3,
1589
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1590
if (add_field_to_list(lex->session, &$1, (enum enum_field_types) $3,
1757
1591
lex->length,lex->dec,lex->type,
1759
lex->default_value, lex->on_update_value,
1761
lex->change,&lex->interval_list,lex->charset))
1592
statement->column_format,
1593
statement->default_value, statement->on_update_value,
1594
&statement->comment,
1595
statement->change, &lex->interval_list, lex->charset))
1762
1596
DRIZZLE_YYABORT;
1600
type opt_attribute {}
1767
int_type field_options
1770
1607
Lex->length=(char*) 0; /* use default length */
1772
| real_type opt_precision field_options { $$=$1; }
1775
Lex->length= (char*) "1";
1776
$$=DRIZZLE_TYPE_TINY;
1780
Lex->length=(char*) "1";
1781
$$=DRIZZLE_TYPE_TINY;
1785
Lex->length=(char*) "1";
1786
$$=DRIZZLE_TYPE_TINY;
1609
| real_type opt_precision { $$=$1; }
1788
1610
| char '(' NUM ')' opt_binary
1790
1612
Lex->length=$3.str;
1931
1729
NULL_SYM { Lex->type&= ~ NOT_NULL_FLAG; }
1932
1730
| COLUMN_FORMAT_SYM column_format_types
1934
Lex->column_format= $2;
1935
Lex->alter_info.flags|= ALTER_COLUMN_FORMAT;
1732
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1734
statement->column_format= $2;
1735
statement->alter_info.flags.set(ALTER_COLUMN_FORMAT);
1937
1737
| not NULL_SYM { Lex->type|= NOT_NULL_FLAG; }
1938
1738
| DEFAULT now_or_signed_literal
1940
Lex->default_value=$2;
1941
Lex->alter_info.flags|= ALTER_COLUMN_DEFAULT;
1740
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1742
statement->default_value=$2;
1743
statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1943
1745
| ON UPDATE_SYM NOW_SYM optional_braces
1944
{ Lex->on_update_value= new Item_func_now_local(); }
1746
{ ((statement::AlterTable *)Lex->statement)->on_update_value= new Item_func_now_local(); }
1945
1747
| AUTO_INC { Lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG; }
1946
1748
| SERIAL_SYM DEFAULT VALUE_SYM
1751
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1949
1753
lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_FLAG;
1950
lex->alter_info.flags|= ALTER_ADD_INDEX;
1754
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1952
1756
| opt_primary KEY_SYM
1759
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1955
1761
lex->type|= PRI_KEY_FLAG | NOT_NULL_FLAG;
1956
lex->alter_info.flags|= ALTER_ADD_INDEX;
1762
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1767
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1961
1769
lex->type|= UNIQUE_FLAG;
1962
lex->alter_info.flags|= ALTER_ADD_INDEX;
1770
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1964
1772
| UNIQUE_SYM KEY_SYM
1775
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1967
1777
lex->type|= UNIQUE_KEY_FLAG;
1968
lex->alter_info.flags|= ALTER_ADD_INDEX;
1778
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1970
| COMMENT_SYM TEXT_STRING_sys { Lex->comment= $2; }
1780
| COMMENT_SYM TEXT_STRING_sys { ((statement::AlterTable *)Lex->statement)->comment= $2; }
1971
1781
| COLLATE_SYM collation_name
1973
1783
if (Lex->charset && !my_charset_same(Lex->charset,$2))
2202
1931
opt_match_clause:
2204
{ Lex->fk_match_option= Foreign_key::FK_MATCH_UNDEF; }
1933
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= Foreign_key::FK_MATCH_UNDEF; }
2206
{ Lex->fk_match_option= Foreign_key::FK_MATCH_FULL; }
1935
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= Foreign_key::FK_MATCH_FULL; }
2207
1936
| MATCH PARTIAL
2208
{ Lex->fk_match_option= Foreign_key::FK_MATCH_PARTIAL; }
1937
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= Foreign_key::FK_MATCH_PARTIAL; }
2209
1938
| MATCH SIMPLE_SYM
2210
{ Lex->fk_match_option= Foreign_key::FK_MATCH_SIMPLE; }
1939
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= Foreign_key::FK_MATCH_SIMPLE; }
2213
1942
opt_on_update_delete:
2217
lex->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
2218
lex->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
1945
((statement::CreateTable *)Lex->statement)->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
1946
((statement::CreateTable *)Lex->statement)->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
2220
1948
| ON UPDATE_SYM delete_option
2223
lex->fk_update_opt= $3;
2224
lex->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
1950
((statement::CreateTable *)Lex->statement)->fk_update_opt= $3;
1951
((statement::CreateTable *)Lex->statement)->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
2226
1953
| ON DELETE_SYM delete_option
2229
lex->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
2230
lex->fk_delete_opt= $3;
1955
((statement::CreateTable *)Lex->statement)->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
1956
((statement::CreateTable *)Lex->statement)->fk_delete_opt= $3;
2232
1958
| ON UPDATE_SYM delete_option
2233
1959
ON DELETE_SYM delete_option
2236
lex->fk_update_opt= $3;
2237
lex->fk_delete_opt= $6;
1961
((statement::CreateTable *)Lex->statement)->fk_update_opt= $3;
1962
((statement::CreateTable *)Lex->statement)->fk_delete_opt= $6;
2239
1964
| ON DELETE_SYM delete_option
2240
1965
ON UPDATE_SYM delete_option
2243
lex->fk_update_opt= $6;
2244
lex->fk_delete_opt= $3;
1967
((statement::CreateTable *)Lex->statement)->fk_update_opt= $6;
1968
((statement::CreateTable *)Lex->statement)->fk_delete_opt= $3;
2368
2092
ALTER build_method opt_ignore TABLE_SYM table_ident
2094
Session *session= YYSession;
2095
LEX *lex= session->lex;
2372
2096
lex->name.str= 0;
2373
2097
lex->name.length= 0;
2374
2098
lex->sql_command= SQLCOM_ALTER_TABLE;
2099
statement::AlterTable *statement= new(std::nothrow) statement::AlterTable(YYSession);
2100
lex->statement= statement;
2101
if (lex->statement == NULL)
2375
2103
lex->duplicates= DUP_ERROR;
2376
if (!lex->select_lex.add_table_to_list(thd, $5, NULL,
2104
if (!lex->select_lex.add_table_to_list(session, $5, NULL,
2377
2105
TL_OPTION_UPDATING))
2378
2106
DRIZZLE_YYABORT;
2379
lex->alter_info.reset();
2380
2107
lex->col_list.empty();
2381
2108
lex->select_lex.init_order();
2382
2109
lex->select_lex.db=
2383
((TABLE_LIST*) lex->select_lex.table_list.first)->db;
2384
memset(&lex->create_info, 0, sizeof(lex->create_info));
2385
lex->create_info.db_type= 0;
2386
lex->create_info.default_table_charset= NULL;
2387
lex->create_info.row_type= ROW_TYPE_NOT_USED;
2388
lex->alter_info.reset();
2389
lex->no_write_to_binlog= 0;
2390
lex->alter_info.build_method= $2;
2110
((TableList*) lex->select_lex.table_list.first)->db;
2111
statement->create_info.db_type= 0;
2112
statement->create_info.default_table_charset= NULL;
2113
statement->create_info.row_type= ROW_TYPE_NOT_USED;
2114
statement->alter_info.build_method= $2;
2394
2118
| ALTER DATABASE ident_or_empty
2396
Lex->create_info.default_table_charset= NULL;
2397
Lex->create_info.used_fields= 0;
2399
create_database_options
2402
2121
lex->sql_command=SQLCOM_ALTER_DB;
2122
lex->statement= new(std::nothrow) statement::AlterSchema(YYSession);
2123
if (lex->statement == NULL)
2126
default_collation_schema
2404
2130
if (lex->name.str == NULL &&
2405
2131
lex->copy_db_to(&lex->name.str, &lex->name.length))
2452
2187
add_column column_def opt_place { }
2455
Lex->alter_info.flags|= ALTER_ADD_INDEX;
2190
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2192
statement->alter_info.flags.set(ALTER_ADD_INDEX);
2457
2194
| add_column '(' field_list ')'
2459
Lex->alter_info.flags|= ALTER_ADD_COLUMN | ALTER_ADD_INDEX;
2196
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2198
statement->alter_info.flags.set(ALTER_ADD_COLUMN);
2199
statement->alter_info.flags.set(ALTER_ADD_INDEX);
2461
2201
| CHANGE opt_column field_ident
2464
lex->change= $3.str;
2465
lex->alter_info.flags|= ALTER_CHANGE_COLUMN;
2203
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2204
statement->change= $3.str;
2205
statement->alter_info.flags.set(ALTER_CHANGE_COLUMN);
2467
2207
field_spec opt_place
2468
2208
| MODIFY_SYM opt_column field_ident
2211
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2471
2212
lex->length=lex->dec=0; lex->type=0;
2472
lex->default_value= lex->on_update_value= 0;
2473
lex->comment=null_lex_str;
2213
statement->default_value= statement->on_update_value= 0;
2214
statement->comment= null_lex_str;
2474
2215
lex->charset= NULL;
2475
lex->alter_info.flags|= ALTER_CHANGE_COLUMN;
2476
lex->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
2216
statement->alter_info.flags.set(ALTER_CHANGE_COLUMN);
2217
statement->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
2481
if (add_field_to_list(lex->thd,&$3,
2222
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2224
if (add_field_to_list(lex->session,&$3,
2482
2225
(enum enum_field_types) $5,
2483
lex->length,lex->dec,lex->type,
2485
lex->default_value, lex->on_update_value,
2226
lex->length, lex->dec, lex->type,
2227
statement->column_format,
2228
statement->default_value,
2229
statement->on_update_value,
2230
&statement->comment,
2487
2231
$3.str, &lex->interval_list, lex->charset))
2488
2232
DRIZZLE_YYABORT;
2491
2235
| DROP opt_column field_ident
2494
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::COLUMN,
2496
lex->alter_info.flags|= ALTER_DROP_COLUMN;
2237
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2239
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::COLUMN, $3.str));
2240
statement->alter_info.flags.set(ALTER_DROP_COLUMN);
2498
2242
| DROP FOREIGN KEY_SYM opt_ident
2500
Lex->alter_info.flags|= ALTER_DROP_INDEX | ALTER_FOREIGN_KEY;
2244
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2246
statement->alter_info.flags.set(ALTER_DROP_INDEX);
2247
statement->alter_info.flags.set(ALTER_FOREIGN_KEY);
2502
2249
| DROP PRIMARY_SYM KEY_SYM
2505
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::KEY,
2507
lex->alter_info.flags|= ALTER_DROP_INDEX;
2251
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2253
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY,
2255
statement->alter_info.flags.set(ALTER_DROP_INDEX);
2509
2257
| DROP key_or_index field_ident
2512
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::KEY,
2514
lex->alter_info.flags|= ALTER_DROP_INDEX;
2259
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2261
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY,
2263
statement->alter_info.flags.set(ALTER_DROP_INDEX);
2516
2265
| DISABLE_SYM KEYS
2519
lex->alter_info.keys_onoff= DISABLE;
2520
lex->alter_info.flags|= ALTER_KEYS_ONOFF;
2267
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2269
statement->alter_info.keys_onoff= DISABLE;
2270
statement->alter_info.flags.set(ALTER_KEYS_ONOFF);
2522
2272
| ENABLE_SYM KEYS
2525
lex->alter_info.keys_onoff= ENABLE;
2526
lex->alter_info.flags|= ALTER_KEYS_ONOFF;
2274
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2276
statement->alter_info.keys_onoff= ENABLE;
2277
statement->alter_info.flags.set(ALTER_KEYS_ONOFF);
2528
2279
| ALTER opt_column field_ident SET DEFAULT signed_literal
2531
lex->alter_info.alter_list.push_back(new Alter_column($3.str,$6));
2532
lex->alter_info.flags|= ALTER_COLUMN_DEFAULT;
2281
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2283
statement->alter_info.alter_list.push_back(new AlterColumn($3.str,$6));
2284
statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
2534
2286
| ALTER opt_column field_ident DROP DEFAULT
2537
lex->alter_info.alter_list.push_back(new Alter_column($3.str,
2539
lex->alter_info.flags|= ALTER_COLUMN_DEFAULT;
2288
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2290
statement->alter_info.alter_list.push_back(new AlterColumn($3.str, (Item*) 0));
2291
statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
2541
2293
| RENAME opt_to table_ident
2296
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2545
2299
lex->select_lex.db=$3->db.str;
2546
2300
if (lex->select_lex.db == NULL &&
2547
2301
lex->copy_db_to(&lex->select_lex.db, &dummy))
2554
2308
DRIZZLE_YYABORT;
2556
2310
lex->name= $3->table;
2557
lex->alter_info.flags|= ALTER_RENAME;
2311
statement->alter_info.flags.set(ALTER_RENAME);
2559
| CONVERT_SYM TO_SYM charset charset_name_or_default opt_collate
2313
| CONVERT_SYM TO_SYM collation_name_or_default
2564
$4= thd->variables.collation_database;
2567
if (!my_charset_same($4,$5))
2569
my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
2570
$5->name, $4->csname);
2574
lex->create_info.table_charset=
2575
lex->create_info.default_table_charset= $5;
2576
lex->create_info.used_fields|= (HA_CREATE_USED_CHARSET |
2315
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2317
statement->create_info.table_charset=
2318
statement->create_info.default_table_charset= $3;
2319
statement->create_info.used_fields|= (HA_CREATE_USED_CHARSET |
2577
2320
HA_CREATE_USED_DEFAULT_CHARSET);
2578
lex->alter_info.flags|= ALTER_CONVERT;
2321
statement->alter_info.flags.set(ALTER_CONVERT);
2580
2323
| create_table_options_space_separated
2583
lex->alter_info.flags|= ALTER_OPTIONS;
2325
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2327
statement->alter_info.flags.set(ALTER_OPTIONS);
2587
Lex->alter_info.flags|= ALTER_FORCE;
2331
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2333
statement->alter_info.flags.set(ALTER_FORCE);
2589
2335
| alter_order_clause
2592
lex->alter_info.flags|= ALTER_ORDER;
2337
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2339
statement->alter_info.flags.set(ALTER_ORDER);
2686
{ Lex->slave_thd_opt= 0; }
2687
slave_thread_opt_list
2691
slave_thread_opt_list:
2693
| slave_thread_opt_list ',' slave_thread_opt
2698
| SQL_THREAD { Lex->slave_thd_opt|=SLAVE_SQL; }
2699
| RELAY_THREAD { Lex->slave_thd_opt|=SLAVE_IO; }
2704
| UNTIL_SYM slave_until_opts
2707
if (((lex->mi.log_file_name || lex->mi.pos) && (lex->mi.relay_log_name || lex->mi.relay_log_pos)) ||
2708
!((lex->mi.log_file_name && lex->mi.pos) ||
2709
(lex->mi.relay_log_name && lex->mi.relay_log_pos)))
2711
my_message(ER_BAD_SLAVE_UNTIL_COND,
2712
ER(ER_BAD_SLAVE_UNTIL_COND), MYF(0));
2720
| slave_until_opts ',' master_file_def
2724
2400
CHECKSUM_SYM table_or_tables
2727
2403
lex->sql_command = SQLCOM_CHECKSUM;
2404
lex->statement= new(std::nothrow) statement::Checksum(YYSession);
2405
if (lex->statement == NULL)
2729
2408
table_list opt_checksum_type
2733
2412
opt_checksum_type:
2734
/* nothing */ { Lex->check_opt.flags= 0; }
2735
| QUICK { Lex->check_opt.flags= T_QUICK; }
2736
| EXTENDED_SYM { Lex->check_opt.flags= T_EXTEND; }
2740
REPAIR opt_no_write_to_binlog table_or_tables
2743
lex->sql_command = SQLCOM_REPAIR;
2744
lex->no_write_to_binlog= $2;
2745
lex->check_opt.init();
2747
table_list opt_mi_repair_type
2752
/* empty */ { Lex->check_opt.flags = T_MEDIUM; }
2753
| mi_repair_types {}
2758
| mi_repair_type mi_repair_types {}
2762
QUICK { Lex->check_opt.flags|= T_QUICK; }
2763
| EXTENDED_SYM { Lex->check_opt.flags|= T_EXTEND; }
2764
| USE_FRM { Lex->check_opt.sql_flags|= TT_USEFRM; }
2413
/* nothing */ { ((statement::Checksum *)Lex->statement)->check_opt.flags= 0; }
2414
| QUICK { ((statement::Checksum *)Lex->statement)->check_opt.flags= T_QUICK; }
2415
| EXTENDED_SYM { ((statement::Checksum *)Lex->statement)->check_opt.flags= T_EXTEND; }
2768
ANALYZE_SYM opt_no_write_to_binlog table_or_tables
2420
ANALYZE_SYM table_or_tables
2771
2423
lex->sql_command = SQLCOM_ANALYZE;
2772
lex->no_write_to_binlog= $2;
2773
lex->check_opt.init();
2424
lex->statement= new(std::nothrow) statement::Analyze(YYSession);
2425
if (lex->statement == NULL)
2779
binlog_base64_event:
2780
BINLOG_SYM TEXT_STRING_sys
2782
Lex->sql_command = SQLCOM_BINLOG_BASE64_EVENT;
2788
2433
CHECK_SYM table_or_tables
2792
2437
lex->sql_command = SQLCOM_CHECK;
2793
lex->check_opt.init();
2438
lex->statement= new(std::nothrow) statement::Check(YYSession);
2439
if (lex->statement == NULL)
2795
2442
table_list opt_mi_check_type
2799
2446
opt_mi_check_type:
2800
/* empty */ { Lex->check_opt.flags = T_MEDIUM; }
2447
/* empty */ { ((statement::Check *)Lex->statement)->check_opt.flags = T_MEDIUM; }
2801
2448
| mi_check_types {}
2851
2496
table_ident TO_SYM table_ident
2854
SELECT_LEX *sl= lex->current_select;
2855
if (!sl->add_table_to_list(lex->thd, $1,NULL,TL_OPTION_UPDATING,
2499
Select_Lex *sl= lex->current_select;
2500
if (!sl->add_table_to_list(lex->session, $1,NULL,TL_OPTION_UPDATING,
2857
!sl->add_table_to_list(lex->thd, $3,NULL,TL_OPTION_UPDATING,
2502
!sl->add_table_to_list(lex->session, $3,NULL,TL_OPTION_UPDATING,
2859
2504
DRIZZLE_YYABORT;
2864
CACHE_SYM INDEX_SYM keycache_list IN_SYM key_cache_name
2867
lex->sql_command= SQLCOM_ASSIGN_TO_KEYCACHE;
2874
| keycache_list ',' assign_to_keycache
2878
table_ident cache_keys_spec
2880
if (!Select->add_table_to_list(YYTHD, $1, NULL, 0, TL_READ,
2881
Select->pop_index_hints()))
2888
| DEFAULT { $$ = default_key_cache_base; }
2893
Lex->select_lex.alloc_index_hints(YYTHD);
2894
Select->set_index_hint_type(INDEX_HINT_USE,
2895
global_system_variables.old_mode ?
2896
INDEX_HINT_MASK_JOIN :
2897
INDEX_HINT_MASK_ALL);
2899
cache_key_list_or_empty
2902
cache_key_list_or_empty:
2904
| key_or_index '(' opt_key_usage_list ')'
2908
2509
Select : retrieve data from table
3256
2854
bit_expr IN_SYM '(' subselect ')'
3258
$$= new (YYTHD->mem_root) Item_in_subselect($1, $4);
2856
$$= new (YYSession->mem_root) Item_in_subselect($1, $4);
3260
2858
| bit_expr not IN_SYM '(' subselect ')'
3263
Item *item= new (thd->mem_root) Item_in_subselect($1, $5);
3264
$$= negate_expression(thd, item);
2860
Session *session= YYSession;
2861
Item *item= new (session->mem_root) Item_in_subselect($1, $5);
2862
$$= negate_expression(session, item);
3266
2864
| bit_expr IN_SYM '(' expr ')'
3268
$$= handle_sql2003_note184_exception(YYTHD, $1, true, $4);
2866
$$= handle_sql2003_note184_exception(YYSession, $1, true, $4);
3270
2868
| bit_expr IN_SYM '(' expr ',' expr_list ')'
3272
2870
$6->push_front($4);
3273
2871
$6->push_front($1);
3274
$$= new (YYTHD->mem_root) Item_func_in(*$6);
2872
$$= new (YYSession->mem_root) Item_func_in(*$6);
3276
2874
| bit_expr not IN_SYM '(' expr ')'
3278
$$= handle_sql2003_note184_exception(YYTHD, $1, false, $5);
2876
$$= handle_sql2003_note184_exception(YYSession, $1, false, $5);
3280
2878
| bit_expr not IN_SYM '(' expr ',' expr_list ')'
3282
2880
$7->push_front($5);
3283
2881
$7->push_front($1);
3284
Item_func_in *item = new (YYTHD->mem_root) Item_func_in(*$7);
2882
Item_func_in *item = new (YYSession->mem_root) Item_func_in(*$7);
3285
2883
item->negate();
3356
2954
| function_call_conflict
3357
2955
| simple_expr COLLATE_SYM ident_or_text %prec NEG
3360
Item *i1= new (thd->mem_root) Item_string($3.str,
2957
Session *session= YYSession;
2958
Item *i1= new (session->mem_root) Item_string($3.str,
3363
$$= new (thd->mem_root) Item_func_set_collation($1, i1);
2960
session->charset());
2961
$$= new (session->mem_root) Item_func_set_collation($1, i1);
3368
2966
| '+' simple_expr %prec NEG { $$= $2; }
3369
2967
| '-' simple_expr %prec NEG
3370
{ $$= new (YYTHD->mem_root) Item_func_neg($2); }
2968
{ $$= new (YYSession->mem_root) Item_func_neg($2); }
3371
2969
| '(' subselect ')'
3373
$$= new (YYTHD->mem_root) Item_singlerow_subselect($2);
2971
$$= new (YYSession->mem_root) Item_singlerow_subselect($2);
3375
2973
| '(' expr ')' { $$= $2; }
3376
2974
| '(' expr ',' expr_list ')'
3378
2976
$4->push_front($2);
3379
$$= new (YYTHD->mem_root) Item_row(*$4);
2977
$$= new (YYSession->mem_root) Item_row(*$4);
3381
2979
| ROW_SYM '(' expr ',' expr_list ')'
3383
2981
$5->push_front($3);
3384
$$= new (YYTHD->mem_root) Item_row(*$5);
2982
$$= new (YYSession->mem_root) Item_row(*$5);
3386
2984
| EXISTS '(' subselect ')'
3388
$$= new (YYTHD->mem_root) Item_exists_subselect($3);
2986
$$= new (YYSession->mem_root) Item_exists_subselect($3);
3390
2988
| '{' ident expr '}' { $$= $3; }
3391
2989
| BINARY simple_expr %prec NEG
3393
$$= create_func_cast(YYTHD, $2, ITEM_CAST_CHAR, NULL, NULL,
2991
$$= create_func_cast(YYSession, $2, ITEM_CAST_CHAR, NULL, NULL,
3394
2992
&my_charset_bin);
3396
2994
| CAST_SYM '(' expr AS cast_type ')'
3399
$$= create_func_cast(YYTHD, $3, $5, lex->length, lex->dec,
2997
$$= create_func_cast(YYSession, $3, $5, lex->length, lex->dec,
3402
3000
DRIZZLE_YYABORT;
3404
3002
| CASE_SYM opt_expr when_list opt_else END
3405
{ $$= new (YYTHD->mem_root) Item_func_case(* $3, $2, $4 ); }
3003
{ $$= new (YYSession->mem_root) Item_func_case(* $3, $2, $4 ); }
3406
3004
| CONVERT_SYM '(' expr ',' cast_type ')'
3408
$$= create_func_cast(YYTHD, $3, $5, Lex->length, Lex->dec,
3006
$$= create_func_cast(YYSession, $3, $5, Lex->length, Lex->dec,
3411
3009
DRIZZLE_YYABORT;
3413
| CONVERT_SYM '(' expr USING charset_name ')'
3414
{ $$= new (YYTHD->mem_root) Item_func_conv_charset($3,$5); }
3415
3011
| DEFAULT '(' simple_ident ')'
3417
$$= new (YYTHD->mem_root) Item_default_value(Lex->current_context(),
3013
$$= new (YYSession->mem_root) Item_default_value(Lex->current_context(),
3420
3016
| VALUES '(' simple_ident_nospvar ')'
3422
$$= new (YYTHD->mem_root) Item_insert_value(Lex->current_context(),
3018
$$= new (YYSession->mem_root) Item_insert_value(Lex->current_context(),
3425
3021
| INTERVAL_SYM expr interval '+' expr %prec INTERVAL_SYM
3426
3022
/* we cannot put interval before - */
3427
{ $$= new (YYTHD->mem_root) Item_date_add_interval($5,$2,$3,0); }
3023
{ $$= new (YYSession->mem_root) Item_date_add_interval($5,$2,$3,0); }
3436
3032
function_call_keyword:
3437
3033
CHAR_SYM '(' expr_list ')'
3438
{ $$= new (YYTHD->mem_root) Item_func_char(*$3); }
3439
| CHAR_SYM '(' expr_list USING charset_name ')'
3440
{ $$= new (YYTHD->mem_root) Item_func_char(*$3, $5); }
3034
{ $$= new (YYSession->mem_root) Item_func_char(*$3); }
3441
3035
| CURRENT_USER optional_braces
3443
$$= new (YYTHD->mem_root) Item_func_current_user(Lex->current_context());
3444
Lex->set_stmt_unsafe();
3037
$$= new (YYSession->mem_root) Item_func_current_user(Lex->current_context());
3446
3039
| DATE_SYM '(' expr ')'
3447
{ $$= new (YYTHD->mem_root) Item_date_typecast($3); }
3040
{ $$= new (YYSession->mem_root) Item_date_typecast($3); }
3448
3041
| DAY_SYM '(' expr ')'
3449
{ $$= new (YYTHD->mem_root) Item_func_dayofmonth($3); }
3042
{ $$= new (YYSession->mem_root) Item_func_dayofmonth($3); }
3450
3043
| HOUR_SYM '(' expr ')'
3451
{ $$= new (YYTHD->mem_root) Item_func_hour($3); }
3044
{ $$= new (YYSession->mem_root) Item_func_hour($3); }
3452
3045
| INSERT '(' expr ',' expr ',' expr ',' expr ')'
3453
{ $$= new (YYTHD->mem_root) Item_func_insert($3,$5,$7,$9); }
3046
{ $$= new (YYSession->mem_root) Item_func_insert($3,$5,$7,$9); }
3454
3047
| INTERVAL_SYM '(' expr ',' expr ')' %prec INTERVAL_SYM
3457
List<Item> *list= new (thd->mem_root) List<Item>;
3049
Session *session= YYSession;
3050
List<Item> *list= new (session->mem_root) List<Item>;
3458
3051
list->push_front($5);
3459
3052
list->push_front($3);
3460
Item_row *item= new (thd->mem_root) Item_row(*list);
3461
$$= new (thd->mem_root) Item_func_interval(item);
3053
Item_row *item= new (session->mem_root) Item_row(*list);
3054
$$= new (session->mem_root) Item_func_interval(item);
3463
3056
| INTERVAL_SYM '(' expr ',' expr ',' expr_list ')' %prec INTERVAL_SYM
3058
Session *session= YYSession;
3466
3059
$7->push_front($5);
3467
3060
$7->push_front($3);
3468
Item_row *item= new (thd->mem_root) Item_row(*$7);
3469
$$= new (thd->mem_root) Item_func_interval(item);
3061
Item_row *item= new (session->mem_root) Item_row(*$7);
3062
$$= new (session->mem_root) Item_func_interval(item);
3471
3064
| LEFT '(' expr ',' expr ')'
3472
{ $$= new (YYTHD->mem_root) Item_func_left($3,$5); }
3065
{ $$= new (YYSession->mem_root) Item_func_left($3,$5); }
3473
3066
| MINUTE_SYM '(' expr ')'
3474
{ $$= new (YYTHD->mem_root) Item_func_minute($3); }
3067
{ $$= new (YYSession->mem_root) Item_func_minute($3); }
3475
3068
| MONTH_SYM '(' expr ')'
3476
{ $$= new (YYTHD->mem_root) Item_func_month($3); }
3069
{ $$= new (YYSession->mem_root) Item_func_month($3); }
3477
3070
| RIGHT '(' expr ',' expr ')'
3478
{ $$= new (YYTHD->mem_root) Item_func_right($3,$5); }
3071
{ $$= new (YYSession->mem_root) Item_func_right($3,$5); }
3479
3072
| SECOND_SYM '(' expr ')'
3480
{ $$= new (YYTHD->mem_root) Item_func_second($3); }
3481
| TIME_SYM '(' expr ')'
3482
{ $$= new (YYTHD->mem_root) Item_time_typecast($3); }
3483
| TIMESTAMP '(' expr ')'
3484
{ $$= new (YYTHD->mem_root) Item_datetime_typecast($3); }
3485
| TIMESTAMP '(' expr ',' expr ')'
3486
{ $$= new (YYTHD->mem_root) Item_func_add_time($3, $5, 1, 0); }
3073
{ $$= new (YYSession->mem_root) Item_func_second($3); }
3074
| TIMESTAMP_SYM '(' expr ')'
3075
{ $$= new (YYSession->mem_root) Item_datetime_typecast($3); }
3487
3076
| TRIM '(' expr ')'
3488
{ $$= new (YYTHD->mem_root) Item_func_trim($3); }
3077
{ $$= new (YYSession->mem_root) Item_func_trim($3); }
3489
3078
| TRIM '(' LEADING expr FROM expr ')'
3490
{ $$= new (YYTHD->mem_root) Item_func_ltrim($6,$4); }
3079
{ $$= new (YYSession->mem_root) Item_func_ltrim($6,$4); }
3491
3080
| TRIM '(' TRAILING expr FROM expr ')'
3492
{ $$= new (YYTHD->mem_root) Item_func_rtrim($6,$4); }
3081
{ $$= new (YYSession->mem_root) Item_func_rtrim($6,$4); }
3493
3082
| TRIM '(' BOTH expr FROM expr ')'
3494
{ $$= new (YYTHD->mem_root) Item_func_trim($6,$4); }
3083
{ $$= new (YYSession->mem_root) Item_func_trim($6,$4); }
3495
3084
| TRIM '(' LEADING FROM expr ')'
3496
{ $$= new (YYTHD->mem_root) Item_func_ltrim($5); }
3085
{ $$= new (YYSession->mem_root) Item_func_ltrim($5); }
3497
3086
| TRIM '(' TRAILING FROM expr ')'
3498
{ $$= new (YYTHD->mem_root) Item_func_rtrim($5); }
3087
{ $$= new (YYSession->mem_root) Item_func_rtrim($5); }
3499
3088
| TRIM '(' BOTH FROM expr ')'
3500
{ $$= new (YYTHD->mem_root) Item_func_trim($5); }
3089
{ $$= new (YYSession->mem_root) Item_func_trim($5); }
3501
3090
| TRIM '(' expr FROM expr ')'
3502
{ $$= new (YYTHD->mem_root) Item_func_trim($5,$3); }
3091
{ $$= new (YYSession->mem_root) Item_func_trim($5,$3); }
3505
$$= new (YYTHD->mem_root) Item_func_user();
3506
Lex->set_stmt_unsafe();
3094
$$= new (YYSession->mem_root) Item_func_user();
3508
3096
| YEAR_SYM '(' expr ')'
3509
{ $$= new (YYTHD->mem_root) Item_func_year($3); }
3097
{ $$= new (YYSession->mem_root) Item_func_year($3); }
3518
3106
The only reasons a function should be added here are:
3519
3107
- for compatibility reasons with another SQL syntax (CURDATE),
3520
- for typing reasons (GET_FORMAT)
3521
3108
Any other 'Syntaxic sugar' enhancements should be *STRONGLY*
3524
3111
function_call_nonkeyword:
3525
3112
ADDDATE_SYM '(' expr ',' expr ')'
3527
$$= new (YYTHD->mem_root) Item_date_add_interval($3, $5,
3114
$$= new (YYSession->mem_root) Item_date_add_interval($3, $5,
3528
3115
INTERVAL_DAY, 0);
3530
3117
| ADDDATE_SYM '(' expr ',' INTERVAL_SYM expr interval ')'
3531
{ $$= new (YYTHD->mem_root) Item_date_add_interval($3, $6, $7, 0); }
3118
{ $$= new (YYSession->mem_root) Item_date_add_interval($3, $6, $7, 0); }
3532
3119
| CURDATE optional_braces
3534
$$= new (YYTHD->mem_root) Item_func_curdate_local();
3536
| CURTIME optional_braces
3538
$$= new (YYTHD->mem_root) Item_func_curtime_local();
3540
| CURTIME '(' expr ')'
3542
$$= new (YYTHD->mem_root) Item_func_curtime_local($3);
3121
$$= new (YYSession->mem_root) Item_func_curdate_local();
3544
3123
| DATE_ADD_INTERVAL '(' expr ',' INTERVAL_SYM expr interval ')' %prec INTERVAL_SYM
3545
{ $$= new (YYTHD->mem_root) Item_date_add_interval($3,$6,$7,0); }
3124
{ $$= new (YYSession->mem_root) Item_date_add_interval($3,$6,$7,0); }
3546
3125
| DATE_SUB_INTERVAL '(' expr ',' INTERVAL_SYM expr interval ')' %prec INTERVAL_SYM
3547
{ $$= new (YYTHD->mem_root) Item_date_add_interval($3,$6,$7,1); }
3126
{ $$= new (YYSession->mem_root) Item_date_add_interval($3,$6,$7,1); }
3548
3127
| EXTRACT_SYM '(' interval FROM expr ')'
3549
{ $$=new (YYTHD->mem_root) Item_extract( $3, $5); }
3550
| GET_FORMAT '(' date_time_type ',' expr ')'
3551
{ $$= new (YYTHD->mem_root) Item_func_get_format($3, $5); }
3128
{ $$=new (YYSession->mem_root) Item_extract( $3, $5); }
3552
3129
| NOW_SYM optional_braces
3554
$$= new (YYTHD->mem_root) Item_func_now_local();
3131
$$= new (YYSession->mem_root) Item_func_now_local();
3556
3133
| NOW_SYM '(' expr ')'
3558
$$= new (YYTHD->mem_root) Item_func_now_local($3);
3135
$$= new (YYSession->mem_root) Item_func_now_local($3);
3560
3137
| POSITION_SYM '(' bit_expr IN_SYM expr ')'
3561
{ $$ = new (YYTHD->mem_root) Item_func_locate($5,$3); }
3138
{ $$ = new (YYSession->mem_root) Item_func_locate($5,$3); }
3562
3139
| SUBDATE_SYM '(' expr ',' expr ')'
3564
$$= new (YYTHD->mem_root) Item_date_add_interval($3, $5,
3141
$$= new (YYSession->mem_root) Item_date_add_interval($3, $5,
3565
3142
INTERVAL_DAY, 1);
3567
3144
| SUBDATE_SYM '(' expr ',' INTERVAL_SYM expr interval ')'
3568
{ $$= new (YYTHD->mem_root) Item_date_add_interval($3, $6, $7, 1); }
3145
{ $$= new (YYSession->mem_root) Item_date_add_interval($3, $6, $7, 1); }
3569
3146
| SUBSTRING '(' expr ',' expr ',' expr ')'
3570
{ $$= new (YYTHD->mem_root) Item_func_substr($3,$5,$7); }
3147
{ $$= new (YYSession->mem_root) Item_func_substr($3,$5,$7); }
3571
3148
| SUBSTRING '(' expr ',' expr ')'
3572
{ $$= new (YYTHD->mem_root) Item_func_substr($3,$5); }
3149
{ $$= new (YYSession->mem_root) Item_func_substr($3,$5); }
3573
3150
| SUBSTRING '(' expr FROM expr FOR_SYM expr ')'
3574
{ $$= new (YYTHD->mem_root) Item_func_substr($3,$5,$7); }
3151
{ $$= new (YYSession->mem_root) Item_func_substr($3,$5,$7); }
3575
3152
| SUBSTRING '(' expr FROM expr ')'
3576
{ $$= new (YYTHD->mem_root) Item_func_substr($3,$5); }
3153
{ $$= new (YYSession->mem_root) Item_func_substr($3,$5); }
3577
3154
| SYSDATE optional_braces
3579
if (global_system_variables.sysdate_is_now == 0)
3580
$$= new (YYTHD->mem_root) Item_func_sysdate_local();
3582
$$= new (YYTHD->mem_root) Item_func_now_local();
3155
{ $$= new (YYSession->mem_root) Item_func_sysdate_local(); }
3584
3156
| SYSDATE '(' expr ')'
3586
if (global_system_variables.sysdate_is_now == 0)
3587
$$= new (YYTHD->mem_root) Item_func_sysdate_local($3);
3589
$$= new (YYTHD->mem_root) Item_func_now_local($3);
3157
{ $$= new (YYSession->mem_root) Item_func_sysdate_local($3); }
3591
3158
| TIMESTAMP_ADD '(' interval_time_stamp ',' expr ',' expr ')'
3592
{ $$= new (YYTHD->mem_root) Item_date_add_interval($7,$5,$3,0); }
3159
{ $$= new (YYSession->mem_root) Item_date_add_interval($7,$5,$3,0); }
3593
3160
| TIMESTAMP_DIFF '(' interval_time_stamp ',' expr ',' expr ')'
3594
{ $$= new (YYTHD->mem_root) Item_func_timestamp_diff($5,$7,$3); }
3161
{ $$= new (YYSession->mem_root) Item_func_timestamp_diff($5,$7,$3); }
3595
3162
| UTC_DATE_SYM optional_braces
3597
$$= new (YYTHD->mem_root) Item_func_curdate_utc();
3599
| UTC_TIME_SYM optional_braces
3601
$$= new (YYTHD->mem_root) Item_func_curtime_utc();
3164
$$= new (YYSession->mem_root) Item_func_curdate_utc();
3603
3166
| UTC_TIMESTAMP_SYM optional_braces
3605
$$= new (YYTHD->mem_root) Item_func_now_utc();
3168
$$= new (YYSession->mem_root) Item_func_now_utc();
3612
3175
a dedicated rule is needed here.
3614
3177
function_call_conflict:
3615
ASCII_SYM '(' expr ')'
3616
{ $$= new (YYTHD->mem_root) Item_func_ascii($3); }
3617
| CHARSET '(' expr ')'
3618
{ $$= new (YYTHD->mem_root) Item_func_charset($3); }
3619
| COALESCE '(' expr_list ')'
3620
{ $$= new (YYTHD->mem_root) Item_func_coalesce(* $3); }
3178
COALESCE '(' expr_list ')'
3179
{ $$= new (YYSession->mem_root) Item_func_coalesce(* $3); }
3621
3180
| COLLATION_SYM '(' expr ')'
3622
{ $$= new (YYTHD->mem_root) Item_func_collation($3); }
3181
{ $$= new (YYSession->mem_root) Item_func_collation($3); }
3623
3182
| DATABASE '(' ')'
3625
$$= new (YYTHD->mem_root) Item_func_database();
3184
$$= new (YYSession->mem_root) Item_func_database();
3627
3186
| IF '(' expr ',' expr ',' expr ')'
3628
{ $$= new (YYTHD->mem_root) Item_func_if($3,$5,$7); }
3187
{ $$= new (YYSession->mem_root) Item_func_if($3,$5,$7); }
3629
3188
| MICROSECOND_SYM '(' expr ')'
3630
{ $$= new (YYTHD->mem_root) Item_func_microsecond($3); }
3189
{ $$= new (YYSession->mem_root) Item_func_microsecond($3); }
3631
3190
| MOD_SYM '(' expr ',' expr ')'
3632
{ $$ = new (YYTHD->mem_root) Item_func_mod( $3, $5); }
3191
{ $$ = new (YYSession->mem_root) Item_func_mod( $3, $5); }
3633
3192
| QUARTER_SYM '(' expr ')'
3634
{ $$ = new (YYTHD->mem_root) Item_func_quarter($3); }
3193
{ $$ = new (YYSession->mem_root) Item_func_quarter($3); }
3635
3194
| REPEAT_SYM '(' expr ',' expr ')'
3636
{ $$= new (YYTHD->mem_root) Item_func_repeat($3,$5); }
3195
{ $$= new (YYSession->mem_root) Item_func_repeat($3,$5); }
3637
3196
| REPLACE '(' expr ',' expr ',' expr ')'
3638
{ $$= new (YYTHD->mem_root) Item_func_replace($3,$5,$7); }
3197
{ $$= new (YYSession->mem_root) Item_func_replace($3,$5,$7); }
3639
3198
| REVERSE_SYM '(' expr ')'
3640
{ $$= new (YYTHD->mem_root) Item_func_reverse($3); }
3199
{ $$= new (YYSession->mem_root) Item_func_reverse($3); }
3641
3200
| TRUNCATE_SYM '(' expr ',' expr ')'
3642
{ $$= new (YYTHD->mem_root) Item_func_round($3,$5,1); }
3643
| WEEK_SYM '(' expr ')'
3646
Item *i1= new (thd->mem_root) Item_int((char*) "0",
3647
thd->variables.default_week_format,
3650
$$= new (thd->mem_root) Item_func_week($3, i1);
3652
| WEEK_SYM '(' expr ',' expr ')'
3653
{ $$= new (YYTHD->mem_root) Item_func_week($3,$5); }
3201
{ $$= new (YYSession->mem_root) Item_func_round($3,$5,1); }
3654
3202
| WEIGHT_STRING_SYM '(' expr opt_ws_levels ')'
3655
{ $$= new (YYTHD->mem_root) Item_func_weight_string($3, 0, $4); }
3203
{ $$= new (YYSession->mem_root) Item_func_weight_string($3, 0, $4); }
3656
3204
| WEIGHT_STRING_SYM '(' expr AS CHAR_SYM ws_nweights opt_ws_levels ')'
3658
$$= new (YYTHD->mem_root)
3206
$$= new (YYSession->mem_root)
3659
3207
Item_func_weight_string($3, $6, $7|MY_STRXFRM_PAD_WITH_SPACE);
3661
3209
| WEIGHT_STRING_SYM '(' expr AS BINARY ws_nweights ')'
3663
$3= create_func_char_cast(YYTHD, $3, $6, &my_charset_bin);
3664
$$= new (YYTHD->mem_root)
3211
$3= create_func_char_cast(YYSession, $3, $6, &my_charset_bin);
3212
$$= new (YYSession->mem_root)
3665
3213
Item_func_weight_string($3, $6, MY_STRXFRM_PAD_WITH_SPACE);
5229
4682
FROM table_ident
5231
if (!Select->add_table_to_list(YYTHD, $2, NULL, TL_OPTION_UPDATING,
4684
if (!Lex->current_select->add_table_to_list(YYSession, $2, NULL, TL_OPTION_UPDATING,
5232
4685
Lex->lock_option))
5233
4686
DRIZZLE_YYABORT;
5235
4688
where_clause opt_order_clause
5236
4689
delete_limit_clause {}
5238
{ mysql_init_multi_delete(Lex); }
5239
FROM join_table_list where_clause
5241
if (multi_delete_set_locks_and_link_aux_tables(Lex))
5244
| FROM table_alias_ref_list
5245
{ mysql_init_multi_delete(Lex); }
5246
USING join_table_list where_clause
5248
if (multi_delete_set_locks_and_link_aux_tables(Lex))
5255
| table_wild_list ',' table_wild_one
5261
if (!Select->add_table_to_list(YYTHD, new Table_ident($1),
5263
TL_OPTION_UPDATING | TL_OPTION_ALIAS,
5267
| ident '.' ident opt_wild
5269
if (!Select->add_table_to_list(YYTHD,
5270
new Table_ident(YYTHD, $1, $3, 0),
5272
TL_OPTION_UPDATING | TL_OPTION_ALIAS,
5283
4692
opt_delete_options:
5316
4727
lex->lock_option= TL_READ;
5317
4728
mysql_init_select(lex);
5318
4729
lex->current_select->parsing_place= SELECT_LIST;
5319
memset(&lex->create_info, 0, sizeof(lex->create_info));
5326
DATABASES wild_and_where
5329
4739
lex->sql_command= SQLCOM_SHOW_DATABASES;
5330
if (prepare_schema_table(YYTHD, lex, 0, SCH_SCHEMATA))
4741
new(std::nothrow) statement::Select(YYSession);
4742
if (lex->statement == NULL)
4744
if (prepare_schema_table(YYSession, lex, 0, "SCHEMATA"))
5331
4745
DRIZZLE_YYABORT;
5333
| opt_full TABLES opt_db wild_and_where
4747
| opt_full TABLES opt_db show_wild
5336
4750
lex->sql_command= SQLCOM_SHOW_TABLES;
4752
new(std::nothrow) statement::Select(YYSession);
4753
if (lex->statement == NULL)
5337
4755
lex->select_lex.db= $3;
5338
if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLE_NAMES))
4756
if (prepare_schema_table(YYSession, lex, 0, "TABLE_NAMES"))
5339
4757
DRIZZLE_YYABORT;
5341
| TABLE_SYM STATUS_SYM opt_db wild_and_where
4759
| TABLE_SYM STATUS_SYM opt_db show_wild
5344
4762
lex->sql_command= SQLCOM_SHOW_TABLE_STATUS;
4764
new(std::nothrow) statement::Select(YYSession);
4765
if (lex->statement == NULL)
5345
4767
lex->select_lex.db= $3;
5346
if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLES))
4768
if (prepare_schema_table(YYSession, lex, 0, "TABLES"))
5347
4769
DRIZZLE_YYABORT;
5349
| OPEN_SYM TABLES opt_db wild_and_where
4771
| OPEN_SYM TABLES opt_db show_wild
5352
4774
lex->sql_command= SQLCOM_SHOW_OPEN_TABLES;
4776
new(std::nothrow) statement::Select(YYSession);
4777
if (lex->statement == NULL)
5353
4779
lex->select_lex.db= $3;
5354
if (prepare_schema_table(YYTHD, lex, 0, SCH_OPEN_TABLES))
4780
if (prepare_schema_table(YYSession, lex, 0, "OPEN_TABLES"))
5355
4781
DRIZZLE_YYABORT;
5357
4783
| ENGINE_SYM known_storage_engines STATUS_SYM /* This should either go... well it should go */
5359
Lex->create_info.db_type= $2;
5360
4785
Lex->sql_command= SQLCOM_SHOW_ENGINE_STATUS;
4787
new(std::nothrow) statement::ShowEngineStatus(YYSession, $2);
4788
if (Lex->statement == NULL)
5362
| opt_full COLUMNS from_or_in table_ident opt_db wild_and_where
4791
| opt_full COLUMNS from_or_in table_ident opt_db show_wild
5365
4794
lex->sql_command= SQLCOM_SHOW_FIELDS;
4796
new(std::nothrow) statement::Select(YYSession);
4797
if (lex->statement == NULL)
5367
4800
$4->change_db($5);
5368
if (prepare_schema_table(YYTHD, lex, $4, SCH_COLUMNS))
4801
if (prepare_schema_table(YYSession, lex, $4, "COLUMNS"))
5369
4802
DRIZZLE_YYABORT;
5371
| master_or_binary LOGS_SYM
5373
Lex->sql_command = SQLCOM_SHOW_BINLOGS;
5377
Lex->sql_command = SQLCOM_SHOW_SLAVE_HOSTS;
5379
| BINLOG_SYM EVENTS_SYM binlog_in binlog_from
5382
lex->sql_command= SQLCOM_SHOW_BINLOG_EVENTS;
5383
} opt_limit_clause_init
5384
4804
| keys_or_index from_or_in table_ident opt_db where_clause
5387
4807
lex->sql_command= SQLCOM_SHOW_KEYS;
4808
lex->statement= new(std::nothrow) statement::Select(YYSession);
4809
if (lex->statement == NULL)
5389
4812
$3->change_db($4);
5390
if (prepare_schema_table(YYTHD, lex, $3, SCH_STATISTICS))
4813
if (prepare_schema_table(YYSession, lex, $3, "STATISTICS"))
5391
4814
DRIZZLE_YYABORT;
5393
4816
| COUNT_SYM '(' '*' ')' WARNINGS
5394
{ (void) create_select_for_variable("warning_count"); }
4818
(void) create_select_for_variable("warning_count");
4820
lex->statement= new(std::nothrow) statement::Select(YYSession);
4821
if (lex->statement == NULL)
5395
4824
| COUNT_SYM '(' '*' ')' ERRORS
5396
{ (void) create_select_for_variable("error_count"); }
4826
(void) create_select_for_variable("error_count");
4828
lex->statement= new(std::nothrow) statement::Select(YYSession);
4829
if (lex->statement == NULL)
5397
4832
| WARNINGS opt_limit_clause_init
5398
{ Lex->sql_command = SQLCOM_SHOW_WARNS;}
4834
Lex->sql_command = SQLCOM_SHOW_WARNS;
4835
Lex->statement= new(std::nothrow) statement::ShowWarnings(YYSession);
4836
if (Lex->statement == NULL)
5399
4839
| ERRORS opt_limit_clause_init
5400
{ Lex->sql_command = SQLCOM_SHOW_ERRORS;}
5401
| opt_var_type STATUS_SYM wild_and_where
4841
Lex->sql_command = SQLCOM_SHOW_ERRORS;
4842
Lex->statement= new(std::nothrow) statement::ShowErrors(YYSession);
4843
if (Lex->statement == NULL)
4846
| opt_var_type STATUS_SYM show_wild
5404
4849
lex->sql_command= SQLCOM_SHOW_STATUS;
4851
new(std::nothrow) statement::ShowStatus(YYSession,
4853
if (lex->statement == NULL)
5405
4855
lex->option_type= $1;
5406
if (prepare_schema_table(YYTHD, lex, 0, SCH_STATUS))
4856
if (prepare_schema_table(YYSession, lex, 0, "STATUS"))
5407
4857
DRIZZLE_YYABORT;
5409
4859
| opt_full PROCESSLIST_SYM
5410
{ Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;}
5411
| opt_var_type VARIABLES wild_and_where
4861
Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;
4863
new(std::nothrow) statement::ShowProcesslist(YYSession);
4864
if (Lex->statement == NULL)
4867
| opt_var_type VARIABLES show_wild
5414
4870
lex->sql_command= SQLCOM_SHOW_VARIABLES;
4872
new(std::nothrow) statement::Select(YYSession);
4873
if (lex->statement == NULL)
5415
4875
lex->option_type= $1;
5416
if (prepare_schema_table(YYTHD, lex, 0, SCH_VARIABLES))
5419
| charset wild_and_where
5422
lex->sql_command= SQLCOM_SHOW_CHARSETS;
5423
if (prepare_schema_table(YYTHD, lex, 0, SCH_CHARSETS))
5426
| COLLATION_SYM wild_and_where
5429
lex->sql_command= SQLCOM_SHOW_COLLATIONS;
5430
if (prepare_schema_table(YYTHD, lex, 0, SCH_COLLATIONS))
4876
if (prepare_schema_table(YYSession, lex, 0, "VARIABLES"))
5431
4877
DRIZZLE_YYABORT;
5433
4879
| CREATE DATABASE opt_if_not_exists ident
5435
4881
Lex->sql_command=SQLCOM_SHOW_CREATE_DB;
5436
Lex->create_info.options=$3;
4882
statement::ShowCreateSchema *statement= new(std::nothrow) statement::ShowCreateSchema(YYSession);
4883
Lex->statement= statement;
4884
if (Lex->statement == NULL)
4886
statement->create_info.options=$3;
5439
4889
| CREATE TABLE_SYM table_ident
5442
4892
lex->sql_command = SQLCOM_SHOW_CREATE;
5443
if (!lex->select_lex.add_table_to_list(YYTHD, $3, NULL,0))
5446
| MASTER_SYM STATUS_SYM
5448
Lex->sql_command = SQLCOM_SHOW_MASTER_STAT;
5452
Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
4893
lex->statement= new(std::nothrow) statement::ShowCreate(YYSession);
4894
if (lex->statement == NULL)
4896
if (!lex->select_lex.add_table_to_list(YYSession, $3, NULL,0))
5461
4901
/* empty */ { $$= 0; }
5678
Lex_input_stream *lip= thd->m_lip;
5059
Session *session= YYSession;
5060
LEX *lex= session->lex;
5680
lex->fname_start= lip->get_ptr();
5682
load_data_lock opt_local INFILE TEXT_STRING_filesystem
5685
5062
lex->sql_command= SQLCOM_LOAD;
5063
statement::Load *statement= new(std::nothrow) statement::Load(YYSession);
5064
lex->statement= statement;
5065
if (lex->statement == NULL)
5068
Lex_input_stream *lip= session->m_lip;
5069
statement->fname_start= lip->get_ptr();
5071
load_data_lock INFILE TEXT_STRING_filesystem
5686
5074
lex->lock_option= $4;
5687
lex->local_file= $5;
5688
5075
lex->duplicates= DUP_ERROR;
5689
5076
lex->ignore= 0;
5690
if (!(lex->exchange= new sql_exchange($7.str, 0, $2)))
5077
if (!(lex->exchange= new file_exchange($6.str, 0, $2)))
5691
5078
DRIZZLE_YYABORT;
5693
5080
opt_duplicate INTO
5697
Lex_input_stream *lip= thd->m_lip;
5698
lex->fname_end= lip->get_ptr();
5082
Session *session= YYSession;
5083
Lex_input_stream *lip= session->m_lip;
5084
((statement::Load *)Lex->statement)->fname_end= lip->get_ptr();
5700
5086
TABLE_SYM table_ident
5703
if (!Select->add_table_to_list(YYTHD, $13, NULL, TL_OPTION_UPDATING,
5089
if (!Lex->current_select->add_table_to_list(YYSession,
5090
$12, NULL, TL_OPTION_UPDATING,
5705
5092
DRIZZLE_YYABORT;
5706
5093
lex->field_list.empty();
5707
5094
lex->update_list.empty();
5708
5095
lex->value_list.empty();
5710
opt_load_data_charset
5711
{ Lex->exchange->cs= $15; }
5712
5097
opt_field_term opt_line_term opt_ignore_lines opt_field_or_var_spec
5713
5098
opt_load_data_set_spec
5836
5215
/* Common definitions */
5843
const CHARSET_INFO * const cs_con= thd->variables.collation_connection;
5844
const CHARSET_INFO * const cs_cli= thd->variables.character_set_client;
5845
uint repertoire= thd->lex->text_string_is_7bit &&
5846
my_charset_is_ascii_based(cs_cli) ?
5847
MY_REPERTOIRE_ASCII : MY_REPERTOIRE_UNICODE30;
5848
if (thd->charset_is_collation_connection ||
5849
(repertoire == MY_REPERTOIRE_ASCII &&
5850
my_charset_is_ascii_based(cs_con)))
5853
thd->convert_string(&tmp, cs_con, $1.str, $1.length, cs_cli);
5854
$$= new Item_string(tmp.str, tmp.length, cs_con,
5855
DERIVATION_COERCIBLE, repertoire);
5857
| UNDERSCORE_CHARSET TEXT_STRING
5859
Item_string *str= new Item_string($2.str, $2.length, $1);
5860
str->set_repertoire_from_value();
5861
str->set_cs_specified(true);
5220
Session *session= YYSession;
5221
$$ = new Item_string($1.str, $1.length, session->variables.getCollation());
5865
5223
| text_literal TEXT_STRING_literal
5867
Item_string* item= (Item_string*) $1;
5868
item->append($2.str, $2.length);
5869
if (!(item->collation.repertoire & MY_REPERTOIRE_EXTENDED))
5872
If the string has been pure ASCII so far,
5875
const CHARSET_INFO * const cs= YYTHD->variables.collation_connection;
5876
item->collation.repertoire|= my_string_repertoire(cs,
5225
((Item_string*) $1)->append($2.str, $2.length);
5884
5230
TEXT_STRING_literal
5886
$$= new (YYTHD->mem_root) String($1.str,
5232
$$= new (YYSession->mem_root) String($1.str,
5888
YYTHD->variables.collation_connection);
5234
YYSession->variables.getCollation());
5928
5274
$$ = new Item_null();
5929
YYTHD->m_lip->next_state=MY_LEX_OPERATOR_OR_IDENT;
5275
YYSession->m_lip->next_state=MY_LEX_OPERATOR_OR_IDENT;
5931
5277
| FALSE_SYM { $$= new Item_int((char*) "FALSE",0,1); }
5932
5278
| TRUE_SYM { $$= new Item_int((char*) "TRUE",1,1); }
5933
5279
| HEX_NUM { $$ = new Item_hex_string($1.str, $1.length);}
5934
5280
| BIN_NUM { $$= new Item_bin_string($1.str, $1.length); }
5935
| UNDERSCORE_CHARSET HEX_NUM
5937
Item *tmp= new Item_hex_string($2.str, $2.length);
5939
it is OK only emulate fix_fieds, because we need only
5943
tmp->quick_fix_field(), tmp->val_str((String*) 0) :
5946
Item_string *item_str=
5947
new Item_string(NULL, /* name will be set in select_item */
5948
str ? str->ptr() : "",
5949
str ? str->length() : 0,
5952
!item_str->check_well_formed_result(&item_str->str_value, true))
5957
item_str->set_repertoire_from_value();
5958
item_str->set_cs_specified(true);
5962
| UNDERSCORE_CHARSET BIN_NUM
5964
Item *tmp= new Item_bin_string($2.str, $2.length);
5966
it is OK only emulate fix_fieds, because we need only
5970
tmp->quick_fix_field(), tmp->val_str((String*) 0) :
5973
Item_string *item_str=
5974
new Item_string(NULL, /* name will be set in select_item */
5975
str ? str->ptr() : "",
5976
str ? str->length() : 0,
5979
!item_str->check_well_formed_result(&item_str->str_value, true))
5984
item_str->set_cs_specified(true);
5988
5281
| DATE_SYM text_literal { $$ = $2; }
5989
| TIME_SYM text_literal { $$ = $2; }
5990
| TIMESTAMP text_literal { $$ = $2; }
5282
| TIMESTAMP_SYM text_literal { $$ = $2; }
6080
5374
simple_ident_q:
6081
5375
ident '.' ident
5377
Session *session= YYSession;
5378
LEX *lex= session->lex;
6087
SELECT_LEX *sel= lex->current_select;
5381
Select_Lex *sel= lex->current_select;
6088
5382
if (sel->no_table_names_allowed)
6090
5384
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
6091
MYF(0), $1.str, thd->where);
5385
MYF(0), $1.str, session->where);
6093
5387
$$= (sel->parsing_place != IN_HAVING ||
6094
5388
sel->get_in_sum_expr() > 0) ?
6095
(Item*) new Item_field(Lex->current_context(), NullS, $1.str, $3.str) :
6096
(Item*) new Item_ref(Lex->current_context(), NullS, $1.str, $3.str);
5389
(Item*) new Item_field(Lex->current_context(),
5390
(const char *)NULL, $1.str, $3.str) :
5391
(Item*) new Item_ref(Lex->current_context(),
5392
(const char *)NULL, $1.str, $3.str);
6099
5395
| '.' ident '.' ident
6103
SELECT_LEX *sel= lex->current_select;
5397
Session *session= YYSession;
5398
LEX *lex= session->lex;
5399
Select_Lex *sel= lex->current_select;
6104
5400
if (sel->no_table_names_allowed)
6106
5402
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
6107
MYF(0), $2.str, thd->where);
5403
MYF(0), $2.str, session->where);
6109
5405
$$= (sel->parsing_place != IN_HAVING ||
6110
5406
sel->get_in_sum_expr() > 0) ?
6111
(Item*) new Item_field(Lex->current_context(), NullS, $2.str, $4.str) :
6112
(Item*) new Item_ref(Lex->current_context(), NullS, $2.str, $4.str);
5407
(Item*) new Item_field(Lex->current_context(), NULL, $2.str, $4.str) :
5408
(Item*) new Item_ref(Lex->current_context(),
5409
(const char *)NULL, $2.str, $4.str);
6114
5411
| ident '.' ident '.' ident
6118
SELECT_LEX *sel= lex->current_select;
5413
Session *session= YYSession;
5414
LEX *lex= session->lex;
5415
Select_Lex *sel= lex->current_select;
6119
5416
if (sel->no_table_names_allowed)
6121
5418
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
6122
MYF(0), $3.str, thd->where);
5419
MYF(0), $3.str, session->where);
6124
5421
$$= (sel->parsing_place != IN_HAVING ||
6125
5422
sel->get_in_sum_expr() > 0) ?
6126
(Item*) new Item_field(Lex->current_context(),
6127
(YYTHD->client_capabilities &
6128
CLIENT_NO_SCHEMA ? NullS : $1.str),
6130
(Item*) new Item_ref(Lex->current_context(),
6131
(YYTHD->client_capabilities &
6132
CLIENT_NO_SCHEMA ? NullS : $1.str),
5423
(Item*) new Item_field(Lex->current_context(), $1.str, $3.str,
5425
(Item*) new Item_ref(Lex->current_context(), $1.str, $3.str,
6175
5470
IDENT { $$= $1; }
6180
if (thd->charset_is_system_charset)
5473
const CHARSET_INFO * const cs= system_charset_info;
5475
uint32_t wlen= cs->cset->well_formed_len(cs, $1.str,
5477
$1.length, &dummy_error);
5478
if (wlen < $1.length)
6182
const CHARSET_INFO * const cs= system_charset_info;
6184
uint wlen= cs->cset->well_formed_len(cs, $1.str,
6186
$1.length, &dummy_error);
6187
if (wlen < $1.length)
6189
my_error(ER_INVALID_CHARACTER_STRING, MYF(0),
6190
cs->csname, $1.str + wlen);
5480
my_error(ER_INVALID_CHARACTER_STRING, MYF(0),
5481
cs->csname, $1.str + wlen);
6196
thd->convert_string(&$$, system_charset_info,
6197
$1.str, $1.length, thd->charset());
6201
5488
TEXT_STRING_sys:
6206
if (thd->charset_is_system_charset)
6209
thd->convert_string(&$$, system_charset_info,
6210
$1.str, $1.length, thd->charset());
6214
5495
TEXT_STRING_literal:
6219
if (thd->charset_is_collation_connection)
6222
thd->convert_string(&$$, thd->variables.collation_connection,
6223
$1.str, $1.length, thd->charset());
6227
5502
TEXT_STRING_filesystem:
6232
if (thd->charset_is_character_set_filesystem)
6235
thd->convert_string(&$$, thd->variables.character_set_filesystem,
6236
$1.str, $1.length, thd->charset());
6618
5842
lex->var_list.push_back(new set_var($3, $4.var, &$4.base_name, $6));
6620
| charset old_or_new_charset_name_or_default
6624
$2= $2 ? $2: global_system_variables.character_set_client;
6625
lex->var_list.push_back(new set_var_collation_client($2,thd->variables.collation_database,$2));
6627
| NAMES_SYM charset_name_or_default opt_collate
6630
$2= $2 ? $2 : global_system_variables.character_set_client;
6632
if (!my_charset_same($2,$3))
6634
my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
6635
$3->name, $2->csname);
6638
lex->var_list.push_back(new set_var_collation_client($3,$3,$3));
6642
5846
internal_variable_name:
5849
Session *session= YYSession;
6647
5851
/* We have to lookup here since local vars can shadow sysvars */
6649
5853
/* Not an SP local variable */
6650
sys_var *tmp=find_sys_var(thd, $1.str, $1.length);
5854
sys_var *tmp=find_sys_var(session, $1.str, $1.length);
6652
5856
DRIZZLE_YYABORT;
6654
5858
$$.base_name= null_lex_str;
6659
if (check_reserved_words(&$1))
6661
my_parse_error(ER(ER_SYNTAX_ERROR));
6665
sys_var *tmp=find_sys_var(YYTHD, $3.str, $3.length);
6668
if (!tmp->is_struct())
6669
my_error(ER_VARIABLE_IS_NOT_STRUCT, MYF(0), $3.str);
6676
sys_var *tmp=find_sys_var(YYTHD, $3.str, $3.length);
6679
if (!tmp->is_struct())
6680
my_error(ER_VARIABLE_IS_NOT_STRUCT, MYF(0), $3.str);
6682
$$.base_name.str= (char*) "default";
6683
$$.base_name.length= 7;
6687
5863
isolation_types:
6699
5875
| BINARY { $$=new Item_string("binary", 6, system_charset_info); }
6708
Transactional locks can be taken only if all requested locks
6709
are transactional. Initialize lex->lock_transactional as
6710
TRUE. Any non-transactional lock request turns this to FALSE.
6711
Table specific variables keep track of the locking method
6712
requested for the table. This is used to warn about a
6713
changed locking method later.
6715
Lex->lock_transactional= true;
6720
lex->sql_command= SQLCOM_LOCK_TABLES;
6726
5878
table_or_tables:
6733
| table_lock_list ',' table_lock
6737
table_ident opt_table_alias table_lock_info
6740
if (!(tlist= Select->add_table_to_list(YYTHD, $1, $2, 0,
6742
DRIZZLE_YYABORT; /* purecov: inspected */
6743
tlist->lock_timeout= $3.lock_timeout;
6744
/* Store the requested lock method for later warning. */
6745
tlist->lock_transactional= $3.lock_transactional;
6746
/* Compute the resulting lock method for all tables. */
6747
if (!$3.lock_transactional)
6748
Lex->lock_transactional= false;
6755
$$.lock_type= TL_READ_NO_INSERT;
6756
$$.lock_timeout= -1;
6757
$$.lock_transactional= false;
6761
$$.lock_type= TL_WRITE_DEFAULT;
6762
$$.lock_timeout= -1;
6763
$$.lock_transactional= false;
6765
| LOW_PRIORITY WRITE_SYM
6767
$$.lock_type= TL_WRITE_LOW_PRIORITY;
6768
$$.lock_timeout= -1;
6769
$$.lock_transactional= false;
6771
| READ_SYM LOCAL_SYM
6773
$$.lock_type= TL_READ;
6774
$$.lock_timeout= -1;
6775
$$.lock_transactional= false;
6777
| IN_SYM transactional_lock_mode MODE_SYM opt_transactional_lock_timeout
6780
$$.lock_timeout= $4;
6781
$$.lock_transactional= true;
6785
/* Use thr_lock_type here for easier fallback to non-trans locking. */
6786
transactional_lock_mode:
6787
SHARE_SYM { $$= TL_READ_NO_INSERT; }
6788
| EXCLUSIVE_SYM { $$= TL_WRITE_DEFAULT; }
6791
opt_transactional_lock_timeout:
6792
/* empty */ { $$= -1; }
6793
| NOWAIT_SYM { $$= 0; }
6794
/* | WAIT_SYM opt_lock_timeout_value { $$= $2; } */
6798
We have a timeout resolution of milliseconds. The WAIT argument is in
6799
seconds with decimal fragments for sub-second resolution. E.g. 22.5, 0.015
6801
/* opt_lock_timeout_value: */
6802
/* empty { $$= -1; } */
6803
/* | NUM { $$= (int) (atof($1.str) * 1000.0 + 0.5); } */
6809
5887
lex->sql_command= SQLCOM_UNLOCK_TABLES;
5888
lex->statement= new(std::nothrow) statement::UnlockTables(YYSession);
5889
if (lex->statement == NULL)
6811
5892
table_or_tables