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/statement.h>
91
#include <drizzled/statement/checksum.h>
92
#include <drizzled/statement/commit.h>
93
#include <drizzled/statement/delete.h>
94
#include <drizzled/statement/empty_query.h>
95
#include <drizzled/statement/load.h>
96
#include <drizzled/statement/rollback.h>
97
#include <drizzled/statement/select.h>
98
#include <drizzled/statement/show_create.h>
99
#include <drizzled/statement/show_create_schema.h>
100
#include <drizzled/statement/show_engine_status.h>
101
#include <drizzled/statement/show_errors.h>
102
#include <drizzled/statement/show_processlist.h>
103
#include <drizzled/statement/show_status.h>
104
#include <drizzled/statement/show_warnings.h>
105
#include <drizzled/statement/unlock_tables.h>
107
using namespace drizzled;
44
113
int yylex(void *yylval, void *yysession);
46
115
#define yyoverflow(A,B,C,D,E,F) \
48
unsigned long val= *(F); \
49
if (drizzled::my_yyoverflow((B), (D), &val)) \
118
if (my_yyoverflow((B), (D), &val)) \
51
120
yyerror((char*) (A)); \
102
180
The parser will abort immediately after invoking this callback.
104
182
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
183
the parser, as it performs some pre-return cleanup.
184
In semantic actions, please use my_parse_error or my_error to
107
185
push an error into the error stack and DRIZZLE_YYABORT
108
186
to abort from the parser.
111
189
static void DRIZZLEerror(const char *s)
116
} /* namespace drizzled; */
118
using namespace drizzled;
191
Session *session= current_session;
194
Restore the original LEX if it was replaced when parsing
195
a stored procedure. We must ensure that a parsing error
196
does not leave any side effects in the Session.
198
LEX::cleanup_lex_after_parse_error(session);
200
/* "parse error" changed into "syntax error" between bison 1.75 and 1.875 */
201
if (strcmp(s,"parse error") == 0 || strcmp(s,"syntax error") == 0)
202
s= ER(ER_SYNTAX_ERROR);
207
Helper to resolve the SQL:2003 Syntax exception 1) in <in predicate>.
208
See SQL:2003, Part 2, section 8.4 <in predicate>, Note 184, page 383.
209
This function returns the proper item for the SQL expression
210
<code>left [NOT] IN ( expr )</code>
211
@param session the current thread
212
@param left the in predicand
213
@param equal true for IN predicates, false for NOT IN predicates
214
@param expr first and only expression of the in value list
215
@return an expression representing the IN predicate.
217
static Item* handle_sql2003_note184_exception(Session *session,
218
Item* left, bool equal,
222
Relevant references for this issue:
223
- SQL:2003, Part 2, section 8.4 <in predicate>, page 383,
224
- SQL:2003, Part 2, section 7.2 <row value expression>, page 296,
225
- SQL:2003, Part 2, section 6.3 <value expression primary>, page 174,
226
- SQL:2003, Part 2, section 7.15 <subquery>, page 370,
227
- SQL:2003 Feature F561, "Full value expressions".
229
The exception in SQL:2003 Note 184 means:
230
Item_singlerow_subselect, which corresponds to a <scalar subquery>,
231
should be re-interpreted as an Item_in_subselect, which corresponds
232
to a <table subquery> when used inside an <in predicate>.
234
Our reading of Note 184 is reccursive, so that all:
235
- IN (( <subquery> ))
236
- IN ((( <subquery> )))
237
- IN '('^N <subquery> ')'^N
239
should be interpreted as a <table subquery>, no matter how deep in the
240
expression the <subquery> is.
245
if (expr->type() == Item::SUBSELECT_ITEM)
247
Item_subselect *expr2 = (Item_subselect*) expr;
249
if (expr2->substype() == Item_subselect::SINGLEROW_SUBS)
251
Item_singlerow_subselect *expr3 = (Item_singlerow_subselect*) expr2;
252
Select_Lex *subselect;
255
Implement the mandated change, by altering the semantic tree:
256
left IN Item_singlerow_subselect(subselect)
259
which is represented as
260
Item_in_subselect(left, subselect)
262
subselect= expr3->invalidate_and_restore_select_lex();
263
result= new (session->mem_root) Item_in_subselect(left, subselect);
266
result = negate_expression(session, result);
273
result= new (session->mem_root) Item_func_eq(left, expr);
275
result= new (session->mem_root) Item_func_ne(left, expr);
281
@brief Creates a new Select_Lex for a UNION branch.
283
Sets up and initializes a Select_Lex structure for a query once the parser
284
discovers a UNION token. The current Select_Lex is pushed on the stack and
285
the new Select_Lex becomes the current one..=
287
@lex The parser state.
289
@is_union_distinct True if the union preceding the new select statement
292
@return <code>false</code> if successful, <code>true</code> if an error was
293
reported. In the latter case parsing should stop.
295
static bool add_select_to_union_list(LEX *lex, bool is_union_distinct)
299
/* Only the last SELECT can have INTO...... */
300
my_error(ER_WRONG_USAGE, MYF(0), "UNION", "INTO");
303
if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE)
305
my_parse_error(ER(ER_SYNTAX_ERROR));
308
/* This counter shouldn't be incremented for UNION parts */
310
if (mysql_new_select(lex, 0))
312
mysql_init_select(lex);
313
lex->current_select->linkage=UNION_TYPE;
314
if (is_union_distinct) /* UNION DISTINCT - remember position */
315
lex->current_select->master_unit()->union_distinct=
321
@brief Initializes a Select_Lex for a query within parentheses (aka
324
@return false if successful, true if an error was reported. In the latter
325
case parsing should stop.
327
static bool setup_select_in_parentheses(LEX *lex)
329
Select_Lex * sel= lex->current_select;
330
if (sel->set_braces(1))
332
my_parse_error(ER(ER_SYNTAX_ERROR));
335
if (sel->linkage == UNION_TYPE &&
336
!sel->master_unit()->first_select()->braces &&
337
sel->master_unit()->first_select()->linkage ==
340
my_parse_error(ER(ER_SYNTAX_ERROR));
343
if (sel->linkage == UNION_TYPE &&
344
sel->olap != UNSPECIFIED_OLAP_TYPE &&
345
sel->master_unit()->fake_select_lex)
347
my_error(ER_WRONG_USAGE, MYF(0), "CUBE/ROLLUP", "ORDER BY");
350
/* select in braces, can't contain global parameters */
351
if (sel->master_unit()->fake_select_lex)
352
sel->master_unit()->global_parameters=
353
sel->master_unit()->fake_select_lex;
123
unsigned long ulong_num;
124
361
uint64_t ulonglong_number;
125
362
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;
364
LEX_STRING *lex_str_ptr;
130
367
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;
370
List<Item> *item_list;
371
List<String> *string_list;
373
Key_part_spec *key_part;
374
Function_builder *udf;
375
TableList *table_list;
376
struct sys_var_with_base variable;
377
enum enum_var_type var_type;
378
Key::Keytype key_type;
379
enum ha_key_alg key_alg;
380
StorageEngine *db_type;
381
enum row_type row_type;
382
enum column_format_type column_format_type;
383
enum ha_rkey_function ha_rkey_mode;
384
enum enum_tx_isolation tx_isolation;
385
enum Cast_target cast_type;
386
enum ha_choice choice;
387
const CHARSET_INFO *charset;
388
thr_lock_type lock_type;
389
interval_type interval, interval_time_st;
390
enum enum_drizzle_timestamp_type date_time_type;
391
Select_Lex *select_lex;
392
chooser_compare_func_creator boolfunc2creator;
394
struct p_elem_val *p_elem_value;
395
enum index_hint_type index_hint;
396
enum enum_filetype filetype;
397
enum ha_build_method build_method;
398
enum Foreign_key::fk_option m_fk_option;
164
bool my_yyoverflow(short **a, YYSTYPE **b, unsigned long *yystacksize);
402
bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
169
405
%pure_parser /* We have threads */
172
Currently there are 70 shift/reduce conflicts.
407
Currently there are 88 shift/reduce conflicts.
173
408
We should not introduce new conflicts any more.
178
413
Comments for TOKENS.
828
1125
/* 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);
1128
CREATE opt_table_options TABLE_SYM opt_if_not_exists table_ident
1130
Session *session= YYSession;
1131
LEX *lex= session->lex;
1132
lex->sql_command= SQLCOM_CREATE_TABLE;
1133
if (!lex->select_lex.add_table_to_list(session, $5, NULL,
1137
lex->alter_info.reset();
1138
lex->col_list.empty();
1140
memset(&lex->create_info, 0, sizeof(lex->create_info));
1141
lex->create_info.options=$2 | $4;
1142
lex->create_info.db_type= ha_default_storage_engine(session);
1143
lex->create_info.default_table_charset= NULL;
1146
drizzled::message::Table *proto=
1147
lex->create_table_proto= new drizzled::message::Table();
1149
proto->set_name($5->table.str);
1150
if($2 & HA_LEX_CREATE_TMP_TABLE)
1151
proto->set_type(drizzled::message::Table::TEMPORARY);
1153
proto->set_type(drizzled::message::Table::STANDARD);
1156
drizzled::message::Table::StorageEngine *protoengine;
1157
protoengine= proto->mutable_engine();
1158
StorageEngine *engine= ha_default_storage_engine(session);
1160
protoengine->set_name(engine->getName());
1165
LEX *lex= YYSession->lex;
1166
lex->current_select= &lex->select_lex;
1167
assert(lex->create_info.db_type);
1169
| CREATE build_method opt_unique INDEX_SYM ident key_alg
1173
lex->sql_command= SQLCOM_CREATE_INDEX;
1174
if (!lex->current_select->add_table_to_list(lex->session, $8,
1176
TL_OPTION_UPDATING))
1178
lex->alter_info.reset();
1179
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1180
lex->alter_info.build_method= $2;
1181
lex->col_list.empty();
1184
'(' key_list ')' key_options
1188
key= new Key($3, $5, &lex->key_create_info, 0,
1190
lex->alter_info.key_list.push_back(key);
1191
lex->col_list.empty();
1193
| CREATE DATABASE opt_if_not_exists ident
1195
Lex->create_info.default_table_charset= NULL;
1196
Lex->create_info.used_fields= 0;
866
1198
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);
1201
lex->sql_command=SQLCOM_CREATE_DB;
1203
lex->create_info.options=$3;
1209
| opt_create_table_options
1213
Session *session= YYSession;
1214
LEX *lex= session->lex;
1216
lex->create_info.options|= HA_LEX_CREATE_TABLE_LIKE;
1217
if (!lex->select_lex.add_table_to_list(session, $2, NULL, 0, TL_READ))
1220
| '(' LIKE table_ident ')'
1222
Session *session= YYSession;
1223
LEX *lex= session->lex;
1225
lex->create_info.options|= HA_LEX_CREATE_TABLE_LIKE;
1226
if (!lex->select_lex.add_table_to_list(session, $3, NULL, 0, TL_READ))
1232
field_list ')' opt_create_table_options
1235
{ 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);
1241
| opt_duplicate opt_as create_select
1242
{ Lex->current_select->set_braces(0);}
895
| opt_duplicate_as '(' create_select ')'
897
Lex->current_select->set_braces(1);
1244
| opt_duplicate opt_as '(' create_select ')'
1245
{ 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);
1253
lex->lock_option= TL_READ;
1254
if (lex->sql_command == SQLCOM_INSERT)
1255
lex->sql_command= SQLCOM_INSERT_SELECT;
1256
else if (lex->sql_command == SQLCOM_REPLACE)
1257
lex->sql_command= SQLCOM_REPLACE_SELECT;
936
1259
The following work only with the local list, the global list
937
1260
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;
1262
lex->current_select->table_list.save_and_clear(&lex->save_list);
1263
mysql_init_select(lex);
1264
lex->current_select->parsing_place= SELECT_LIST;
943
1266
select_options select_item_list
1005
1329
create_table_option
1006
1330
| create_table_option create_table_options
1007
1331
| create_table_option ',' create_table_options
1009
1334
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);
1335
ENGINE_SYM opt_equal storage_engines
1337
Lex->create_info.db_type= $3;
1338
Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE;
1341
drizzled::message::Table::StorageEngine *protoengine;
1342
protoengine= Lex->create_table_proto->mutable_engine();
1344
protoengine->set_name($3->getName());
1347
| MAX_ROWS opt_equal ulonglong_num
1349
Lex->create_info.max_rows= $3;
1350
Lex->create_info.used_fields|= HA_CREATE_USED_MAX_ROWS;
1352
| MIN_ROWS opt_equal ulonglong_num
1354
Lex->create_info.min_rows= $3;
1355
Lex->create_info.used_fields|= HA_CREATE_USED_MIN_ROWS;
1357
| AVG_ROW_LENGTH opt_equal ulong_num
1359
Lex->create_info.avg_row_length=$3;
1360
Lex->create_info.used_fields|= HA_CREATE_USED_AVG_ROW_LENGTH;
1362
| BLOCK_SIZE_SYM opt_equal ulong_num
1364
Lex->create_info.block_size= $3;
1365
Lex->create_info.used_fields|= HA_CREATE_USED_BLOCK_SIZE;
1017
1367
| COMMENT_SYM opt_equal TEXT_STRING_sys
1019
Lex->table()->mutable_options()->set_comment($3.str);
1369
Lex->create_info.comment=$3;
1370
Lex->create_info.used_fields|= HA_CREATE_USED_COMMENT;
1021
1372
| 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);
1374
Lex->create_info.auto_increment_value=$3;
1375
Lex->create_info.used_fields|= HA_CREATE_USED_AUTO;
1377
| PACK_KEYS_SYM opt_equal ulong_num
1381
Lex->create_info.table_options|= HA_OPTION_NO_PACK_KEYS;
1384
Lex->create_info.table_options|= HA_OPTION_PACK_KEYS;
1387
my_parse_error(ER(ER_SYNTAX_ERROR));
1390
Lex->create_info.used_fields|= HA_CREATE_USED_PACK_KEYS;
1392
| PACK_KEYS_SYM opt_equal DEFAULT
1394
Lex->create_info.table_options&=
1395
~(HA_OPTION_PACK_KEYS | HA_OPTION_NO_PACK_KEYS);
1396
Lex->create_info.used_fields|= HA_CREATE_USED_PACK_KEYS;
1398
| CHECKSUM_SYM opt_equal ulong_num
1400
Lex->create_info.table_options|= $3 ? HA_OPTION_CHECKSUM : HA_OPTION_NO_CHECKSUM;
1401
Lex->create_info.used_fields|= HA_CREATE_USED_CHECKSUM;
1403
| TABLE_CHECKSUM_SYM opt_equal ulong_num
1405
Lex->create_info.table_options|= $3 ? HA_OPTION_CHECKSUM : HA_OPTION_NO_CHECKSUM;
1406
Lex->create_info.used_fields|= HA_CREATE_USED_CHECKSUM;
1408
| PAGE_CHECKSUM_SYM opt_equal choice
1410
Lex->create_info.used_fields|= HA_CREATE_USED_PAGE_CHECKSUM;
1411
Lex->create_info.page_checksum= $3;
1413
| ROW_FORMAT_SYM opt_equal row_types
1415
Lex->create_info.row_type= $3;
1416
Lex->create_info.used_fields|= HA_CREATE_USED_ROW_FORMAT;
1417
Lex->alter_info.flags.set(ALTER_ROW_FORMAT);
1041
1419
| default_collation
1420
| DATA_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys
1422
Lex->create_info.data_file_name= $4.str;
1423
Lex->create_info.used_fields|= HA_CREATE_USED_DATADIR;
1425
| INDEX_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys
1427
Lex->create_info.index_file_name= $4.str;
1428
Lex->create_info.used_fields|= HA_CREATE_USED_INDEXDIR;
1430
| CONNECTION_SYM opt_equal TEXT_STRING_sys
1432
Lex->create_info.connect_string.str= $3.str;
1433
Lex->create_info.connect_string.length= $3.length;
1434
Lex->create_info.used_fields|= HA_CREATE_USED_CONNECTION;
1436
| KEY_BLOCK_SIZE opt_equal ulong_num
1438
Lex->create_info.used_fields|= HA_CREATE_USED_KEY_BLOCK_SIZE;
1439
Lex->create_info.key_block_size= $3;
1044
1443
default_collation:
1045
1444
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;
1446
HA_CREATE_INFO *cinfo= &Lex->create_info;
1447
if ((cinfo->used_fields & HA_CREATE_USED_DEFAULT_CHARSET) &&
1448
cinfo->default_table_charset && $4 &&
1449
!my_charset_same(cinfo->default_table_charset,$4))
1451
my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
1452
$4->name, cinfo->default_table_charset->csname);
1455
Lex->create_info.default_table_charset= $4;
1456
Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET;
1463
const std::string engine_name($1.str);
1464
StorageEngine *engine= ha_resolve_by_name(YYSession, engine_name);
1470
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str);
1476
known_storage_engines:
1479
const std::string engine_name($1.str);
1480
StorageEngine *engine;
1481
if ((engine= ha_resolve_by_name(YYSession, engine_name)))
1485
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str);
1491
column_format_types:
1492
DEFAULT { $$= COLUMN_FORMAT_TYPE_DEFAULT; }
1493
| FIXED_SYM { $$= COLUMN_FORMAT_TYPE_FIXED; }
1494
| DYNAMIC_SYM { $$= COLUMN_FORMAT_TYPE_DYNAMIC; };
1497
DEFAULT { $$= ROW_TYPE_DEFAULT; }
1498
| FIXED_SYM { $$= ROW_TYPE_FIXED; }
1499
| DYNAMIC_SYM { $$= ROW_TYPE_DYNAMIC; }
1500
| COMPRESSED_SYM { $$= ROW_TYPE_COMPRESSED; }
1501
| REDUNDANT_SYM { $$= ROW_TYPE_REDUNDANT; }
1502
| COMPACT_SYM { $$= ROW_TYPE_COMPACT; }
1503
| PAGE_SYM { $$= ROW_TYPE_PAGE; }
1078
1506
opt_select_from:
1094
1522
field_spec opt_check_constraint
1095
1523
| field_spec references
1097
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1525
Lex->col_list.empty(); /* Alloced by sql_alloc */
1102
1530
key_type opt_ident key_alg '(' key_list ')' key_options
1104
parser::buildKey(Lex, $1, $2);
1533
Key *key= new Key($1, $2, &lex->key_create_info, 0,
1535
lex->alter_info.key_list.push_back(key);
1536
lex->col_list.empty(); /* Alloced by sql_alloc */
1106
1538
| opt_constraint constraint_key_type opt_ident key_alg
1107
1539
'(' key_list ')' key_options
1109
parser::buildKey(Lex, $2, $3.str ? $3 : $1);
1542
Key *key= new Key($2, $3.str ? $3 : $1, &lex->key_create_info, 0,
1544
lex->alter_info.key_list.push_back(key);
1545
lex->col_list.empty(); /* Alloced by sql_alloc */
1111
1547
| opt_constraint FOREIGN KEY_SYM opt_ident '(' key_list ')' references
1113
parser::buildForeignKey(Lex, $1.str ? $1 : $4, $8);
1550
Key *key= new Foreign_key($4.str ? $4 : $1, lex->col_list,
1555
lex->fk_match_option);
1556
lex->alter_info.key_list.push_back(key);
1557
key= new Key(Key::MULTIPLE, $1.str ? $1 : $4,
1558
&default_key_create_info, 1,
1560
lex->alter_info.key_list.push_back(key);
1561
lex->col_list.empty(); /* Alloced by sql_alloc */
1562
/* Only used for ALTER TABLE. Ignored otherwise. */
1563
lex->alter_info.flags.set(ALTER_FOREIGN_KEY);
1115
1565
| constraint opt_check_constraint
1117
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1567
Lex->col_list.empty(); /* Alloced by sql_alloc */
1119
1569
| opt_constraint check_constraint
1121
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1571
Lex->col_list.empty(); /* Alloced by sql_alloc */
1146
parser::buildCreateFieldIdent(Lex);
1597
lex->length=lex->dec=0;
1599
lex->default_value= lex->on_update_value= 0;
1600
lex->comment=null_lex_str;
1602
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))
1607
if (add_field_to_list(lex->session, &$1, (enum enum_field_types) $3,
1608
lex->length,lex->dec,lex->type,
1610
lex->default_value, lex->on_update_value,
1612
lex->change,&lex->interval_list,lex->charset))
1163
1613
DRIZZLE_YYABORT;
1165
Lex->setField(NULL);
1170
field_definition opt_attribute {}
1617
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);
1624
Lex->length=(char*) 0; /* use default length */
1626
| real_type opt_precision { $$=$1; }
1627
| char '(' NUM ')' opt_binary
1630
$$=DRIZZLE_TYPE_VARCHAR;
1634
Lex->length=(char*) "1";
1635
$$=DRIZZLE_TYPE_VARCHAR;
1637
| varchar '(' NUM ')' opt_binary
1640
$$= DRIZZLE_TYPE_VARCHAR;
1195
1642
| VARBINARY '(' NUM ')'
1197
$$= parser::buildVarbinaryColumn(Lex, $3.str);
1645
Lex->charset=&my_charset_bin;
1646
$$= 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);
1649
{ $$=DRIZZLE_TYPE_DATE; }
1213
1650
| TIMESTAMP_SYM
1215
$$=parser::buildTimestampColumn(Lex, NULL);
1217
| TIMESTAMP_SYM '(' NUM ')'
1219
$$=parser::buildTimestampColumn(Lex, $3.str);
1651
{ $$=DRIZZLE_TYPE_TIMESTAMP; }
1223
$$=DRIZZLE_TYPE_DATETIME;
1226
Lex->field()->set_type(message::Table::Field::DATETIME);
1653
{ $$=DRIZZLE_TYPE_DATETIME; }
1230
$$= parser::buildBlobColumn(Lex);
1656
Lex->charset=&my_charset_bin;
1234
1657
$$=DRIZZLE_TYPE_BLOB;
1235
1658
Lex->length=(char*) 0; /* use default length */
1238
Lex->field()->set_type(message::Table::Field::BLOB);
1660
| TEXT_SYM opt_binary
1662
$$=DRIZZLE_TYPE_BLOB;
1663
Lex->length=(char*) 0; /* use default length */
1240
1665
| DECIMAL_SYM float_options
1242
$$= parser::buildDecimalColumn(Lex);
1666
{ $$=DRIZZLE_TYPE_NEWDECIMAL;}
1244
1667
| NUMERIC_SYM float_options
1246
$$= parser::buildDecimalColumn(Lex);
1668
{ $$=DRIZZLE_TYPE_NEWDECIMAL;}
1248
1669
| FIXED_SYM float_options
1250
$$= parser::buildDecimalColumn(Lex);
1670
{ $$=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);
1672
{Lex->interval_list.empty();}
1673
'(' string_list ')' opt_binary
1674
{ $$=DRIZZLE_TYPE_ENUM; }
1273
$$= parser::buildSerialColumn(Lex);
1677
$$=DRIZZLE_TYPE_LONGLONG;
1678
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);
1746
NULL_SYM { Lex->type&= ~ NOT_NULL_FLAG; }
1747
| COLUMN_FORMAT_SYM column_format_types
1749
Lex->column_format= $2;
1750
Lex->alter_info.flags.set(ALTER_COLUMN_FORMAT);
1752
| not NULL_SYM { Lex->type|= NOT_NULL_FLAG; }
1753
| DEFAULT now_or_signed_literal
1755
Lex->default_value=$2;
1756
Lex->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1758
| ON UPDATE_SYM NOW_SYM optional_braces
1759
{ Lex->on_update_value= new Item_func_now_local(); }
1760
| AUTO_INC { Lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG; }
1402
1761
| SERIAL_SYM DEFAULT VALUE_SYM
1404
(void)parser::buildSerialColumn(Lex);
1764
lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_FLAG;
1765
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1406
1767
| opt_primary KEY_SYM
1408
parser::buildPrimaryOnColumn(Lex);
1770
lex->type|= PRI_KEY_FLAG | NOT_NULL_FLAG;
1771
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1412
parser::buildKeyOnColumn(Lex);
1776
lex->type|= UNIQUE_FLAG;
1777
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1414
1779
| 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);
1782
lex->type|= UNIQUE_KEY_FLAG;
1783
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1785
| COMMENT_SYM TEXT_STRING_sys { Lex->comment= $2; }
1426
1786
| COLLATE_SYM collation_name
1428
1788
if (Lex->charset && !my_charset_same(Lex->charset,$2))
1493
1927
{ 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));
1931
lex->ref_list.empty();
1932
lex->ref_list.push_back(new Key_part_spec($1, 0));
1501
1936
opt_match_clause:
1503
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_UNDEFINED; }
1938
{ Lex->fk_match_option= Foreign_key::FK_MATCH_UNDEF; }
1505
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_FULL; }
1940
{ Lex->fk_match_option= Foreign_key::FK_MATCH_FULL; }
1506
1941
| MATCH PARTIAL
1507
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_PARTIAL; }
1942
{ Lex->fk_match_option= Foreign_key::FK_MATCH_PARTIAL; }
1508
1943
| MATCH SIMPLE_SYM
1509
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_SIMPLE; }
1944
{ Lex->fk_match_option= Foreign_key::FK_MATCH_SIMPLE; }
1512
1947
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;
1951
lex->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
1952
lex->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
1518
1954
| 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;
1957
lex->fk_update_opt= $3;
1958
lex->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
1523
1960
| 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;
1963
lex->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
1964
lex->fk_delete_opt= $3;
1528
1966
| ON UPDATE_SYM delete_option
1529
1967
ON DELETE_SYM delete_option
1531
((statement::CreateTable *)Lex->statement)->fk_update_opt= $3;
1532
((statement::CreateTable *)Lex->statement)->fk_delete_opt= $6;
1970
lex->fk_update_opt= $3;
1971
lex->fk_delete_opt= $6;
1534
1973
| ON DELETE_SYM delete_option
1535
1974
ON UPDATE_SYM delete_option
1537
((statement::CreateTable *)Lex->statement)->fk_update_opt= $6;
1538
((statement::CreateTable *)Lex->statement)->fk_delete_opt= $3;
1977
lex->fk_update_opt= $6;
1978
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; }
1983
RESTRICT { $$= Foreign_key::FK_OPTION_RESTRICT; }
1984
| CASCADE { $$= Foreign_key::FK_OPTION_CASCADE; }
1985
| SET NULL_SYM { $$= Foreign_key::FK_OPTION_SET_NULL; }
1986
| NO_SYM ACTION { $$= Foreign_key::FK_OPTION_NO_ACTION; }
1987
| SET DEFAULT { $$= Foreign_key::FK_OPTION_DEFAULT; }
1661
ALTER_SYM build_method opt_ignore TABLE_SYM table_ident
2102
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))
2104
Session *session= YYSession;
2105
LEX *lex= session->lex;
2107
lex->name.length= 0;
2108
lex->sql_command= SQLCOM_ALTER_TABLE;
2109
lex->duplicates= DUP_ERROR;
2110
if (!lex->select_lex.add_table_to_list(session, $5, NULL,
2111
TL_OPTION_UPDATING))
1668
2112
DRIZZLE_YYABORT;
2113
lex->alter_info.reset();
2114
lex->col_list.empty();
2115
lex->select_lex.init_order();
2117
((TableList*) lex->select_lex.table_list.first)->db;
2118
memset(&lex->create_info, 0, sizeof(lex->create_info));
2119
lex->create_info.db_type= 0;
2120
lex->create_info.default_table_charset= NULL;
2121
lex->create_info.row_type= ROW_TYPE_NOT_USED;
2122
lex->alter_info.reset();
2123
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());
2125
lex->create_table_proto= new drizzled::message::Table();
1677
| ALTER_SYM DATABASE schema_name
2129
| ALTER DATABASE ident_or_empty
1679
Lex->statement= new statement::AlterSchema(YYSession);
2131
Lex->create_info.default_table_charset= NULL;
2132
Lex->create_info.used_fields= 0;
1681
default_collation_schema
2134
create_database_options
1684
if (Lex->name.str == NULL && Lex->copy_db_to(&Lex->name.str, &Lex->name.length))
2137
lex->sql_command=SQLCOM_ALTER_DB;
2139
if (lex->name.str == NULL &&
2140
lex->copy_db_to(&lex->name.str, &lex->name.length))
1685
2141
DRIZZLE_YYABORT;
2146
/* empty */ { $$.str= 0; $$.length= 0; }
1689
2150
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;
2152
| DISCARD TABLESPACE { Lex->alter_info.tablespace_op= DISCARD_TABLESPACE; }
2153
| 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);
2182
lex->alter_info.flags.set(ALTER_ADD_COLUMN);
1734
2186
alter_list_item:
1735
2187
add_column column_def opt_place { }
1738
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1740
statement->alter_info.flags.set(ALTER_ADD_INDEX);
2190
Lex->alter_info.flags.set(ALTER_ADD_INDEX);
1742
2192
| 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);
2194
Lex->alter_info.flags.set(ALTER_ADD_COLUMN);
2195
Lex->alter_info.flags.set(ALTER_ADD_INDEX);
1749
| CHANGE_SYM opt_column field_ident
2197
| 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);
2200
lex->change= $3.str;
2201
lex->alter_info.flags.set(ALTER_CHANGE_COLUMN);
1755
2203
field_spec opt_place
1756
2204
| 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);
2207
lex->length=lex->dec=0; lex->type=0;
2208
lex->default_value= lex->on_update_value= 0;
2209
lex->comment=null_lex_str;
2211
lex->alter_info.flags.set(ALTER_CHANGE_COLUMN);
2212
lex->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
1771
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1773
if (add_field_to_list(Lex->session,&$3,
2217
if (add_field_to_list(lex->session,&$3,
1774
2218
(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))
2219
lex->length,lex->dec,lex->type,
2221
lex->default_value, lex->on_update_value,
2223
$3.str, &lex->interval_list, lex->charset))
1781
2224
DRIZZLE_YYABORT;
1784
2227
| 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);
2230
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::COLUMN,
2232
lex->alter_info.flags.set(ALTER_DROP_COLUMN);
1791
2234
| 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);
2236
Lex->alter_info.flags.set(ALTER_DROP_INDEX);
2237
Lex->alter_info.flags.set(ALTER_FOREIGN_KEY);
1799
2239
| 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,
2242
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::KEY,
1805
statement->alter_info.flags.set(ALTER_DROP_INDEX);
2244
lex->alter_info.flags.set(ALTER_DROP_INDEX);
1807
2246
| 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);
2249
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::KEY,
2251
lex->alter_info.flags.set(ALTER_DROP_INDEX);
1815
2253
| 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);
2256
lex->alter_info.keys_onoff= DISABLE;
2257
lex->alter_info.flags.set(ALTER_KEYS_ONOFF);
1822
2259
| 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);
2262
lex->alter_info.keys_onoff= ENABLE;
2263
lex->alter_info.flags.set(ALTER_KEYS_ONOFF);
2265
| ALTER opt_column field_ident SET DEFAULT signed_literal
2268
lex->alter_info.alter_list.push_back(new Alter_column($3.str,$6));
2269
lex->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
2271
| ALTER opt_column field_ident DROP DEFAULT
2274
lex->alter_info.alter_list.push_back(new Alter_column($3.str,
2276
lex->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1843
2278
| 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))
2282
lex->select_lex.db=$3->db.str;
2283
if (lex->select_lex.db == NULL &&
2284
lex->copy_db_to(&lex->select_lex.db, &dummy))
1852
2286
DRIZZLE_YYABORT;
1855
if (check_table_name($3->table.str,$3->table.length))
2288
if (check_table_name($3->table.str,$3->table.length) || ($3->db.str && check_db_name(&$3->db)))
1857
2290
my_error(ER_WRONG_TABLE_NAME, MYF(0), $3->table.str);
1858
2291
DRIZZLE_YYABORT;
1861
Lex->name= $3->table;
1862
statement->alter_info.flags.set(ALTER_RENAME);
2293
lex->name= $3->table;
2294
lex->alter_info.flags.set(ALTER_RENAME);
1864
2296
| 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 |
2299
lex->create_info.table_charset=
2300
lex->create_info.default_table_charset= $3;
2301
lex->create_info.used_fields|= (HA_CREATE_USED_CHARSET |
1871
2302
HA_CREATE_USED_DEFAULT_CHARSET);
1872
statement->alter_info.flags.set(ALTER_CONVERT);
2303
lex->alter_info.flags.set(ALTER_CONVERT);
1874
2305
| create_table_options_space_separated
1876
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1878
statement->alter_info.flags.set(ALTER_OPTIONS);
2308
lex->alter_info.flags.set(ALTER_OPTIONS);
1882
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1884
statement->alter_info.flags.set(ALTER_FORCE);
2312
Lex->alter_info.flags.set(ALTER_FORCE);
1886
2314
| alter_order_clause
1888
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1890
statement->alter_info.flags.set(ALTER_ORDER);
2317
lex->alter_info.flags.set(ALTER_ORDER);
2078
2579
| 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
2583
STRAIGHT_JOIN { Lex->current_select->options|= SELECT_STRAIGHT_JOIN; }
2584
| DISTINCT { Lex->current_select->options|= SELECT_DISTINCT; }
2585
| SQL_SMALL_RESULT { Lex->current_select->options|= SELECT_SMALL_RESULT; }
2586
| SQL_BIG_RESULT { Lex->current_select->options|= SELECT_BIG_RESULT; }
2130
2587
| SQL_BUFFER_RESULT
2132
if (check_simple_select(YYSession))
2589
if (check_simple_select())
2133
2590
DRIZZLE_YYABORT;
2134
2591
Lex->current_select->options|= OPTION_BUFFER_RESULT;
2136
| select_option_small_or_big
2138
| select_option_distinct_or_all
2140
2593
| SQL_CALC_FOUND_ROWS
2142
if (check_simple_select(YYSession))
2595
if (check_simple_select())
2143
2596
DRIZZLE_YYABORT;
2144
2597
Lex->current_select->options|= OPTION_FOUND_ROWS;
2599
| ALL { Lex->current_select->options|= SELECT_ALL; }
2148
2602
select_lock_type:
2150
2604
| FOR_SYM UPDATE_SYM
2152
Lex->current_select->set_lock_for_tables(TL_WRITE);
2607
lex->current_select->set_lock_for_tables(TL_WRITE);
2154
2609
| LOCK_SYM IN_SYM SHARE_SYM MODE_SYM
2156
Lex->current_select->
2612
lex->current_select->
2157
2613
set_lock_for_tables(TL_READ_WITH_SHARED_LOCKS);
2682
3106
| SUBDATE_SYM '(' expr ',' INTERVAL_SYM expr interval ')'
2683
3107
{ $$= new (YYSession->mem_root) Item_date_add_interval($3, $6, $7, 1); }
2684
3108
| 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)))
3109
{ $$= new (YYSession->mem_root) Item_func_substr($3,$5,$7); }
2696
3110
| 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)))
3111
{ $$= new (YYSession->mem_root) Item_func_substr($3,$5); }
2707
3112
| 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)))
3113
{ $$= new (YYSession->mem_root) Item_func_substr($3,$5,$7); }
2719
3114
| 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)))
3115
{ $$= new (YYSession->mem_root) Item_func_substr($3,$5); }
2730
3116
| SYSDATE optional_braces
2732
$$= new (YYSession->mem_root) Item_func_sysdate_local();
2733
Lex->setCacheable(false);
3117
{ $$= new (YYSession->mem_root) Item_func_sysdate_local(); }
2735
3118
| SYSDATE '(' expr ')'
2737
$$= new (YYSession->mem_root) Item_func_sysdate_local($3);
2738
Lex->setCacheable(false);
3119
{ $$= new (YYSession->mem_root) Item_func_sysdate_local($3); }
2740
3120
| TIMESTAMP_ADD '(' interval_time_stamp ',' expr ',' expr ')'
2741
3121
{ $$= new (YYSession->mem_root) Item_date_add_interval($7,$5,$3,0); }
2742
3122
| TIMESTAMP_DIFF '(' interval_time_stamp ',' expr ',' expr ')'
2819
3154
| QUARTER_SYM '(' expr ')'
2820
3155
{ $$ = new (YYSession->mem_root) Item_func_quarter($3); }
2821
3156
| REPEAT_SYM '(' expr ',' expr ')'
2822
{ $$= new (YYSession->mem_root) Item_func_repeat(*YYSession, $3, $5); }
3157
{ $$= new (YYSession->mem_root) Item_func_repeat($3,$5); }
2823
3158
| REPLACE '(' expr ',' expr ',' expr ')'
2824
{ $$= new (YYSession->mem_root) Item_func_replace(*YYSession, $3, $5, $7); }
3159
{ $$= new (YYSession->mem_root) Item_func_replace($3,$5,$7); }
3160
| REVERSE_SYM '(' expr ')'
3161
{ $$= new (YYSession->mem_root) Item_func_reverse($3); }
2825
3162
| TRUNCATE_SYM '(' expr ',' expr ')'
2826
3163
{ $$= new (YYSession->mem_root) Item_func_round($3,$5,1); }
2827
| WAIT_SYM '(' expr ')'
3164
| WEIGHT_STRING_SYM '(' expr opt_ws_levels ')'
3165
{ $$= new (YYSession->mem_root) Item_func_weight_string($3, 0, $4); }
3166
| 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)))
3168
$$= new (YYSession->mem_root)
3169
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)))
3171
| WEIGHT_STRING_SYM '(' expr AS BINARY ws_nweights ')'
3173
$3= create_func_char_cast(YYSession, $3, $6, &my_charset_bin);
3174
$$= new (YYSession->mem_root)
3175
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); }
4241
NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4242
| HEX_NUM { $$= (ulong) strtol($1.str, (char**) 0, 16); }
4243
| LONG_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4244
| ULONGLONG_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4245
| DECIMAL_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4246
| FLOAT_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4250
NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4251
| HEX_NUM { $$= (ulong) strtol($1.str, (char**) 0, 16); }
4252
| LONG_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4253
| 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); }
4258
NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4259
| ULONGLONG_NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4260
| LONG_NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4261
| DECIMAL_NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4262
| FLOAT_NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4267
{ my_parse_error(ER(ER_ONLY_INTEGERS_ALLOWED)); }
4276
ulong_num { $$= $1 != 0 ? HA_CHOICE_YES : HA_CHOICE_NO; }
4277
| DEFAULT { $$= HA_CHOICE_UNDEF; }
3923
4280
select_var_list_init:
3925
if (not Lex->describe && (not (Lex->result= new select_dumpvar())))
4283
if (!lex->describe && (!(lex->result= new select_dumpvar())))
3926
4284
DRIZZLE_YYABORT;
3928
4286
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;
4345
DROP opt_temporary table_or_tables if_exists table_list
4348
lex->sql_command = SQLCOM_DROP_TABLE;
4349
lex->drop_temporary= $2;
4350
lex->drop_if_exists= $4;
4001
4352
| 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))
4355
lex->sql_command= SQLCOM_DROP_INDEX;
4356
lex->alter_info.reset();
4357
lex->alter_info.flags.set(ALTER_DROP_INDEX);
4358
lex->alter_info.build_method= $2;
4359
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::KEY,
4361
if (!lex->current_select->add_table_to_list(lex->session, $6, NULL,
4362
TL_OPTION_UPDATING))
4010
4363
DRIZZLE_YYABORT;
4012
| DROP DATABASE if_exists schema_name
4365
| DROP DATABASE if_exists ident
4014
statement::DropSchema *statement= new statement::DropSchema(YYSession);
4015
Lex->statement= statement;
4016
statement->drop_if_exists=$3;
4368
lex->sql_command= SQLCOM_DROP_DB;
4369
lex->drop_if_exists=$3;
4023
4374
| table_list ',' table_name
4346
Lex->lock_option= TL_READ;
4348
Lex->current_select->parsing_place= SELECT_LIST;
4673
lex->lock_option= TL_READ;
4674
mysql_init_select(lex);
4675
lex->current_select->parsing_place= SELECT_LIST;
4676
memset(&lex->create_info, 0, sizeof(lex->create_info));
4356
4683
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 */
4686
lex->sql_command= SQLCOM_SHOW_DATABASES;
4688
new(std::nothrow) statement::Select(SQLCOM_SHOW_DATABASES,
4690
if (lex->statement == NULL)
4692
if (prepare_schema_table(YYSession, lex, 0, "SCHEMATA"))
4695
| opt_full TABLES opt_db show_wild
4698
lex->sql_command= SQLCOM_SHOW_TABLES;
4700
new(std::nothrow) statement::Select(SQLCOM_SHOW_TABLES,
4702
if (lex->statement == NULL)
4704
lex->select_lex.db= $3;
4705
if (prepare_schema_table(YYSession, lex, 0, "TABLE_NAMES"))
4374
4708
| 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 */
4711
lex->sql_command= SQLCOM_SHOW_TABLE_STATUS;
4713
new(std::nothrow) statement::Select(SQLCOM_SHOW_TABLE_STATUS,
4715
if (lex->statement == NULL)
4717
lex->select_lex.db= $3;
4718
if (prepare_schema_table(YYSession, lex, 0, "TABLES"))
4721
| OPEN_SYM TABLES opt_db show_wild
4724
lex->sql_command= SQLCOM_SHOW_OPEN_TABLES;
4726
new(std::nothrow) statement::Select(SQLCOM_SHOW_OPEN_TABLES,
4728
if (lex->statement == NULL)
4730
lex->select_lex.db= $3;
4731
if (prepare_schema_table(YYSession, lex, 0, "OPEN_TABLES"))
4734
| ENGINE_SYM known_storage_engines STATUS_SYM /* This should either go... well it should go */
4736
Lex->show_engine= $2;
4737
Lex->sql_command= SQLCOM_SHOW_ENGINE_STATUS;
4739
new(std::nothrow) statement::ShowEngineStatus(YYSession);
4740
if (Lex->statement == NULL)
4743
| opt_full COLUMNS from_or_in table_ident opt_db show_wild
4746
lex->sql_command= SQLCOM_SHOW_FIELDS;
4748
new(std::nothrow) statement::Select(SQLCOM_SHOW_FIELDS, YYSession);
4749
if (lex->statement == NULL)
4753
if (prepare_schema_table(YYSession, lex, $4, "COLUMNS"))
4386
4756
| keys_or_index from_or_in table_ident opt_db where_clause
4388
if (not show::buildIndex(YYSession, $4, $3))
4759
lex->sql_command= SQLCOM_SHOW_KEYS;
4760
lex->statement= new(std::nothrow) statement::Select(SQLCOM_SHOW_KEYS,
4762
if (lex->statement == NULL)
4766
if (prepare_schema_table(YYSession, lex, $3, "STATISTICS"))
4391
4769
| COUNT_SYM '(' '*' ')' WARNINGS
4393
show::buildSelectWarning(YYSession);
4771
(void) create_select_for_variable("warning_count");
4773
lex->statement= new(std::nothrow) statement::Select(SQLCOM_SELECT,
4775
if (lex->statement == NULL)
4395
4778
| COUNT_SYM '(' '*' ')' ERRORS
4397
show::buildSelectError(YYSession);
4780
(void) create_select_for_variable("error_count");
4782
lex->statement= new(std::nothrow) statement::Select(SQLCOM_SELECT,
4784
if (lex->statement == NULL)
4399
4787
| WARNINGS opt_limit_clause_init
4401
show::buildWarnings(YYSession);
4789
Lex->sql_command = SQLCOM_SHOW_WARNS;
4790
Lex->statement= new(std::nothrow) statement::ShowWarnings(YYSession);
4791
if (Lex->statement == NULL)
4403
4794
| ERRORS opt_limit_clause_init
4405
show::buildErrors(YYSession);
4796
Lex->sql_command = SQLCOM_SHOW_ERRORS;
4797
Lex->statement= new(std::nothrow) statement::ShowErrors(YYSession);
4798
if (Lex->statement == NULL)
4407
4801
| 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))
4804
lex->sql_command= SQLCOM_SHOW_STATUS;
4806
new(std::nothrow) statement::ShowStatus(YYSession,
4808
if (lex->statement == NULL)
4810
lex->option_type= $1;
4811
if (prepare_schema_table(YYSession, lex, 0, "STATUS"))
4814
| opt_full PROCESSLIST_SYM
4816
Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;
4818
new(std::nothrow) statement::ShowProcesslist(YYSession);
4819
if (Lex->statement == NULL)
4822
| opt_var_type VARIABLES show_wild
4825
lex->sql_command= SQLCOM_SHOW_VARIABLES;
4827
new(std::nothrow) statement::Select(SQLCOM_SHOW_VARIABLES,
4829
if (lex->statement == NULL)
4831
lex->option_type= $1;
4832
if (prepare_schema_table(YYSession, lex, 0, "VARIABLES"))
4835
| CREATE DATABASE opt_if_not_exists ident
4837
Lex->sql_command=SQLCOM_SHOW_CREATE_DB;
4838
Lex->statement= new(std::nothrow) statement::ShowCreateSchema(YYSession);
4839
if (Lex->statement == NULL)
4841
Lex->create_info.options=$3;
4417
4844
| 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))
4847
lex->sql_command = SQLCOM_SHOW_CREATE;
4848
lex->statement= new(std::nothrow) statement::ShowCreate(YYSession);
4849
if (lex->statement == NULL)
4851
if (!lex->select_lex.add_table_to_list(YYSession, $3, NULL,0))
4435
4852
DRIZZLE_YYABORT;
4872
5320
simple_ident_q:
4873
5321
ident '.' ident
4875
$$= parser::buildIdent(Lex, NULL_LEX_STRING, $1, $3);
5323
Session *session= YYSession;
5324
LEX *lex= session->lex;
5327
Select_Lex *sel= lex->current_select;
5328
if (sel->no_table_names_allowed)
5330
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5331
MYF(0), $1.str, session->where);
5333
$$= (sel->parsing_place != IN_HAVING ||
5334
sel->get_in_sum_expr() > 0) ?
5335
(Item*) new Item_field(Lex->current_context(),
5336
(const char *)NULL, $1.str, $3.str) :
5337
(Item*) new Item_ref(Lex->current_context(),
5338
(const char *)NULL, $1.str, $3.str);
4877
5341
| '.' ident '.' ident
4879
$$= parser::buildIdent(Lex, NULL_LEX_STRING, $2, $4);
5343
Session *session= YYSession;
5344
LEX *lex= session->lex;
5345
Select_Lex *sel= lex->current_select;
5346
if (sel->no_table_names_allowed)
5348
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5349
MYF(0), $2.str, session->where);
5351
$$= (sel->parsing_place != IN_HAVING ||
5352
sel->get_in_sum_expr() > 0) ?
5353
(Item*) new Item_field(Lex->current_context(), NULL, $2.str, $4.str) :
5354
(Item*) new Item_ref(Lex->current_context(),
5355
(const char *)NULL, $2.str, $4.str);
4881
5357
| ident '.' ident '.' ident
4883
$$= parser::buildIdent(Lex, $1, $3, $5);
5359
Session *session= YYSession;
5360
LEX *lex= session->lex;
5361
Select_Lex *sel= lex->current_select;
5362
if (sel->no_table_names_allowed)
5364
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5365
MYF(0), $3.str, session->where);
5367
$$= (sel->parsing_place != IN_HAVING ||
5368
sel->get_in_sum_expr() > 0) ?
5369
(Item*) new Item_field(Lex->current_context(), $1.str, $3.str,
5371
(Item*) new Item_ref(Lex->current_context(), $1.str, $3.str,
4892
5378
| ident '.' ident '.' ident
4894
if (not parser::checkFieldIdent(Lex, $1, $3))
5381
reinterpret_cast<TableList*>(Lex->current_select->table_list.first);
5382
if (my_strcasecmp(table_alias_charset, $1.str, table->db))
5384
my_error(ER_WRONG_DB_NAME, MYF(0), $1.str);
5387
if (my_strcasecmp(table_alias_charset, $3.str,
5390
my_error(ER_WRONG_TABLE_NAME, MYF(0), $3.str);
4899
5395
| ident '.' ident
4901
if (not parser::checkFieldIdent(Lex, NULL_LEX_STRING, $1))
5398
reinterpret_cast<TableList*>(Lex->current_select->table_list.first);
5399
if (my_strcasecmp(table_alias_charset, $1.str, table->alias))
5401
my_error(ER_WRONG_TABLE_NAME, MYF(0), $1.str);
4902
5402
DRIZZLE_YYABORT;
5406
| '.' ident { $$=$2;} /* For Delphi */
4915
$$= new Table_ident($1);
4917
| schema_name '.' ident
4919
$$=new Table_ident($1,$3);
4923
$$= new Table_ident($2);
5410
ident { $$=new Table_ident($1); }
5411
| ident '.' ident { $$=new Table_ident($1,$3);}
5412
| '.' ident { $$=new Table_ident($2);} /* For Delphi */
4942
5419
const CHARSET_INFO * const cs= system_charset_info;
5221
5767
sys_option_value:
5222
5768
option_type internal_variable_name equal set_expr_or_default
5225
5773
{ /* 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)));
5775
lex->option_type= $1;
5776
lex->var_list.push_back(new set_var(lex->option_type, $2.var,
5777
&$2.base_name, $4));
5233
5780
| 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)
5783
lex->option_type= $1;
5784
lex->var_list.push_back(new set_var(lex->option_type,
5785
find_sys_var(YYSession, "tx_isolation"),
5787
new Item_int((int32_t) $5)));
5245
'@' user_variable_ident equal expr
5792
'@' ident_or_text equal expr
5247
Lex->var_list.push_back(SetVarPtr(new set_var_user(new Item_func_set_user_var($2,$4))));
5794
Lex->var_list.push_back(new set_var_user(new Item_func_set_user_var($2,$4)));
5249
5796
| '@' '@' 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; }
5799
lex->var_list.push_back(new set_var($3, $4.var, &$4.base_name, $6));
5270
5803
internal_variable_name:
5271
internal_variable_ident
5806
Session *session= YYSession;
5273
5808
/* We have to lookup here since local vars can shadow sysvars */
5275
5810
/* Not an SP local variable */
5276
sys_var *tmp= find_sys_var(std::string($1.str, $1.length));
5811
sys_var *tmp=find_sys_var(session, $1.str, $1.length);
5278
5813
DRIZZLE_YYABORT;