36
36
#define YYINITDEPTH 100
37
37
#define YYMAXDEPTH 3200 /* Because of 64K stack */
38
38
#define Lex (YYSession->lex)
42
#include "drizzled/parser.h"
39
#include <drizzled/server_includes.h>
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/command.h>
91
#include <drizzled/command/show_status.h>
92
#include <drizzled/command/select.h>
94
using namespace drizzled;
44
100
int yylex(void *yylval, void *yysession);
46
102
#define yyoverflow(A,B,C,D,E,F) \
48
unsigned long val= *(F); \
49
if (drizzled::my_yyoverflow((B), (D), &val)) \
105
if (my_yyoverflow((B), (D), &val)) \
51
107
yyerror((char*) (A)); \
102
167
The parser will abort immediately after invoking this callback.
104
169
This function is not for use in semantic actions and is internal to
105
the parser, as it performs some pre-return cleanup.
106
In semantic actions, please use parser::my_parse_error or my_error to
170
the parser, as it performs some pre-return cleanup.
171
In semantic actions, please use my_parse_error or my_error to
107
172
push an error into the error stack and DRIZZLE_YYABORT
108
173
to abort from the parser.
111
176
static void DRIZZLEerror(const char *s)
116
} /* namespace drizzled; */
118
using namespace drizzled;
178
Session *session= current_session;
181
Restore the original LEX if it was replaced when parsing
182
a stored procedure. We must ensure that a parsing error
183
does not leave any side effects in the Session.
185
LEX::cleanup_lex_after_parse_error(session);
187
/* "parse error" changed into "syntax error" between bison 1.75 and 1.875 */
188
if (strcmp(s,"parse error") == 0 || strcmp(s,"syntax error") == 0)
189
s= ER(ER_SYNTAX_ERROR);
194
Helper to resolve the SQL:2003 Syntax exception 1) in <in predicate>.
195
See SQL:2003, Part 2, section 8.4 <in predicate>, Note 184, page 383.
196
This function returns the proper item for the SQL expression
197
<code>left [NOT] IN ( expr )</code>
198
@param session the current thread
199
@param left the in predicand
200
@param equal true for IN predicates, false for NOT IN predicates
201
@param expr first and only expression of the in value list
202
@return an expression representing the IN predicate.
204
static Item* handle_sql2003_note184_exception(Session *session,
205
Item* left, bool equal,
209
Relevant references for this issue:
210
- SQL:2003, Part 2, section 8.4 <in predicate>, page 383,
211
- SQL:2003, Part 2, section 7.2 <row value expression>, page 296,
212
- SQL:2003, Part 2, section 6.3 <value expression primary>, page 174,
213
- SQL:2003, Part 2, section 7.15 <subquery>, page 370,
214
- SQL:2003 Feature F561, "Full value expressions".
216
The exception in SQL:2003 Note 184 means:
217
Item_singlerow_subselect, which corresponds to a <scalar subquery>,
218
should be re-interpreted as an Item_in_subselect, which corresponds
219
to a <table subquery> when used inside an <in predicate>.
221
Our reading of Note 184 is reccursive, so that all:
222
- IN (( <subquery> ))
223
- IN ((( <subquery> )))
224
- IN '('^N <subquery> ')'^N
226
should be interpreted as a <table subquery>, no matter how deep in the
227
expression the <subquery> is.
232
if (expr->type() == Item::SUBSELECT_ITEM)
234
Item_subselect *expr2 = (Item_subselect*) expr;
236
if (expr2->substype() == Item_subselect::SINGLEROW_SUBS)
238
Item_singlerow_subselect *expr3 = (Item_singlerow_subselect*) expr2;
239
Select_Lex *subselect;
242
Implement the mandated change, by altering the semantic tree:
243
left IN Item_singlerow_subselect(subselect)
246
which is represented as
247
Item_in_subselect(left, subselect)
249
subselect= expr3->invalidate_and_restore_select_lex();
250
result= new (session->mem_root) Item_in_subselect(left, subselect);
253
result = negate_expression(session, result);
260
result= new (session->mem_root) Item_func_eq(left, expr);
262
result= new (session->mem_root) Item_func_ne(left, expr);
268
@brief Creates a new Select_Lex for a UNION branch.
270
Sets up and initializes a Select_Lex structure for a query once the parser
271
discovers a UNION token. The current Select_Lex is pushed on the stack and
272
the new Select_Lex becomes the current one..=
274
@lex The parser state.
276
@is_union_distinct True if the union preceding the new select statement
279
@return <code>false</code> if successful, <code>true</code> if an error was
280
reported. In the latter case parsing should stop.
282
static bool add_select_to_union_list(LEX *lex, bool is_union_distinct)
286
/* Only the last SELECT can have INTO...... */
287
my_error(ER_WRONG_USAGE, MYF(0), "UNION", "INTO");
290
if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE)
292
my_parse_error(ER(ER_SYNTAX_ERROR));
295
/* This counter shouldn't be incremented for UNION parts */
297
if (mysql_new_select(lex, 0))
299
mysql_init_select(lex);
300
lex->current_select->linkage=UNION_TYPE;
301
if (is_union_distinct) /* UNION DISTINCT - remember position */
302
lex->current_select->master_unit()->union_distinct=
308
@brief Initializes a Select_Lex for a query within parentheses (aka
311
@return false if successful, true if an error was reported. In the latter
312
case parsing should stop.
314
static bool setup_select_in_parentheses(LEX *lex)
316
Select_Lex * sel= lex->current_select;
317
if (sel->set_braces(1))
319
my_parse_error(ER(ER_SYNTAX_ERROR));
322
if (sel->linkage == UNION_TYPE &&
323
!sel->master_unit()->first_select()->braces &&
324
sel->master_unit()->first_select()->linkage ==
327
my_parse_error(ER(ER_SYNTAX_ERROR));
330
if (sel->linkage == UNION_TYPE &&
331
sel->olap != UNSPECIFIED_OLAP_TYPE &&
332
sel->master_unit()->fake_select_lex)
334
my_error(ER_WRONG_USAGE, MYF(0), "CUBE/ROLLUP", "ORDER BY");
337
/* select in braces, can't contain global parameters */
338
if (sel->master_unit()->fake_select_lex)
339
sel->master_unit()->global_parameters=
340
sel->master_unit()->fake_select_lex;
123
unsigned long ulong_num;
124
348
uint64_t ulonglong_number;
125
349
int64_t longlong_number;
126
drizzled::LEX_STRING lex_str;
127
drizzled::LEX_STRING *lex_str_ptr;
128
drizzled::LEX_SYMBOL symbol;
129
drizzled::Table_ident *table;
351
LEX_STRING *lex_str_ptr;
130
354
char *simple_string;
131
drizzled::Item *item;
132
drizzled::Item_num *item_num;
133
drizzled::List<drizzled::Item> *item_list;
134
drizzled::List<drizzled::String> *string_list;
135
drizzled::String *string;
136
drizzled::Key_part_spec *key_part;
137
const drizzled::plugin::Function *udf;
138
drizzled::TableList *table_list;
139
drizzled::enum_field_types field_val;
140
drizzled::sys_var_with_base variable;
141
drizzled::sql_var_t var_type;
142
drizzled::Key::Keytype key_type;
143
drizzled::ha_key_alg key_alg;
144
drizzled::ha_rkey_function ha_rkey_mode;
145
drizzled::enum_tx_isolation tx_isolation;
146
drizzled::Cast_target cast_type;
147
const drizzled::CHARSET_INFO *charset;
148
drizzled::thr_lock_type lock_type;
149
drizzled::interval_type interval, interval_time_st;
150
drizzled::type::timestamp_t date_time_type;
151
drizzled::Select_Lex *select_lex;
152
drizzled::chooser_compare_func_creator boolfunc2creator;
153
drizzled::st_lex *lex;
154
drizzled::index_hint_type index_hint;
155
drizzled::enum_filetype filetype;
156
drizzled::ha_build_method build_method;
157
drizzled::message::Table::ForeignKeyConstraint::ForeignKeyOption m_fk_option;
158
drizzled::execute_string_t execute_string;
357
List<Item> *item_list;
358
List<String> *string_list;
360
Key_part_spec *key_part;
361
Function_builder *udf;
362
TableList *table_list;
363
struct sys_var_with_base variable;
364
enum enum_var_type var_type;
365
Key::Keytype key_type;
366
enum ha_key_alg key_alg;
367
StorageEngine *db_type;
368
enum row_type row_type;
369
enum column_format_type column_format_type;
370
enum ha_rkey_function ha_rkey_mode;
371
enum enum_tx_isolation tx_isolation;
372
enum Cast_target cast_type;
373
enum ha_choice choice;
374
const CHARSET_INFO *charset;
375
thr_lock_type lock_type;
376
interval_type interval, interval_time_st;
377
enum enum_drizzle_timestamp_type date_time_type;
378
Select_Lex *select_lex;
379
chooser_compare_func_creator boolfunc2creator;
381
struct p_elem_val *p_elem_value;
382
enum index_hint_type index_hint;
383
enum enum_filetype filetype;
384
enum ha_build_method build_method;
385
enum Foreign_key::fk_option m_fk_option;
164
bool my_yyoverflow(short **a, YYSTYPE **b, unsigned long *yystacksize);
389
bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
169
392
%pure_parser /* We have threads */
172
Currently there are 70 shift/reduce conflicts.
394
Currently there are 88 shift/reduce conflicts.
173
395
We should not introduce new conflicts any more.
178
400
Comments for TOKENS.
828
1109
/* create a table */
831
CREATE CATALOG_SYM catalog_name
833
Lex->statement= new statement::catalog::Create(YYSession, $3);
835
| CREATE opt_table_options TABLE_SYM opt_if_not_exists table_ident
837
Lex->statement= new statement::CreateTable(YYSession, $5, $2);
839
if (not Lex->select_lex.add_table_to_list(YYSession, $5, NULL,
843
Lex->col_list.empty();
845
create_table_definition
847
Lex->current_select= &Lex->select_lex;
849
| CREATE build_method
851
Lex->statement= new statement::CreateIndex(YYSession, $2);
853
opt_unique INDEX_SYM ident key_alg ON table_ident '(' key_list ')' key_options
855
if (not Lex->current_select->add_table_to_list(Lex->session, $9,
860
parser::buildKey(Lex, $4, $6);
862
| CREATE DATABASE opt_if_not_exists schema_name
864
Lex->statement= new statement::CreateSchema(YYSession);
1112
CREATE opt_table_options TABLE_SYM opt_if_not_exists table_ident
1114
Session *session= YYSession;
1115
LEX *lex= session->lex;
1116
lex->sql_command= SQLCOM_CREATE_TABLE;
1117
if (!lex->select_lex.add_table_to_list(session, $5, NULL,
1121
lex->alter_info.reset();
1122
lex->col_list.empty();
1124
memset(&lex->create_info, 0, sizeof(lex->create_info));
1125
lex->create_info.options=$2 | $4;
1126
lex->create_info.db_type= ha_default_storage_engine(session);
1127
lex->create_info.default_table_charset= NULL;
1130
drizzled::message::Table *proto=
1131
lex->create_table_proto= new drizzled::message::Table();
1133
proto->set_name($5->table.str);
1134
if($2 & HA_LEX_CREATE_TMP_TABLE)
1135
proto->set_type(drizzled::message::Table::TEMPORARY);
1137
proto->set_type(drizzled::message::Table::STANDARD);
1140
drizzled::message::Table::StorageEngine *protoengine;
1141
protoengine= proto->mutable_engine();
1142
StorageEngine *engine= ha_default_storage_engine(session);
1144
protoengine->set_name(engine->getName());
1149
LEX *lex= YYSession->lex;
1150
lex->current_select= &lex->select_lex;
1151
assert(lex->create_info.db_type);
1153
| CREATE build_method opt_unique INDEX_SYM ident key_alg
1157
lex->sql_command= SQLCOM_CREATE_INDEX;
1158
if (!lex->current_select->add_table_to_list(lex->session, $8,
1160
TL_OPTION_UPDATING))
1162
lex->alter_info.reset();
1163
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1164
lex->alter_info.build_method= $2;
1165
lex->col_list.empty();
1168
'(' key_list ')' key_options
1172
key= new Key($3, $5, &lex->key_create_info, 0,
1174
lex->alter_info.key_list.push_back(key);
1175
lex->col_list.empty();
1177
| CREATE DATABASE opt_if_not_exists ident
1179
Lex->create_info.default_table_charset= NULL;
1180
Lex->create_info.used_fields= 0;
866
1182
opt_create_database_options
872
create_table_definition:
873
'(' field_list ')' opt_create_table_options create_select_as
875
| '(' create_select ')'
877
Lex->current_select->set_braces(1);
1185
lex->sql_command=SQLCOM_CREATE_DB;
1187
lex->create_info.options=$3;
1193
| opt_create_table_options
1197
Session *session= YYSession;
1198
LEX *lex= session->lex;
1200
lex->create_info.options|= HA_LEX_CREATE_TABLE_LIKE;
1201
if (!lex->select_lex.add_table_to_list(session, $2, NULL, 0, TL_READ))
1204
| '(' LIKE table_ident ')'
1206
Session *session= YYSession;
1207
LEX *lex= session->lex;
1209
lex->create_info.options|= HA_LEX_CREATE_TABLE_LIKE;
1210
if (!lex->select_lex.add_table_to_list(session, $3, NULL, 0, TL_READ))
1216
field_list ')' opt_create_table_options
1219
{ Lex->current_select->set_braces(1);}
880
| '(' create_like ')' opt_create_table_options
882
| create_like opt_create_table_options
884
| opt_create_table_options create_select_as
890
| opt_duplicate_as create_select
892
Lex->current_select->set_braces(0);
1225
| opt_duplicate opt_as create_select
1226
{ Lex->current_select->set_braces(0);}
895
| opt_duplicate_as '(' create_select ')'
897
Lex->current_select->set_braces(1);
1228
| opt_duplicate opt_as '(' create_select ')'
1229
{ Lex->current_select->set_braces(1);}
905
((statement::CreateTable *)(YYSession->getLex()->statement))->is_create_table_like= true;
907
if (not YYSession->getLex()->select_lex.add_table_to_list(YYSession, $2, NULL, 0, TL_READ))
919
This rule is used for both CREATE TABLE .. SELECT, AND INSERT ... SELECT
924
Lex->lock_option= TL_READ;
925
if (Lex->sql_command == SQLCOM_INSERT)
927
delete Lex->statement;
928
Lex->statement= new statement::InsertSelect(YYSession);
930
else if (Lex->sql_command == SQLCOM_REPLACE)
932
delete Lex->statement;
933
Lex->statement= new statement::ReplaceSelect(YYSession);
1237
lex->lock_option= TL_READ;
1238
if (lex->sql_command == SQLCOM_INSERT)
1239
lex->sql_command= SQLCOM_INSERT_SELECT;
1240
else if (lex->sql_command == SQLCOM_REPLACE)
1241
lex->sql_command= SQLCOM_REPLACE_SELECT;
936
1243
The following work only with the local list, the global list
937
1244
is created correctly in this case
939
Lex->current_select->table_list.save_and_clear(&Lex->save_list);
941
Lex->current_select->parsing_place= SELECT_LIST;
1246
lex->current_select->table_list.save_and_clear(&lex->save_list);
1247
mysql_init_select(lex);
1248
lex->current_select->parsing_place= SELECT_LIST;
943
1250
select_options select_item_list
1005
1313
create_table_option
1006
1314
| create_table_option create_table_options
1007
1315
| create_table_option ',' create_table_options
1009
1318
create_table_option:
1010
custom_engine_option;
1012
custom_engine_option:
1013
ENGINE_SYM equal ident_or_text
1015
Lex->table()->mutable_engine()->set_name($3.str);
1319
ENGINE_SYM opt_equal storage_engines
1321
Lex->create_info.db_type= $3;
1322
Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE;
1325
drizzled::message::Table::StorageEngine *protoengine;
1326
protoengine= Lex->create_table_proto->mutable_engine();
1328
protoengine->set_name($3->getName());
1331
| MAX_ROWS opt_equal ulonglong_num
1333
Lex->create_info.max_rows= $3;
1334
Lex->create_info.used_fields|= HA_CREATE_USED_MAX_ROWS;
1336
| MIN_ROWS opt_equal ulonglong_num
1338
Lex->create_info.min_rows= $3;
1339
Lex->create_info.used_fields|= HA_CREATE_USED_MIN_ROWS;
1341
| AVG_ROW_LENGTH opt_equal ulong_num
1343
Lex->create_info.avg_row_length=$3;
1344
Lex->create_info.used_fields|= HA_CREATE_USED_AVG_ROW_LENGTH;
1346
| BLOCK_SIZE_SYM opt_equal ulong_num
1348
Lex->create_info.block_size= $3;
1349
Lex->create_info.used_fields|= HA_CREATE_USED_BLOCK_SIZE;
1017
1351
| COMMENT_SYM opt_equal TEXT_STRING_sys
1019
Lex->table()->mutable_options()->set_comment($3.str);
1353
Lex->create_info.comment=$3;
1354
Lex->create_info.used_fields|= HA_CREATE_USED_COMMENT;
1021
1356
| AUTO_INC opt_equal ulonglong_num
1023
Lex->table()->mutable_options()->set_auto_increment_value($3);
1025
| ROW_FORMAT_SYM equal row_format_or_text
1027
parser::buildEngineOption(Lex, "ROW_FORMAT", $3);
1029
| FILE_SYM equal TEXT_STRING_sys
1031
parser::buildEngineOption(Lex, "FILE", $3);
1033
| ident_or_text equal engine_option_value
1035
parser::buildEngineOption(Lex, $1.str, $3);
1037
| ident_or_text equal ulonglong_num
1039
parser::buildEngineOption(Lex, $1.str, $3);
1358
Lex->create_info.auto_increment_value=$3;
1359
Lex->create_info.used_fields|= HA_CREATE_USED_AUTO;
1361
| PACK_KEYS_SYM opt_equal ulong_num
1365
Lex->create_info.table_options|= HA_OPTION_NO_PACK_KEYS;
1368
Lex->create_info.table_options|= HA_OPTION_PACK_KEYS;
1371
my_parse_error(ER(ER_SYNTAX_ERROR));
1374
Lex->create_info.used_fields|= HA_CREATE_USED_PACK_KEYS;
1376
| PACK_KEYS_SYM opt_equal DEFAULT
1378
Lex->create_info.table_options&=
1379
~(HA_OPTION_PACK_KEYS | HA_OPTION_NO_PACK_KEYS);
1380
Lex->create_info.used_fields|= HA_CREATE_USED_PACK_KEYS;
1382
| CHECKSUM_SYM opt_equal ulong_num
1384
Lex->create_info.table_options|= $3 ? HA_OPTION_CHECKSUM : HA_OPTION_NO_CHECKSUM;
1385
Lex->create_info.used_fields|= HA_CREATE_USED_CHECKSUM;
1387
| TABLE_CHECKSUM_SYM opt_equal ulong_num
1389
Lex->create_info.table_options|= $3 ? HA_OPTION_CHECKSUM : HA_OPTION_NO_CHECKSUM;
1390
Lex->create_info.used_fields|= HA_CREATE_USED_CHECKSUM;
1392
| PAGE_CHECKSUM_SYM opt_equal choice
1394
Lex->create_info.used_fields|= HA_CREATE_USED_PAGE_CHECKSUM;
1395
Lex->create_info.page_checksum= $3;
1397
| DELAY_KEY_WRITE_SYM opt_equal ulong_num
1399
Lex->create_info.table_options|= $3 ? HA_OPTION_DELAY_KEY_WRITE : HA_OPTION_NO_DELAY_KEY_WRITE;
1400
Lex->create_info.used_fields|= HA_CREATE_USED_DELAY_KEY_WRITE;
1402
| ROW_FORMAT_SYM opt_equal row_types
1404
Lex->create_info.row_type= $3;
1405
Lex->create_info.used_fields|= HA_CREATE_USED_ROW_FORMAT;
1406
Lex->alter_info.flags.set(ALTER_ROW_FORMAT);
1041
1408
| default_collation
1409
| DATA_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys
1411
Lex->create_info.data_file_name= $4.str;
1412
Lex->create_info.used_fields|= HA_CREATE_USED_DATADIR;
1414
| INDEX_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys
1416
Lex->create_info.index_file_name= $4.str;
1417
Lex->create_info.used_fields|= HA_CREATE_USED_INDEXDIR;
1419
| CONNECTION_SYM opt_equal TEXT_STRING_sys
1421
Lex->create_info.connect_string.str= $3.str;
1422
Lex->create_info.connect_string.length= $3.length;
1423
Lex->create_info.used_fields|= HA_CREATE_USED_CONNECTION;
1425
| KEY_BLOCK_SIZE opt_equal ulong_num
1427
Lex->create_info.used_fields|= HA_CREATE_USED_KEY_BLOCK_SIZE;
1428
Lex->create_info.key_block_size= $3;
1044
1432
default_collation:
1045
1433
opt_default COLLATE_SYM opt_equal collation_name_or_default
1047
if (not parser::buildCollation(Lex, $4))
1054
default_collation_schema:
1055
opt_default COLLATE_SYM opt_equal collation_name_or_default
1057
((statement::CreateSchema *)Lex->statement)->schema_message.set_collation($4->name);
1073
$$.str= YYSession->strmake($1.str, $1.length);
1074
$$.length= $1.length;
1435
HA_CREATE_INFO *cinfo= &Lex->create_info;
1436
if ((cinfo->used_fields & HA_CREATE_USED_DEFAULT_CHARSET) &&
1437
cinfo->default_table_charset && $4 &&
1438
!my_charset_same(cinfo->default_table_charset,$4))
1440
my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
1441
$4->name, cinfo->default_table_charset->csname);
1444
Lex->create_info.default_table_charset= $4;
1445
Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET;
1452
const std::string engine_name($1.str);
1453
StorageEngine *engine= ha_resolve_by_name(YYSession, engine_name);
1459
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str);
1465
known_storage_engines:
1468
const std::string engine_name($1.str);
1469
StorageEngine *engine;
1470
if ((engine= ha_resolve_by_name(YYSession, engine_name)))
1474
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str);
1480
column_format_types:
1481
DEFAULT { $$= COLUMN_FORMAT_TYPE_DEFAULT; }
1482
| FIXED_SYM { $$= COLUMN_FORMAT_TYPE_FIXED; }
1483
| DYNAMIC_SYM { $$= COLUMN_FORMAT_TYPE_DYNAMIC; };
1486
DEFAULT { $$= ROW_TYPE_DEFAULT; }
1487
| FIXED_SYM { $$= ROW_TYPE_FIXED; }
1488
| DYNAMIC_SYM { $$= ROW_TYPE_DYNAMIC; }
1489
| COMPRESSED_SYM { $$= ROW_TYPE_COMPRESSED; }
1490
| REDUNDANT_SYM { $$= ROW_TYPE_REDUNDANT; }
1491
| COMPACT_SYM { $$= ROW_TYPE_COMPACT; }
1492
| PAGE_SYM { $$= ROW_TYPE_PAGE; }
1078
1495
opt_select_from:
1094
1511
field_spec opt_check_constraint
1095
1512
| field_spec references
1097
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1514
Lex->col_list.empty(); /* Alloced by sql_alloc */
1102
1519
key_type opt_ident key_alg '(' key_list ')' key_options
1104
parser::buildKey(Lex, $1, $2);
1522
Key *key= new Key($1, $2, &lex->key_create_info, 0,
1524
lex->alter_info.key_list.push_back(key);
1525
lex->col_list.empty(); /* Alloced by sql_alloc */
1106
1527
| opt_constraint constraint_key_type opt_ident key_alg
1107
1528
'(' key_list ')' key_options
1109
parser::buildKey(Lex, $2, $3.str ? $3 : $1);
1531
Key *key= new Key($2, $3.str ? $3 : $1, &lex->key_create_info, 0,
1533
lex->alter_info.key_list.push_back(key);
1534
lex->col_list.empty(); /* Alloced by sql_alloc */
1111
1536
| opt_constraint FOREIGN KEY_SYM opt_ident '(' key_list ')' references
1113
parser::buildForeignKey(Lex, $1.str ? $1 : $4, $8);
1539
Key *key= new Foreign_key($4.str ? $4 : $1, lex->col_list,
1544
lex->fk_match_option);
1545
lex->alter_info.key_list.push_back(key);
1546
key= new Key(Key::MULTIPLE, $1.str ? $1 : $4,
1547
&default_key_create_info, 1,
1549
lex->alter_info.key_list.push_back(key);
1550
lex->col_list.empty(); /* Alloced by sql_alloc */
1551
/* Only used for ALTER TABLE. Ignored otherwise. */
1552
lex->alter_info.flags.set(ALTER_FOREIGN_KEY);
1115
1554
| constraint opt_check_constraint
1117
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1556
Lex->col_list.empty(); /* Alloced by sql_alloc */
1119
1558
| opt_constraint check_constraint
1121
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1560
Lex->col_list.empty(); /* Alloced by sql_alloc */
1146
parser::buildCreateFieldIdent(Lex);
1586
lex->length=lex->dec=0;
1588
lex->default_value= lex->on_update_value= 0;
1589
lex->comment=null_lex_str;
1591
lex->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
1150
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1154
Lex->field()->set_name($1.str);
1157
if (add_field_to_list(Lex->session, &$1, (enum enum_field_types) $3,
1158
Lex->length, Lex->dec, Lex->type,
1159
statement->column_format,
1160
statement->default_value, statement->on_update_value,
1161
&statement->comment,
1162
statement->change, &Lex->interval_list, Lex->charset))
1596
if (add_field_to_list(lex->session, &$1, (enum enum_field_types) $3,
1597
lex->length,lex->dec,lex->type,
1599
lex->default_value, lex->on_update_value,
1601
lex->change,&lex->interval_list,lex->charset))
1163
1602
DRIZZLE_YYABORT;
1165
Lex->setField(NULL);
1170
field_definition opt_attribute {}
1606
type opt_attribute {}
1174
int_type ignored_field_number_length opt_field_number_signed opt_zerofill
1176
$$= parser::buildIntegerColumn(Lex, $1, ($3 or $4));
1178
| real_type opt_precision
1180
assert ($1 == DRIZZLE_TYPE_DOUBLE);
1181
$$= parser::buildDoubleColumn(Lex);
1185
$$= parser::buildVarcharColumn(Lex, $3.str);
1189
$$= parser::buildVarcharColumn(Lex, "1");
1191
| varchar '(' NUM ')'
1193
$$= parser::buildVarcharColumn(Lex, $3.str);
1613
Lex->length=(char*) 0; /* use default length */
1615
| real_type opt_precision { $$=$1; }
1616
| char '(' NUM ')' opt_binary
1619
$$=DRIZZLE_TYPE_VARCHAR;
1623
Lex->length=(char*) "1";
1624
$$=DRIZZLE_TYPE_VARCHAR;
1626
| varchar '(' NUM ')' opt_binary
1629
$$= DRIZZLE_TYPE_VARCHAR;
1195
1631
| VARBINARY '(' NUM ')'
1197
$$= parser::buildVarbinaryColumn(Lex, $3.str);
1634
Lex->charset=&my_charset_bin;
1635
$$= DRIZZLE_TYPE_VARCHAR;
1201
$$=DRIZZLE_TYPE_DATE;
1204
Lex->field()->set_type(message::Table::Field::DATE);
1208
$$=DRIZZLE_TYPE_TIME;
1211
Lex->field()->set_type(message::Table::Field::TIME);
1638
{ $$=DRIZZLE_TYPE_DATE; }
1213
1639
| TIMESTAMP_SYM
1215
$$=parser::buildTimestampColumn(Lex, NULL);
1217
| TIMESTAMP_SYM '(' NUM ')'
1219
$$=parser::buildTimestampColumn(Lex, $3.str);
1640
{ $$=DRIZZLE_TYPE_TIMESTAMP; }
1223
$$=DRIZZLE_TYPE_DATETIME;
1226
Lex->field()->set_type(message::Table::Field::DATETIME);
1642
{ $$=DRIZZLE_TYPE_DATETIME; }
1230
$$= parser::buildBlobColumn(Lex);
1645
Lex->charset=&my_charset_bin;
1234
1646
$$=DRIZZLE_TYPE_BLOB;
1235
1647
Lex->length=(char*) 0; /* use default length */
1238
Lex->field()->set_type(message::Table::Field::BLOB);
1649
| TEXT_SYM opt_binary
1651
$$=DRIZZLE_TYPE_BLOB;
1652
Lex->length=(char*) 0; /* use default length */
1240
1654
| DECIMAL_SYM float_options
1242
$$= parser::buildDecimalColumn(Lex);
1655
{ $$=DRIZZLE_TYPE_NEWDECIMAL;}
1244
1656
| NUMERIC_SYM float_options
1246
$$= parser::buildDecimalColumn(Lex);
1657
{ $$=DRIZZLE_TYPE_NEWDECIMAL;}
1248
1658
| FIXED_SYM float_options
1250
$$= parser::buildDecimalColumn(Lex);
1659
{ $$=DRIZZLE_TYPE_NEWDECIMAL;}
1254
Lex->interval_list.empty();
1258
$$=DRIZZLE_TYPE_ENUM;
1261
Lex->field()->set_type(message::Table::Field::ENUM);
1265
$$= parser::buildUuidColumn(Lex);
1269
$$= parser::buildBooleanColumn(Lex);
1661
{Lex->interval_list.empty();}
1662
'(' string_list ')' opt_binary
1663
{ $$=DRIZZLE_TYPE_ENUM; }
1273
$$= parser::buildSerialColumn(Lex);
1666
$$=DRIZZLE_TYPE_LONGLONG;
1667
Lex->type|= (AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_FLAG);
1376
Lex->type&= ~ NOT_NULL_FLAG;
1380
Lex->type|= NOT_NULL_FLAG;
1384
Lex->field()->mutable_constraints()->set_is_notnull(true);
1387
| DEFAULT now_or_signed_literal
1389
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1391
statement->default_value=$2;
1392
statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1394
| ON UPDATE_SYM NOW_SYM optional_braces
1396
((statement::AlterTable *)Lex->statement)->on_update_value= new Item_func_now_local();
1400
parser::buildAutoOnColumn(Lex);
1735
NULL_SYM { Lex->type&= ~ NOT_NULL_FLAG; }
1736
| COLUMN_FORMAT_SYM column_format_types
1738
Lex->column_format= $2;
1739
Lex->alter_info.flags.set(ALTER_COLUMN_FORMAT);
1741
| not NULL_SYM { Lex->type|= NOT_NULL_FLAG; }
1742
| DEFAULT now_or_signed_literal
1744
Lex->default_value=$2;
1745
Lex->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1747
| ON UPDATE_SYM NOW_SYM optional_braces
1748
{ Lex->on_update_value= new Item_func_now_local(); }
1749
| AUTO_INC { Lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG; }
1402
1750
| SERIAL_SYM DEFAULT VALUE_SYM
1404
(void)parser::buildSerialColumn(Lex);
1753
lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_FLAG;
1754
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1406
1756
| opt_primary KEY_SYM
1408
parser::buildPrimaryOnColumn(Lex);
1759
lex->type|= PRI_KEY_FLAG | NOT_NULL_FLAG;
1760
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1412
parser::buildKeyOnColumn(Lex);
1765
lex->type|= UNIQUE_FLAG;
1766
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1414
1768
| UNIQUE_SYM KEY_SYM
1416
parser::buildKeyOnColumn(Lex);
1418
| COMMENT_SYM TEXT_STRING_sys
1420
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1421
statement->comment= $2;
1424
Lex->field()->set_comment($2.str);
1771
lex->type|= UNIQUE_KEY_FLAG;
1772
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1774
| COMMENT_SYM TEXT_STRING_sys { Lex->comment= $2; }
1426
1775
| COLLATE_SYM collation_name
1428
1777
if (Lex->charset && !my_charset_same(Lex->charset,$2))
1493
1916
{ Lex->ref_list.push_back(new Key_part_spec($3, 0)); }
1496
Lex->ref_list.empty();
1497
Lex->ref_list.push_back(new Key_part_spec($1, 0));
1920
lex->ref_list.empty();
1921
lex->ref_list.push_back(new Key_part_spec($1, 0));
1501
1925
opt_match_clause:
1503
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_UNDEFINED; }
1927
{ Lex->fk_match_option= Foreign_key::FK_MATCH_UNDEF; }
1505
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_FULL; }
1929
{ Lex->fk_match_option= Foreign_key::FK_MATCH_FULL; }
1506
1930
| MATCH PARTIAL
1507
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_PARTIAL; }
1931
{ Lex->fk_match_option= Foreign_key::FK_MATCH_PARTIAL; }
1508
1932
| MATCH SIMPLE_SYM
1509
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_SIMPLE; }
1933
{ Lex->fk_match_option= Foreign_key::FK_MATCH_SIMPLE; }
1512
1936
opt_on_update_delete:
1515
((statement::CreateTable *)Lex->statement)->fk_update_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
1516
((statement::CreateTable *)Lex->statement)->fk_delete_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
1940
lex->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
1941
lex->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
1518
1943
| ON UPDATE_SYM delete_option
1520
((statement::CreateTable *)Lex->statement)->fk_update_opt= $3;
1521
((statement::CreateTable *)Lex->statement)->fk_delete_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
1946
lex->fk_update_opt= $3;
1947
lex->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
1523
1949
| ON DELETE_SYM delete_option
1525
((statement::CreateTable *)Lex->statement)->fk_update_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
1526
((statement::CreateTable *)Lex->statement)->fk_delete_opt= $3;
1952
lex->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
1953
lex->fk_delete_opt= $3;
1528
1955
| ON UPDATE_SYM delete_option
1529
1956
ON DELETE_SYM delete_option
1531
((statement::CreateTable *)Lex->statement)->fk_update_opt= $3;
1532
((statement::CreateTable *)Lex->statement)->fk_delete_opt= $6;
1959
lex->fk_update_opt= $3;
1960
lex->fk_delete_opt= $6;
1534
1962
| ON DELETE_SYM delete_option
1535
1963
ON UPDATE_SYM delete_option
1537
((statement::CreateTable *)Lex->statement)->fk_update_opt= $6;
1538
((statement::CreateTable *)Lex->statement)->fk_delete_opt= $3;
1966
lex->fk_update_opt= $6;
1967
lex->fk_delete_opt= $3;
1543
RESTRICT { $$= drizzled::message::Table::ForeignKeyConstraint::OPTION_RESTRICT; }
1544
| CASCADE { $$= drizzled::message::Table::ForeignKeyConstraint::OPTION_CASCADE; }
1545
| SET_SYM NULL_SYM { $$= drizzled::message::Table::ForeignKeyConstraint::OPTION_SET_NULL; }
1546
| NO_SYM ACTION { $$= drizzled::message::Table::ForeignKeyConstraint::OPTION_NO_ACTION; }
1547
| SET_SYM DEFAULT { $$= drizzled::message::Table::ForeignKeyConstraint::OPTION_SET_DEFAULT; }
1972
RESTRICT { $$= Foreign_key::FK_OPTION_RESTRICT; }
1973
| CASCADE { $$= Foreign_key::FK_OPTION_CASCADE; }
1974
| SET NULL_SYM { $$= Foreign_key::FK_OPTION_SET_NULL; }
1975
| NO_SYM ACTION { $$= Foreign_key::FK_OPTION_NO_ACTION; }
1976
| SET DEFAULT { $$= Foreign_key::FK_OPTION_DEFAULT; }
1661
ALTER_SYM build_method opt_ignore TABLE_SYM table_ident
2091
ALTER build_method opt_ignore TABLE_SYM table_ident
1663
statement::AlterTable *statement= new statement::AlterTable(YYSession, $5, $2);
1664
Lex->statement= statement;
1665
Lex->duplicates= DUP_ERROR;
1666
if (not Lex->select_lex.add_table_to_list(YYSession, $5, NULL, TL_OPTION_UPDATING))
2093
Session *session= YYSession;
2094
LEX *lex= session->lex;
2096
lex->name.length= 0;
2097
lex->sql_command= SQLCOM_ALTER_TABLE;
2098
lex->duplicates= DUP_ERROR;
2099
if (!lex->select_lex.add_table_to_list(session, $5, NULL,
2100
TL_OPTION_UPDATING))
1668
2101
DRIZZLE_YYABORT;
2102
lex->alter_info.reset();
2103
lex->col_list.empty();
2104
lex->select_lex.init_order();
2106
((TableList*) lex->select_lex.table_list.first)->db;
2107
memset(&lex->create_info, 0, sizeof(lex->create_info));
2108
lex->create_info.db_type= 0;
2109
lex->create_info.default_table_charset= NULL;
2110
lex->create_info.row_type= ROW_TYPE_NOT_USED;
2111
lex->alter_info.reset();
2112
lex->alter_info.build_method= $2;
1671
Lex->col_list.empty();
1672
Lex->select_lex.init_order();
1673
Lex->select_lex.db= const_cast<char *>(((TableList*) Lex->select_lex.table_list.first)->getSchemaName());
2114
lex->create_table_proto= new drizzled::message::Table();
1677
| ALTER_SYM DATABASE schema_name
2118
| ALTER DATABASE ident_or_empty
1679
Lex->statement= new statement::AlterSchema(YYSession);
2120
Lex->create_info.default_table_charset= NULL;
2121
Lex->create_info.used_fields= 0;
1681
default_collation_schema
2123
create_database_options
1684
if (Lex->name.str == NULL && Lex->copy_db_to(&Lex->name.str, &Lex->name.length))
2126
lex->sql_command=SQLCOM_ALTER_DB;
2128
if (lex->name.str == NULL &&
2129
lex->copy_db_to(&lex->name.str, &lex->name.length))
1685
2130
DRIZZLE_YYABORT;
2135
/* empty */ { $$.str= 0; $$.length= 0; }
1689
2139
alter_commands:
1691
| DISCARD TABLESPACE
1693
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1694
statement->alter_info.tablespace_op= DISCARD_TABLESPACE;
1698
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1699
statement->alter_info.tablespace_op= IMPORT_TABLESPACE;
2141
| DISCARD TABLESPACE { Lex->alter_info.tablespace_op= DISCARD_TABLESPACE; }
2142
| IMPORT TABLESPACE { Lex->alter_info.tablespace_op= IMPORT_TABLESPACE; }
1727
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1729
statement->change=0;
1730
statement->alter_info.flags.set(ALTER_ADD_COLUMN);
2171
lex->alter_info.flags.set(ALTER_ADD_COLUMN);
1734
2175
alter_list_item:
1735
2176
add_column column_def opt_place { }
1738
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1740
statement->alter_info.flags.set(ALTER_ADD_INDEX);
2179
Lex->alter_info.flags.set(ALTER_ADD_INDEX);
1742
2181
| add_column '(' field_list ')'
1744
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1746
statement->alter_info.flags.set(ALTER_ADD_COLUMN);
1747
statement->alter_info.flags.set(ALTER_ADD_INDEX);
2183
Lex->alter_info.flags.set(ALTER_ADD_COLUMN);
2184
Lex->alter_info.flags.set(ALTER_ADD_INDEX);
1749
| CHANGE_SYM opt_column field_ident
2186
| CHANGE opt_column field_ident
1751
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1752
statement->change= $3.str;
1753
statement->alter_info.flags.set(ALTER_CHANGE_COLUMN);
2189
lex->change= $3.str;
2190
lex->alter_info.flags.set(ALTER_CHANGE_COLUMN);
1755
2192
field_spec opt_place
1756
2193
| MODIFY_SYM opt_column field_ident
1758
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1759
Lex->length= Lex->dec=0;
1761
statement->default_value= statement->on_update_value= 0;
1762
statement->comment= null_lex_str;
1764
statement->alter_info.flags.set(ALTER_CHANGE_COLUMN);
1765
statement->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
1767
Lex->setField(NULL);
2196
lex->length=lex->dec=0; lex->type=0;
2197
lex->default_value= lex->on_update_value= 0;
2198
lex->comment=null_lex_str;
2200
lex->alter_info.flags.set(ALTER_CHANGE_COLUMN);
2201
lex->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
1771
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1773
if (add_field_to_list(Lex->session,&$3,
2206
if (add_field_to_list(lex->session,&$3,
1774
2207
(enum enum_field_types) $5,
1775
Lex->length, Lex->dec, Lex->type,
1776
statement->column_format,
1777
statement->default_value,
1778
statement->on_update_value,
1779
&statement->comment,
1780
$3.str, &Lex->interval_list, Lex->charset))
2208
lex->length,lex->dec,lex->type,
2210
lex->default_value, lex->on_update_value,
2212
$3.str, &lex->interval_list, lex->charset))
1781
2213
DRIZZLE_YYABORT;
1784
2216
| DROP opt_column field_ident
1786
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1788
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::COLUMN, $3.str));
1789
statement->alter_info.flags.set(ALTER_DROP_COLUMN);
2219
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::COLUMN,
2221
lex->alter_info.flags.set(ALTER_DROP_COLUMN);
1791
2223
| DROP FOREIGN KEY_SYM opt_ident
1793
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1794
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::FOREIGN_KEY,
1796
statement->alter_info.flags.set(ALTER_DROP_INDEX);
1797
statement->alter_info.flags.set(ALTER_FOREIGN_KEY);
2225
Lex->alter_info.flags.set(ALTER_DROP_INDEX);
2226
Lex->alter_info.flags.set(ALTER_FOREIGN_KEY);
1799
2228
| DROP PRIMARY_SYM KEY_SYM
1801
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1803
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY,
2231
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::KEY,
1805
statement->alter_info.flags.set(ALTER_DROP_INDEX);
2233
lex->alter_info.flags.set(ALTER_DROP_INDEX);
1807
2235
| DROP key_or_index field_ident
1809
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1811
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY,
1813
statement->alter_info.flags.set(ALTER_DROP_INDEX);
2238
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::KEY,
2240
lex->alter_info.flags.set(ALTER_DROP_INDEX);
1815
2242
| DISABLE_SYM KEYS
1817
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1819
statement->alter_info.keys_onoff= DISABLE;
1820
statement->alter_info.flags.set(ALTER_KEYS_ONOFF);
2245
lex->alter_info.keys_onoff= DISABLE;
2246
lex->alter_info.flags.set(ALTER_KEYS_ONOFF);
1822
2248
| ENABLE_SYM KEYS
1824
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1826
statement->alter_info.keys_onoff= ENABLE;
1827
statement->alter_info.flags.set(ALTER_KEYS_ONOFF);
1829
| ALTER_SYM opt_column field_ident SET_SYM DEFAULT signed_literal
1831
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1833
statement->alter_info.alter_list.push_back(new AlterColumn($3.str,$6));
1834
statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1836
| ALTER_SYM opt_column field_ident DROP DEFAULT
1838
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1840
statement->alter_info.alter_list.push_back(new AlterColumn($3.str, (Item*) 0));
1841
statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
2251
lex->alter_info.keys_onoff= ENABLE;
2252
lex->alter_info.flags.set(ALTER_KEYS_ONOFF);
2254
| ALTER opt_column field_ident SET DEFAULT signed_literal
2257
lex->alter_info.alter_list.push_back(new Alter_column($3.str,$6));
2258
lex->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
2260
| ALTER opt_column field_ident DROP DEFAULT
2263
lex->alter_info.alter_list.push_back(new Alter_column($3.str,
2265
lex->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1843
2267
| RENAME opt_to table_ident
1845
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1848
Lex->select_lex.db=$3->db.str;
1849
if (Lex->select_lex.db == NULL &&
1850
Lex->copy_db_to(&Lex->select_lex.db, &dummy))
2271
lex->select_lex.db=$3->db.str;
2272
if (lex->select_lex.db == NULL &&
2273
lex->copy_db_to(&lex->select_lex.db, &dummy))
1852
2275
DRIZZLE_YYABORT;
1855
if (check_table_name($3->table.str,$3->table.length))
2277
if (check_table_name($3->table.str,$3->table.length) || ($3->db.str && check_db_name(&$3->db)))
1857
2279
my_error(ER_WRONG_TABLE_NAME, MYF(0), $3->table.str);
1858
2280
DRIZZLE_YYABORT;
1861
Lex->name= $3->table;
1862
statement->alter_info.flags.set(ALTER_RENAME);
2282
lex->name= $3->table;
2283
lex->alter_info.flags.set(ALTER_RENAME);
1864
2285
| CONVERT_SYM TO_SYM collation_name_or_default
1866
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1868
statement->create_info().table_charset=
1869
statement->create_info().default_table_charset= $3;
1870
statement->create_info().used_fields|= (HA_CREATE_USED_CHARSET |
2288
lex->create_info.table_charset=
2289
lex->create_info.default_table_charset= $3;
2290
lex->create_info.used_fields|= (HA_CREATE_USED_CHARSET |
1871
2291
HA_CREATE_USED_DEFAULT_CHARSET);
1872
statement->alter_info.flags.set(ALTER_CONVERT);
2292
lex->alter_info.flags.set(ALTER_CONVERT);
1874
2294
| create_table_options_space_separated
1876
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1878
statement->alter_info.flags.set(ALTER_OPTIONS);
2297
lex->alter_info.flags.set(ALTER_OPTIONS);
1882
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1884
statement->alter_info.flags.set(ALTER_FORCE);
2301
Lex->alter_info.flags.set(ALTER_FORCE);
1886
2303
| alter_order_clause
1888
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1890
statement->alter_info.flags.set(ALTER_ORDER);
2306
lex->alter_info.flags.set(ALTER_ORDER);
2078
2565
| select_option
2081
select_option_distinct_or_all:
2084
Lex->current_select->options|= SELECT_DISTINCT;
2086
if (Lex->current_select->options & SELECT_DISTINCT && Lex->current_select->options & SELECT_ALL)
2088
my_error(ER_WRONG_USAGE, MYF(0), "ALL", "DISTINCT");
2094
Lex->current_select->options|= SELECT_ALL;
2096
if (Lex->current_select->options & SELECT_DISTINCT && Lex->current_select->options & SELECT_ALL)
2098
my_error(ER_WRONG_USAGE, MYF(0), "ALL", "DISTINCT");
2104
select_option_small_or_big:
2107
Lex->current_select->options|= SELECT_SMALL_RESULT;
2109
if (Lex->current_select->options & SELECT_SMALL_RESULT && Lex->current_select->options & SELECT_BIG_RESULT)
2111
my_error(ER_WRONG_USAGE, MYF(0), "SELECT_SMALL_RESULT", "SELECT_SMALL_RESULT");
2117
Lex->current_select->options|= SELECT_BIG_RESULT;
2119
if (Lex->current_select->options & SELECT_SMALL_RESULT && Lex->current_select->options & SELECT_BIG_RESULT)
2121
my_error(ER_WRONG_USAGE, MYF(0), "SELECT_SMALL_RESULT", "SELECT_SMALL_RESULT");
2129
2569
STRAIGHT_JOIN { Lex->current_select->options|= SELECT_STRAIGHT_JOIN; }
2570
| DISTINCT { Lex->current_select->options|= SELECT_DISTINCT; }
2571
| SQL_SMALL_RESULT { Lex->current_select->options|= SELECT_SMALL_RESULT; }
2572
| SQL_BIG_RESULT { Lex->current_select->options|= SELECT_BIG_RESULT; }
2130
2573
| SQL_BUFFER_RESULT
2132
if (check_simple_select(YYSession))
2575
if (check_simple_select())
2133
2576
DRIZZLE_YYABORT;
2134
2577
Lex->current_select->options|= OPTION_BUFFER_RESULT;
2136
| select_option_small_or_big
2138
| select_option_distinct_or_all
2140
2579
| SQL_CALC_FOUND_ROWS
2142
if (check_simple_select(YYSession))
2581
if (check_simple_select())
2143
2582
DRIZZLE_YYABORT;
2144
2583
Lex->current_select->options|= OPTION_FOUND_ROWS;
2585
| ALL { Lex->current_select->options|= SELECT_ALL; }
2148
2588
select_lock_type:
2150
2590
| FOR_SYM UPDATE_SYM
2152
Lex->current_select->set_lock_for_tables(TL_WRITE);
2593
lex->current_select->set_lock_for_tables(TL_WRITE);
2154
2595
| LOCK_SYM IN_SYM SHARE_SYM MODE_SYM
2156
Lex->current_select->
2598
lex->current_select->
2157
2599
set_lock_for_tables(TL_READ_WITH_SHARED_LOCKS);
2682
3092
| SUBDATE_SYM '(' expr ',' INTERVAL_SYM expr interval ')'
2683
3093
{ $$= new (YYSession->mem_root) Item_date_add_interval($3, $6, $7, 1); }
2684
3094
| SUBSTRING '(' expr ',' expr ',' expr ')'
2686
std::string reverse_str("substr");
2687
List<Item> *args= new (YYSession->mem_root) List<Item>;
2688
args->push_back($3);
2689
args->push_back($5);
2690
args->push_back($7);
2691
if (! ($$= parser::reserved_keyword_function(YYSession, reverse_str, args)))
3095
{ $$= new (YYSession->mem_root) Item_func_substr($3,$5,$7); }
2696
3096
| SUBSTRING '(' expr ',' expr ')'
2698
std::string reverse_str("substr");
2699
List<Item> *args= new (YYSession->mem_root) List<Item>;
2700
args->push_back($3);
2701
args->push_back($5);
2702
if (! ($$= parser::reserved_keyword_function(YYSession, reverse_str, args)))
3097
{ $$= new (YYSession->mem_root) Item_func_substr($3,$5); }
2707
3098
| SUBSTRING '(' expr FROM expr FOR_SYM expr ')'
2709
std::string reverse_str("substr");
2710
List<Item> *args= new (YYSession->mem_root) List<Item>;
2711
args->push_back($3);
2712
args->push_back($5);
2713
args->push_back($7);
2714
if (! ($$= parser::reserved_keyword_function(YYSession, reverse_str, args)))
3099
{ $$= new (YYSession->mem_root) Item_func_substr($3,$5,$7); }
2719
3100
| SUBSTRING '(' expr FROM expr ')'
2721
std::string reverse_str("substr");
2722
List<Item> *args= new (YYSession->mem_root) List<Item>;
2723
args->push_back($3);
2724
args->push_back($5);
2725
if (! ($$= parser::reserved_keyword_function(YYSession, reverse_str, args)))
3101
{ $$= new (YYSession->mem_root) Item_func_substr($3,$5); }
2730
3102
| SYSDATE optional_braces
2732
$$= new (YYSession->mem_root) Item_func_sysdate_local();
2733
Lex->setCacheable(false);
3103
{ $$= new (YYSession->mem_root) Item_func_sysdate_local(); }
2735
3104
| SYSDATE '(' expr ')'
2737
$$= new (YYSession->mem_root) Item_func_sysdate_local($3);
2738
Lex->setCacheable(false);
3105
{ $$= new (YYSession->mem_root) Item_func_sysdate_local($3); }
2740
3106
| TIMESTAMP_ADD '(' interval_time_stamp ',' expr ',' expr ')'
2741
3107
{ $$= new (YYSession->mem_root) Item_date_add_interval($7,$5,$3,0); }
2742
3108
| TIMESTAMP_DIFF '(' interval_time_stamp ',' expr ',' expr ')'
2819
3140
| QUARTER_SYM '(' expr ')'
2820
3141
{ $$ = new (YYSession->mem_root) Item_func_quarter($3); }
2821
3142
| REPEAT_SYM '(' expr ',' expr ')'
2822
{ $$= new (YYSession->mem_root) Item_func_repeat(*YYSession, $3, $5); }
3143
{ $$= new (YYSession->mem_root) Item_func_repeat($3,$5); }
2823
3144
| REPLACE '(' expr ',' expr ',' expr ')'
2824
{ $$= new (YYSession->mem_root) Item_func_replace(*YYSession, $3, $5, $7); }
3145
{ $$= new (YYSession->mem_root) Item_func_replace($3,$5,$7); }
3146
| REVERSE_SYM '(' expr ')'
3147
{ $$= new (YYSession->mem_root) Item_func_reverse($3); }
2825
3148
| TRUNCATE_SYM '(' expr ',' expr ')'
2826
3149
{ $$= new (YYSession->mem_root) Item_func_round($3,$5,1); }
2827
| WAIT_SYM '(' expr ')'
3150
| WEIGHT_STRING_SYM '(' expr opt_ws_levels ')'
3151
{ $$= new (YYSession->mem_root) Item_func_weight_string($3, 0, $4); }
3152
| WEIGHT_STRING_SYM '(' expr AS CHAR_SYM ws_nweights opt_ws_levels ')'
2829
std::string wait_str("wait");
2830
List<Item> *args= new (YYSession->mem_root) List<Item>;
2831
args->push_back($3);
2832
if (! ($$= parser::reserved_keyword_function(YYSession, wait_str, args)))
3154
$$= new (YYSession->mem_root)
3155
Item_func_weight_string($3, $6, $7|MY_STRXFRM_PAD_WITH_SPACE);
2839
if (! ($$= parser::reserved_keyword_function(YYSession, "uuid", NULL)))
2843
Lex->setCacheable(false);
2845
| WAIT_SYM '(' expr ',' expr ')'
2847
std::string wait_str("wait");
2848
List<Item> *args= new (YYSession->mem_root) List<Item>;
2849
args->push_back($3);
2850
args->push_back($5);
2851
if (! ($$= parser::reserved_keyword_function(YYSession, wait_str, args)))
3157
| WEIGHT_STRING_SYM '(' expr AS BINARY ws_nweights ')'
3159
$3= create_func_char_cast(YYSession, $3, $6, &my_charset_bin);
3160
$$= new (YYSession->mem_root)
3161
Item_func_weight_string($3, $6, MY_STRXFRM_PAD_WITH_SPACE);
3907
NUM { int error; $$= (unsigned long) internal::my_strtoll10($1.str, (char**) 0, &error); }
3908
| HEX_NUM { $$= (unsigned long) strtol($1.str, (char**) 0, 16); }
3909
| LONG_NUM { int error; $$= (unsigned long) internal::my_strtoll10($1.str, (char**) 0, &error); }
3910
| ULONGLONG_NUM { int error; $$= (unsigned long) internal::my_strtoll10($1.str, (char**) 0, &error); }
3911
| DECIMAL_NUM { int error; $$= (unsigned long) internal::my_strtoll10($1.str, (char**) 0, &error); }
3912
| FLOAT_NUM { int error; $$= (unsigned long) internal::my_strtoll10($1.str, (char**) 0, &error); }
4227
NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4228
| HEX_NUM { $$= (ulong) strtol($1.str, (char**) 0, 16); }
4229
| LONG_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4230
| ULONGLONG_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4231
| DECIMAL_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4232
| FLOAT_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4236
NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4237
| HEX_NUM { $$= (ulong) strtol($1.str, (char**) 0, 16); }
4238
| LONG_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4239
| ULONGLONG_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
3916
NUM { int error; $$= (uint64_t) internal::my_strtoll10($1.str, (char**) 0, &error); }
3917
| ULONGLONG_NUM { int error; $$= (uint64_t) internal::my_strtoll10($1.str, (char**) 0, &error); }
3918
| LONG_NUM { int error; $$= (uint64_t) internal::my_strtoll10($1.str, (char**) 0, &error); }
3919
| DECIMAL_NUM { int error; $$= (uint64_t) internal::my_strtoll10($1.str, (char**) 0, &error); }
3920
| FLOAT_NUM { int error; $$= (uint64_t) internal::my_strtoll10($1.str, (char**) 0, &error); }
4244
NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4245
| ULONGLONG_NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4246
| LONG_NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4247
| DECIMAL_NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4248
| FLOAT_NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4253
{ my_parse_error(ER(ER_ONLY_INTEGERS_ALLOWED)); }
4262
ulong_num { $$= $1 != 0 ? HA_CHOICE_YES : HA_CHOICE_NO; }
4263
| DEFAULT { $$= HA_CHOICE_UNDEF; }
3923
4266
select_var_list_init:
3925
if (not Lex->describe && (not (Lex->result= new select_dumpvar())))
4269
if (!lex->describe && (!(lex->result= new select_dumpvar())))
3926
4270
DRIZZLE_YYABORT;
3928
4272
select_var_list
3990
DROP CATALOG_SYM catalog_name
3992
Lex->statement= new statement::catalog::Drop(YYSession, $3);
3994
| DROP opt_temporary table_or_tables if_exists table_list
3996
statement::DropTable *statement= new statement::DropTable(YYSession);
3997
Lex->statement= statement;
3998
statement->drop_temporary= $2;
3999
statement->drop_if_exists= $4;
4331
DROP opt_temporary table_or_tables if_exists table_list
4334
lex->sql_command = SQLCOM_DROP_TABLE;
4335
lex->drop_temporary= $2;
4336
lex->drop_if_exists= $4;
4001
4338
| DROP build_method INDEX_SYM ident ON table_ident {}
4003
statement::DropIndex *statement= new statement::DropIndex(YYSession);
4004
Lex->statement= statement;
4005
statement->alter_info.flags.set(ALTER_DROP_INDEX);
4006
statement->alter_info.build_method= $2;
4007
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY, $4.str));
4008
if (not Lex->current_select->add_table_to_list(Lex->session, $6, NULL,
4009
TL_OPTION_UPDATING))
4341
lex->sql_command= SQLCOM_DROP_INDEX;
4342
lex->alter_info.reset();
4343
lex->alter_info.flags.set(ALTER_DROP_INDEX);
4344
lex->alter_info.build_method= $2;
4345
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::KEY,
4347
if (!lex->current_select->add_table_to_list(lex->session, $6, NULL,
4348
TL_OPTION_UPDATING))
4010
4349
DRIZZLE_YYABORT;
4012
| DROP DATABASE if_exists schema_name
4351
| DROP DATABASE if_exists ident
4014
statement::DropSchema *statement= new statement::DropSchema(YYSession);
4015
Lex->statement= statement;
4016
statement->drop_if_exists=$3;
4354
lex->sql_command= SQLCOM_DROP_DB;
4355
lex->drop_if_exists=$3;
4023
4360
| table_list ',' table_name
4346
Lex->lock_option= TL_READ;
4348
Lex->current_select->parsing_place= SELECT_LIST;
4656
lex->lock_option= TL_READ;
4657
mysql_init_select(lex);
4658
lex->current_select->parsing_place= SELECT_LIST;
4659
memset(&lex->create_info, 0, sizeof(lex->create_info));
4356
4666
DATABASES show_wild
4358
if (not show::buildScemas(YYSession))
4362
| TABLES opt_db show_wild
4364
if (not show::buildTables(YYSession, $2))
4367
/* SHOW TEMPORARY TABLES */
4368
| TEMPORARY_SYM TABLES show_wild
4370
if (not show::buildTemporaryTables(YYSession))
4373
/* SHOW TABLE STATUS */
4669
lex->sql_command= SQLCOM_SHOW_DATABASES;
4671
new(std::nothrow) command::Select(SQLCOM_SHOW_DATABASES,
4673
if (lex->command == NULL)
4675
if (prepare_schema_table(YYSession, lex, 0, "SCHEMATA"))
4678
| opt_full TABLES opt_db show_wild
4681
lex->sql_command= SQLCOM_SHOW_TABLES;
4683
new(std::nothrow) command::Select(SQLCOM_SHOW_TABLES,
4685
if (lex->command == NULL)
4687
lex->select_lex.db= $3;
4688
if (prepare_schema_table(YYSession, lex, 0, "TABLE_NAMES"))
4374
4691
| TABLE_SYM STATUS_SYM opt_db show_wild
4376
if (not show::buildTableStatus(YYSession, $3))
4379
/* SHOW COLUMNS FROM table_name */
4380
| COLUMNS from_or_in table_ident opt_db show_wild
4382
if (not show::buildColumns(YYSession, $4, $3))
4385
/* SHOW INDEXES from table */
4694
lex->sql_command= SQLCOM_SHOW_TABLE_STATUS;
4696
new(std::nothrow) command::Select(SQLCOM_SHOW_TABLE_STATUS,
4698
if (lex->command == NULL)
4700
lex->select_lex.db= $3;
4701
if (prepare_schema_table(YYSession, lex, 0, "TABLES"))
4704
| OPEN_SYM TABLES opt_db show_wild
4707
lex->sql_command= SQLCOM_SHOW_OPEN_TABLES;
4709
new(std::nothrow) command::Select(SQLCOM_SHOW_OPEN_TABLES,
4711
if (lex->command == NULL)
4713
lex->select_lex.db= $3;
4714
if (prepare_schema_table(YYSession, lex, 0, "OPEN_TABLES"))
4717
| ENGINE_SYM known_storage_engines STATUS_SYM /* This should either go... well it should go */
4719
Lex->show_engine= $2;
4720
Lex->sql_command= SQLCOM_SHOW_ENGINE_STATUS;
4722
| opt_full COLUMNS from_or_in table_ident opt_db show_wild
4725
lex->sql_command= SQLCOM_SHOW_FIELDS;
4727
new(std::nothrow) command::Select(SQLCOM_SHOW_FIELDS, YYSession);
4728
if (lex->command == NULL)
4732
if (prepare_schema_table(YYSession, lex, $4, "COLUMNS"))
4386
4735
| keys_or_index from_or_in table_ident opt_db where_clause
4388
if (not show::buildIndex(YYSession, $4, $3))
4738
lex->sql_command= SQLCOM_SHOW_KEYS;
4739
lex->command= new(std::nothrow) command::Select(SQLCOM_SHOW_KEYS,
4741
if (lex->command == NULL)
4745
if (prepare_schema_table(YYSession, lex, $3, "STATISTICS"))
4391
4748
| COUNT_SYM '(' '*' ')' WARNINGS
4393
show::buildSelectWarning(YYSession);
4750
(void) create_select_for_variable("warning_count");
4752
lex->command= new(std::nothrow) command::Select(SQLCOM_SELECT,
4754
if (lex->command == NULL)
4395
4757
| COUNT_SYM '(' '*' ')' ERRORS
4397
show::buildSelectError(YYSession);
4759
(void) create_select_for_variable("error_count");
4761
lex->command= new(std::nothrow) command::Select(SQLCOM_SELECT,
4763
if (lex->command == NULL)
4399
4766
| WARNINGS opt_limit_clause_init
4401
show::buildWarnings(YYSession);
4767
{ Lex->sql_command = SQLCOM_SHOW_WARNS;}
4403
4768
| ERRORS opt_limit_clause_init
4405
show::buildErrors(YYSession);
4769
{ Lex->sql_command = SQLCOM_SHOW_ERRORS;}
4407
4770
| opt_var_type STATUS_SYM show_wild
4409
if (not show::buildStatus(YYSession, $1))
4412
| engine_option_value STATUS_SYM
4414
if (not show::buildEngineStatus(YYSession, $1))
4773
lex->sql_command= SQLCOM_SHOW_STATUS;
4775
new(std::nothrow) command::ShowStatus(SQLCOM_SHOW_STATUS,
4778
if (lex->command == NULL)
4780
lex->option_type= $1;
4781
if (prepare_schema_table(YYSession, lex, 0, "STATUS"))
4784
| opt_full PROCESSLIST_SYM
4785
{ Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;}
4786
| opt_var_type VARIABLES show_wild
4789
lex->sql_command= SQLCOM_SHOW_VARIABLES;
4791
new(std::nothrow) command::Select(SQLCOM_SHOW_VARIABLES,
4793
if (lex->command == NULL)
4795
lex->option_type= $1;
4796
if (prepare_schema_table(YYSession, lex, 0, "VARIABLES"))
4799
| CREATE DATABASE opt_if_not_exists ident
4801
Lex->sql_command=SQLCOM_SHOW_CREATE_DB;
4802
Lex->create_info.options=$3;
4417
4805
| CREATE TABLE_SYM table_ident
4419
if (not show::buildCreateTable(YYSession, $3))
4424
if (not show::buildProcesslist(YYSession))
4427
| opt_var_type VARIABLES show_wild
4429
if (not show::buildVariables(YYSession, $1))
4432
| CREATE DATABASE opt_if_not_exists ident
4434
if (not show::buildCreateSchema(YYSession, $4))
4808
lex->sql_command = SQLCOM_SHOW_CREATE;
4809
if (!lex->select_lex.add_table_to_list(YYSession, $3, NULL,0))
4435
4810
DRIZZLE_YYABORT;
4872
5277
simple_ident_q:
4873
5278
ident '.' ident
4875
$$= parser::buildIdent(Lex, NULL_LEX_STRING, $1, $3);
5280
Session *session= YYSession;
5281
LEX *lex= session->lex;
5284
Select_Lex *sel= lex->current_select;
5285
if (sel->no_table_names_allowed)
5287
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5288
MYF(0), $1.str, session->where);
5290
$$= (sel->parsing_place != IN_HAVING ||
5291
sel->get_in_sum_expr() > 0) ?
5292
(Item*) new Item_field(Lex->current_context(),
5293
(const char *)NULL, $1.str, $3.str) :
5294
(Item*) new Item_ref(Lex->current_context(),
5295
(const char *)NULL, $1.str, $3.str);
4877
5298
| '.' ident '.' ident
4879
$$= parser::buildIdent(Lex, NULL_LEX_STRING, $2, $4);
5300
Session *session= YYSession;
5301
LEX *lex= session->lex;
5302
Select_Lex *sel= lex->current_select;
5303
if (sel->no_table_names_allowed)
5305
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5306
MYF(0), $2.str, session->where);
5308
$$= (sel->parsing_place != IN_HAVING ||
5309
sel->get_in_sum_expr() > 0) ?
5310
(Item*) new Item_field(Lex->current_context(), NULL, $2.str, $4.str) :
5311
(Item*) new Item_ref(Lex->current_context(),
5312
(const char *)NULL, $2.str, $4.str);
4881
5314
| ident '.' ident '.' ident
4883
$$= parser::buildIdent(Lex, $1, $3, $5);
5316
Session *session= YYSession;
5317
LEX *lex= session->lex;
5318
Select_Lex *sel= lex->current_select;
5319
if (sel->no_table_names_allowed)
5321
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5322
MYF(0), $3.str, session->where);
5324
$$= (sel->parsing_place != IN_HAVING ||
5325
sel->get_in_sum_expr() > 0) ?
5326
(Item*) new Item_field(Lex->current_context(),
5327
(YYSession->client_capabilities &
5328
CLIENT_NO_SCHEMA ? NULL : $1.str),
5330
(Item*) new Item_ref(Lex->current_context(),
5331
(YYSession->client_capabilities &
5332
CLIENT_NO_SCHEMA ? NULL : $1.str),
4892
5339
| ident '.' ident '.' ident
4894
if (not parser::checkFieldIdent(Lex, $1, $3))
5342
reinterpret_cast<TableList*>(Lex->current_select->table_list.first);
5343
if (my_strcasecmp(table_alias_charset, $1.str, table->db))
5345
my_error(ER_WRONG_DB_NAME, MYF(0), $1.str);
5348
if (my_strcasecmp(table_alias_charset, $3.str,
5351
my_error(ER_WRONG_TABLE_NAME, MYF(0), $3.str);
4899
5356
| ident '.' ident
4901
if (not parser::checkFieldIdent(Lex, NULL_LEX_STRING, $1))
5359
reinterpret_cast<TableList*>(Lex->current_select->table_list.first);
5360
if (my_strcasecmp(table_alias_charset, $1.str, table->alias))
5362
my_error(ER_WRONG_TABLE_NAME, MYF(0), $1.str);
4902
5363
DRIZZLE_YYABORT;
5367
| '.' ident { $$=$2;} /* For Delphi */
4915
$$= new Table_ident($1);
4917
| schema_name '.' ident
4919
$$=new Table_ident($1,$3);
4923
$$= new Table_ident($2);
5371
ident { $$=new Table_ident($1); }
5372
| ident '.' ident { $$=new Table_ident(YYSession, $1,$3,0);}
5373
| '.' ident { $$=new Table_ident($2);} /* For Delphi */
4942
5380
const CHARSET_INFO * const cs= system_charset_info;
5221
5729
sys_option_value:
5222
5730
option_type internal_variable_name equal set_expr_or_default
5225
5735
{ /* System variable */
5228
Lex->option_type= $1;
5230
Lex->var_list.push_back(SetVarPtr(new set_var(Lex->option_type, $2.var, &$2.base_name, $4)));
5737
lex->option_type= $1;
5738
lex->var_list.push_back(new set_var(lex->option_type, $2.var,
5739
&$2.base_name, $4));
5233
5742
| option_type TRANSACTION_SYM ISOLATION LEVEL_SYM isolation_types
5235
Lex->option_type= $1;
5236
Lex->var_list.push_back(SetVarPtr(new set_var(Lex->option_type,
5237
find_sys_var("tx_isolation"),
5239
new Item_int((int32_t)
5745
lex->option_type= $1;
5746
lex->var_list.push_back(new set_var(lex->option_type,
5747
find_sys_var(YYSession, "tx_isolation"),
5749
new Item_int((int32_t) $5)));
5245
'@' user_variable_ident equal expr
5754
'@' ident_or_text equal expr
5247
Lex->var_list.push_back(SetVarPtr(new set_var_user(new Item_func_set_user_var($2,$4))));
5756
Lex->var_list.push_back(new set_var_user(new Item_func_set_user_var($2,$4)));
5249
5758
| '@' '@' opt_var_ident_type internal_variable_name equal set_expr_or_default
5251
Lex->var_list.push_back(SetVarPtr(new set_var($3, $4.var, &$4.base_name, $6)));
5255
user_variable_ident:
5256
internal_variable_ident { $$=$1;}
5257
| TEXT_STRING_sys { $$=$1;}
5258
| LEX_HOSTNAME { $$=$1;}
5261
internal_variable_ident:
5262
keyword_exception_for_variable
5264
$$.str= YYSession->strmake($1.str, $1.length);
5265
$$.length= $1.length;
5267
| IDENT_sys { $$=$1; }
5761
lex->var_list.push_back(new set_var($3, $4.var, &$4.base_name, $6));
5270
5765
internal_variable_name:
5271
internal_variable_ident
5768
Session *session= YYSession;
5273
5770
/* We have to lookup here since local vars can shadow sysvars */
5275
5772
/* Not an SP local variable */
5276
sys_var *tmp= find_sys_var(std::string($1.str, $1.length));
5773
sys_var *tmp=find_sys_var(session, $1.str, $1.length);
5278
5775
DRIZZLE_YYABORT;