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 90 shift/reduce conflicts.
173
395
We should not introduce new conflicts any more.
178
400
Comments for TOKENS.
828
1111
/* 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);
1114
CREATE opt_table_options TABLE_SYM opt_if_not_exists table_ident
1116
Session *session= YYSession;
1117
LEX *lex= session->lex;
1118
lex->sql_command= SQLCOM_CREATE_TABLE;
1119
if (!lex->select_lex.add_table_to_list(session, $5, NULL,
1123
lex->alter_info.reset();
1124
lex->col_list.empty();
1126
memset(&lex->create_info, 0, sizeof(lex->create_info));
1127
lex->create_info.options=$2 | $4;
1128
lex->create_info.db_type= ha_default_storage_engine(session);
1129
lex->create_info.default_table_charset= NULL;
1132
drizzled::message::Table *proto=
1133
lex->create_table_proto= new drizzled::message::Table();
1135
proto->set_name($5->table.str);
1136
if($2 & HA_LEX_CREATE_TMP_TABLE)
1137
proto->set_type(drizzled::message::Table::TEMPORARY);
1139
proto->set_type(drizzled::message::Table::STANDARD);
1142
drizzled::message::Table::StorageEngine *protoengine;
1143
protoengine= proto->mutable_engine();
1144
StorageEngine *engine= ha_default_storage_engine(session);
1146
protoengine->set_name(engine->getName());
1151
LEX *lex= YYSession->lex;
1152
lex->current_select= &lex->select_lex;
1153
assert(lex->create_info.db_type);
1155
| CREATE build_method opt_unique INDEX_SYM ident key_alg
1159
lex->sql_command= SQLCOM_CREATE_INDEX;
1160
if (!lex->current_select->add_table_to_list(lex->session, $8,
1162
TL_OPTION_UPDATING))
1164
lex->alter_info.reset();
1165
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1166
lex->alter_info.build_method= $2;
1167
lex->col_list.empty();
1170
'(' key_list ')' key_options
1174
key= new Key($3, $5, &lex->key_create_info, 0,
1176
lex->alter_info.key_list.push_back(key);
1177
lex->col_list.empty();
1179
| CREATE DATABASE opt_if_not_exists ident
1181
Lex->create_info.default_table_charset= NULL;
1182
Lex->create_info.used_fields= 0;
866
1184
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);
1187
lex->sql_command=SQLCOM_CREATE_DB;
1189
lex->create_info.options=$3;
1195
| opt_create_table_options
1199
Session *session= YYSession;
1200
LEX *lex= session->lex;
1202
lex->create_info.options|= HA_LEX_CREATE_TABLE_LIKE;
1203
if (!lex->select_lex.add_table_to_list(session, $2, NULL, 0, TL_READ))
1206
| '(' LIKE table_ident ')'
1208
Session *session= YYSession;
1209
LEX *lex= session->lex;
1211
lex->create_info.options|= HA_LEX_CREATE_TABLE_LIKE;
1212
if (!lex->select_lex.add_table_to_list(session, $3, NULL, 0, TL_READ))
1218
field_list ')' opt_create_table_options
1221
{ 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);
1227
| opt_duplicate opt_as create_select
1228
{ Lex->current_select->set_braces(0);}
895
| opt_duplicate_as '(' create_select ')'
897
Lex->current_select->set_braces(1);
1230
| opt_duplicate opt_as '(' create_select ')'
1231
{ 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);
1239
lex->lock_option= TL_READ;
1240
if (lex->sql_command == SQLCOM_INSERT)
1241
lex->sql_command= SQLCOM_INSERT_SELECT;
1242
else if (lex->sql_command == SQLCOM_REPLACE)
1243
lex->sql_command= SQLCOM_REPLACE_SELECT;
936
1245
The following work only with the local list, the global list
937
1246
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;
1248
lex->current_select->table_list.save_and_clear(&lex->save_list);
1249
mysql_init_select(lex);
1250
lex->current_select->parsing_place= SELECT_LIST;
943
1252
select_options select_item_list
1005
1315
create_table_option
1006
1316
| create_table_option create_table_options
1007
1317
| create_table_option ',' create_table_options
1009
1320
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);
1321
ENGINE_SYM opt_equal storage_engines
1323
Lex->create_info.db_type= $3;
1324
Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE;
1327
drizzled::message::Table::StorageEngine *protoengine;
1328
protoengine= Lex->create_table_proto->mutable_engine();
1330
protoengine->set_name($3->getName());
1333
| MAX_ROWS opt_equal ulonglong_num
1335
Lex->create_info.max_rows= $3;
1336
Lex->create_info.used_fields|= HA_CREATE_USED_MAX_ROWS;
1338
| MIN_ROWS opt_equal ulonglong_num
1340
Lex->create_info.min_rows= $3;
1341
Lex->create_info.used_fields|= HA_CREATE_USED_MIN_ROWS;
1343
| AVG_ROW_LENGTH opt_equal ulong_num
1345
Lex->create_info.avg_row_length=$3;
1346
Lex->create_info.used_fields|= HA_CREATE_USED_AVG_ROW_LENGTH;
1348
| BLOCK_SIZE_SYM opt_equal ulong_num
1350
Lex->create_info.block_size= $3;
1351
Lex->create_info.used_fields|= HA_CREATE_USED_BLOCK_SIZE;
1017
1353
| COMMENT_SYM opt_equal TEXT_STRING_sys
1019
Lex->table()->mutable_options()->set_comment($3.str);
1355
Lex->create_info.comment=$3;
1356
Lex->create_info.used_fields|= HA_CREATE_USED_COMMENT;
1021
1358
| 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);
1360
Lex->create_info.auto_increment_value=$3;
1361
Lex->create_info.used_fields|= HA_CREATE_USED_AUTO;
1363
| PACK_KEYS_SYM opt_equal ulong_num
1367
Lex->create_info.table_options|= HA_OPTION_NO_PACK_KEYS;
1370
Lex->create_info.table_options|= HA_OPTION_PACK_KEYS;
1373
my_parse_error(ER(ER_SYNTAX_ERROR));
1376
Lex->create_info.used_fields|= HA_CREATE_USED_PACK_KEYS;
1378
| PACK_KEYS_SYM opt_equal DEFAULT
1380
Lex->create_info.table_options&=
1381
~(HA_OPTION_PACK_KEYS | HA_OPTION_NO_PACK_KEYS);
1382
Lex->create_info.used_fields|= HA_CREATE_USED_PACK_KEYS;
1384
| CHECKSUM_SYM opt_equal ulong_num
1386
Lex->create_info.table_options|= $3 ? HA_OPTION_CHECKSUM : HA_OPTION_NO_CHECKSUM;
1387
Lex->create_info.used_fields|= HA_CREATE_USED_CHECKSUM;
1389
| TABLE_CHECKSUM_SYM opt_equal ulong_num
1391
Lex->create_info.table_options|= $3 ? HA_OPTION_CHECKSUM : HA_OPTION_NO_CHECKSUM;
1392
Lex->create_info.used_fields|= HA_CREATE_USED_CHECKSUM;
1394
| PAGE_CHECKSUM_SYM opt_equal choice
1396
Lex->create_info.used_fields|= HA_CREATE_USED_PAGE_CHECKSUM;
1397
Lex->create_info.page_checksum= $3;
1399
| DELAY_KEY_WRITE_SYM opt_equal ulong_num
1401
Lex->create_info.table_options|= $3 ? HA_OPTION_DELAY_KEY_WRITE : HA_OPTION_NO_DELAY_KEY_WRITE;
1402
Lex->create_info.used_fields|= HA_CREATE_USED_DELAY_KEY_WRITE;
1404
| ROW_FORMAT_SYM opt_equal row_types
1406
Lex->create_info.row_type= $3;
1407
Lex->create_info.used_fields|= HA_CREATE_USED_ROW_FORMAT;
1408
Lex->alter_info.flags.set(ALTER_ROW_FORMAT);
1041
1410
| default_collation
1411
| DATA_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys
1413
Lex->create_info.data_file_name= $4.str;
1414
Lex->create_info.used_fields|= HA_CREATE_USED_DATADIR;
1416
| INDEX_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys
1418
Lex->create_info.index_file_name= $4.str;
1419
Lex->create_info.used_fields|= HA_CREATE_USED_INDEXDIR;
1421
| CONNECTION_SYM opt_equal TEXT_STRING_sys
1423
Lex->create_info.connect_string.str= $3.str;
1424
Lex->create_info.connect_string.length= $3.length;
1425
Lex->create_info.used_fields|= HA_CREATE_USED_CONNECTION;
1427
| KEY_BLOCK_SIZE opt_equal ulong_num
1429
Lex->create_info.used_fields|= HA_CREATE_USED_KEY_BLOCK_SIZE;
1430
Lex->create_info.key_block_size= $3;
1044
1434
default_collation:
1045
1435
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;
1437
HA_CREATE_INFO *cinfo= &Lex->create_info;
1438
if ((cinfo->used_fields & HA_CREATE_USED_DEFAULT_CHARSET) &&
1439
cinfo->default_table_charset && $4 &&
1440
!my_charset_same(cinfo->default_table_charset,$4))
1442
my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
1443
$4->name, cinfo->default_table_charset->csname);
1446
Lex->create_info.default_table_charset= $4;
1447
Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET;
1454
const std::string engine_name($1.str);
1455
StorageEngine *engine= ha_resolve_by_name(YYSession, engine_name);
1461
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str);
1467
known_storage_engines:
1470
const std::string engine_name($1.str);
1471
StorageEngine *engine;
1472
if ((engine= ha_resolve_by_name(YYSession, engine_name)))
1476
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str);
1482
column_format_types:
1483
DEFAULT { $$= COLUMN_FORMAT_TYPE_DEFAULT; }
1484
| FIXED_SYM { $$= COLUMN_FORMAT_TYPE_FIXED; }
1485
| DYNAMIC_SYM { $$= COLUMN_FORMAT_TYPE_DYNAMIC; };
1488
DEFAULT { $$= ROW_TYPE_DEFAULT; }
1489
| FIXED_SYM { $$= ROW_TYPE_FIXED; }
1490
| DYNAMIC_SYM { $$= ROW_TYPE_DYNAMIC; }
1491
| COMPRESSED_SYM { $$= ROW_TYPE_COMPRESSED; }
1492
| REDUNDANT_SYM { $$= ROW_TYPE_REDUNDANT; }
1493
| COMPACT_SYM { $$= ROW_TYPE_COMPACT; }
1494
| PAGE_SYM { $$= ROW_TYPE_PAGE; }
1078
1497
opt_select_from:
1094
1513
field_spec opt_check_constraint
1095
1514
| field_spec references
1097
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1516
Lex->col_list.empty(); /* Alloced by sql_alloc */
1102
1521
key_type opt_ident key_alg '(' key_list ')' key_options
1104
parser::buildKey(Lex, $1, $2);
1524
Key *key= new Key($1, $2, &lex->key_create_info, 0,
1526
lex->alter_info.key_list.push_back(key);
1527
lex->col_list.empty(); /* Alloced by sql_alloc */
1106
1529
| opt_constraint constraint_key_type opt_ident key_alg
1107
1530
'(' key_list ')' key_options
1109
parser::buildKey(Lex, $2, $3.str ? $3 : $1);
1533
Key *key= new Key($2, $3.str ? $3 : $1, &lex->key_create_info, 0,
1535
lex->alter_info.key_list.push_back(key);
1536
lex->col_list.empty(); /* Alloced by sql_alloc */
1111
1538
| opt_constraint FOREIGN KEY_SYM opt_ident '(' key_list ')' references
1113
parser::buildForeignKey(Lex, $1.str ? $1 : $4, $8);
1541
Key *key= new Foreign_key($4.str ? $4 : $1, lex->col_list,
1546
lex->fk_match_option);
1547
lex->alter_info.key_list.push_back(key);
1548
key= new Key(Key::MULTIPLE, $1.str ? $1 : $4,
1549
&default_key_create_info, 1,
1551
lex->alter_info.key_list.push_back(key);
1552
lex->col_list.empty(); /* Alloced by sql_alloc */
1553
/* Only used for ALTER TABLE. Ignored otherwise. */
1554
lex->alter_info.flags.set(ALTER_FOREIGN_KEY);
1115
1556
| constraint opt_check_constraint
1117
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1558
Lex->col_list.empty(); /* Alloced by sql_alloc */
1119
1560
| opt_constraint check_constraint
1121
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1562
Lex->col_list.empty(); /* Alloced by sql_alloc */
1146
parser::buildCreateFieldIdent(Lex);
1588
lex->length=lex->dec=0;
1590
lex->default_value= lex->on_update_value= 0;
1591
lex->comment=null_lex_str;
1593
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))
1598
if (add_field_to_list(lex->session, &$1, (enum enum_field_types) $3,
1599
lex->length,lex->dec,lex->type,
1601
lex->default_value, lex->on_update_value,
1603
lex->change,&lex->interval_list,lex->charset))
1163
1604
DRIZZLE_YYABORT;
1165
Lex->setField(NULL);
1170
field_definition opt_attribute {}
1608
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);
1615
Lex->length=(char*) 0; /* use default length */
1617
| real_type opt_precision { $$=$1; }
1618
| char '(' NUM ')' opt_binary
1621
$$=DRIZZLE_TYPE_VARCHAR;
1625
Lex->length=(char*) "1";
1626
$$=DRIZZLE_TYPE_VARCHAR;
1628
| varchar '(' NUM ')' opt_binary
1631
$$= DRIZZLE_TYPE_VARCHAR;
1195
1633
| VARBINARY '(' NUM ')'
1197
$$= parser::buildVarbinaryColumn(Lex, $3.str);
1636
Lex->charset=&my_charset_bin;
1637
$$= 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);
1640
{ $$=DRIZZLE_TYPE_DATE; }
1213
1641
| TIMESTAMP_SYM
1215
$$=parser::buildTimestampColumn(Lex, NULL);
1217
| TIMESTAMP_SYM '(' NUM ')'
1219
$$=parser::buildTimestampColumn(Lex, $3.str);
1642
{ $$=DRIZZLE_TYPE_TIMESTAMP; }
1223
$$=DRIZZLE_TYPE_DATETIME;
1226
Lex->field()->set_type(message::Table::Field::DATETIME);
1644
{ $$=DRIZZLE_TYPE_DATETIME; }
1230
$$= parser::buildBlobColumn(Lex);
1647
Lex->charset=&my_charset_bin;
1234
1648
$$=DRIZZLE_TYPE_BLOB;
1235
1649
Lex->length=(char*) 0; /* use default length */
1238
Lex->field()->set_type(message::Table::Field::BLOB);
1651
| TEXT_SYM opt_binary
1653
$$=DRIZZLE_TYPE_BLOB;
1654
Lex->length=(char*) 0; /* use default length */
1240
1656
| DECIMAL_SYM float_options
1242
$$= parser::buildDecimalColumn(Lex);
1657
{ $$=DRIZZLE_TYPE_NEWDECIMAL;}
1244
1658
| NUMERIC_SYM float_options
1246
$$= parser::buildDecimalColumn(Lex);
1659
{ $$=DRIZZLE_TYPE_NEWDECIMAL;}
1248
1660
| FIXED_SYM float_options
1250
$$= parser::buildDecimalColumn(Lex);
1661
{ $$=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);
1663
{Lex->interval_list.empty();}
1664
'(' string_list ')' opt_binary
1665
{ $$=DRIZZLE_TYPE_ENUM; }
1273
$$= parser::buildSerialColumn(Lex);
1668
$$=DRIZZLE_TYPE_LONGLONG;
1669
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);
1737
NULL_SYM { Lex->type&= ~ NOT_NULL_FLAG; }
1738
| COLUMN_FORMAT_SYM column_format_types
1740
Lex->column_format= $2;
1741
Lex->alter_info.flags.set(ALTER_COLUMN_FORMAT);
1743
| not NULL_SYM { Lex->type|= NOT_NULL_FLAG; }
1744
| DEFAULT now_or_signed_literal
1746
Lex->default_value=$2;
1747
Lex->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1749
| ON UPDATE_SYM NOW_SYM optional_braces
1750
{ Lex->on_update_value= new Item_func_now_local(); }
1751
| AUTO_INC { Lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG; }
1402
1752
| SERIAL_SYM DEFAULT VALUE_SYM
1404
(void)parser::buildSerialColumn(Lex);
1755
lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_FLAG;
1756
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1406
1758
| opt_primary KEY_SYM
1408
parser::buildPrimaryOnColumn(Lex);
1761
lex->type|= PRI_KEY_FLAG | NOT_NULL_FLAG;
1762
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1412
parser::buildKeyOnColumn(Lex);
1767
lex->type|= UNIQUE_FLAG;
1768
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1414
1770
| 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);
1773
lex->type|= UNIQUE_KEY_FLAG;
1774
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1776
| COMMENT_SYM TEXT_STRING_sys { Lex->comment= $2; }
1426
1777
| COLLATE_SYM collation_name
1428
1779
if (Lex->charset && !my_charset_same(Lex->charset,$2))
1493
1918
{ 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));
1922
lex->ref_list.empty();
1923
lex->ref_list.push_back(new Key_part_spec($1, 0));
1501
1927
opt_match_clause:
1503
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_UNDEFINED; }
1929
{ Lex->fk_match_option= Foreign_key::FK_MATCH_UNDEF; }
1505
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_FULL; }
1931
{ Lex->fk_match_option= Foreign_key::FK_MATCH_FULL; }
1506
1932
| MATCH PARTIAL
1507
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_PARTIAL; }
1933
{ Lex->fk_match_option= Foreign_key::FK_MATCH_PARTIAL; }
1508
1934
| MATCH SIMPLE_SYM
1509
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_SIMPLE; }
1935
{ Lex->fk_match_option= Foreign_key::FK_MATCH_SIMPLE; }
1512
1938
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;
1942
lex->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
1943
lex->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
1518
1945
| 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;
1948
lex->fk_update_opt= $3;
1949
lex->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
1523
1951
| 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;
1954
lex->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
1955
lex->fk_delete_opt= $3;
1528
1957
| ON UPDATE_SYM delete_option
1529
1958
ON DELETE_SYM delete_option
1531
((statement::CreateTable *)Lex->statement)->fk_update_opt= $3;
1532
((statement::CreateTable *)Lex->statement)->fk_delete_opt= $6;
1961
lex->fk_update_opt= $3;
1962
lex->fk_delete_opt= $6;
1534
1964
| ON DELETE_SYM delete_option
1535
1965
ON UPDATE_SYM delete_option
1537
((statement::CreateTable *)Lex->statement)->fk_update_opt= $6;
1538
((statement::CreateTable *)Lex->statement)->fk_delete_opt= $3;
1968
lex->fk_update_opt= $6;
1969
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; }
1974
RESTRICT { $$= Foreign_key::FK_OPTION_RESTRICT; }
1975
| CASCADE { $$= Foreign_key::FK_OPTION_CASCADE; }
1976
| SET NULL_SYM { $$= Foreign_key::FK_OPTION_SET_NULL; }
1977
| NO_SYM ACTION { $$= Foreign_key::FK_OPTION_NO_ACTION; }
1978
| SET DEFAULT { $$= Foreign_key::FK_OPTION_DEFAULT; }
1661
ALTER_SYM build_method opt_ignore TABLE_SYM table_ident
2093
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))
2095
Session *session= YYSession;
2096
LEX *lex= session->lex;
2098
lex->name.length= 0;
2099
lex->sql_command= SQLCOM_ALTER_TABLE;
2100
lex->duplicates= DUP_ERROR;
2101
if (!lex->select_lex.add_table_to_list(session, $5, NULL,
2102
TL_OPTION_UPDATING))
1668
2103
DRIZZLE_YYABORT;
2104
lex->alter_info.reset();
2105
lex->col_list.empty();
2106
lex->select_lex.init_order();
2108
((TableList*) lex->select_lex.table_list.first)->db;
2109
memset(&lex->create_info, 0, sizeof(lex->create_info));
2110
lex->create_info.db_type= 0;
2111
lex->create_info.default_table_charset= NULL;
2112
lex->create_info.row_type= ROW_TYPE_NOT_USED;
2113
lex->alter_info.reset();
2114
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());
2116
lex->create_table_proto= new drizzled::message::Table();
1677
| ALTER_SYM DATABASE schema_name
2120
| ALTER DATABASE ident_or_empty
1679
Lex->statement= new statement::AlterSchema(YYSession);
2122
Lex->create_info.default_table_charset= NULL;
2123
Lex->create_info.used_fields= 0;
1681
default_collation_schema
2125
create_database_options
1684
if (Lex->name.str == NULL && Lex->copy_db_to(&Lex->name.str, &Lex->name.length))
2128
lex->sql_command=SQLCOM_ALTER_DB;
2130
if (lex->name.str == NULL &&
2131
lex->copy_db_to(&lex->name.str, &lex->name.length))
1685
2132
DRIZZLE_YYABORT;
2137
/* empty */ { $$.str= 0; $$.length= 0; }
1689
2141
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;
2143
| DISCARD TABLESPACE { Lex->alter_info.tablespace_op= DISCARD_TABLESPACE; }
2144
| 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);
2173
lex->alter_info.flags.set(ALTER_ADD_COLUMN);
1734
2177
alter_list_item:
1735
2178
add_column column_def opt_place { }
1738
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1740
statement->alter_info.flags.set(ALTER_ADD_INDEX);
2181
Lex->alter_info.flags.set(ALTER_ADD_INDEX);
1742
2183
| 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);
2185
Lex->alter_info.flags.set(ALTER_ADD_COLUMN);
2186
Lex->alter_info.flags.set(ALTER_ADD_INDEX);
1749
| CHANGE_SYM opt_column field_ident
2188
| 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);
2191
lex->change= $3.str;
2192
lex->alter_info.flags.set(ALTER_CHANGE_COLUMN);
1755
2194
field_spec opt_place
1756
2195
| 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);
2198
lex->length=lex->dec=0; lex->type=0;
2199
lex->default_value= lex->on_update_value= 0;
2200
lex->comment=null_lex_str;
2202
lex->alter_info.flags.set(ALTER_CHANGE_COLUMN);
2203
lex->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
1771
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1773
if (add_field_to_list(Lex->session,&$3,
2208
if (add_field_to_list(lex->session,&$3,
1774
2209
(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))
2210
lex->length,lex->dec,lex->type,
2212
lex->default_value, lex->on_update_value,
2214
$3.str, &lex->interval_list, lex->charset))
1781
2215
DRIZZLE_YYABORT;
1784
2218
| 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);
2221
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::COLUMN,
2223
lex->alter_info.flags.set(ALTER_DROP_COLUMN);
1791
2225
| 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);
2227
Lex->alter_info.flags.set(ALTER_DROP_INDEX);
2228
Lex->alter_info.flags.set(ALTER_FOREIGN_KEY);
1799
2230
| 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,
2233
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::KEY,
1805
statement->alter_info.flags.set(ALTER_DROP_INDEX);
2235
lex->alter_info.flags.set(ALTER_DROP_INDEX);
1807
2237
| 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);
2240
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::KEY,
2242
lex->alter_info.flags.set(ALTER_DROP_INDEX);
1815
2244
| 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);
2247
lex->alter_info.keys_onoff= DISABLE;
2248
lex->alter_info.flags.set(ALTER_KEYS_ONOFF);
1822
2250
| 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);
2253
lex->alter_info.keys_onoff= ENABLE;
2254
lex->alter_info.flags.set(ALTER_KEYS_ONOFF);
2256
| ALTER opt_column field_ident SET DEFAULT signed_literal
2259
lex->alter_info.alter_list.push_back(new Alter_column($3.str,$6));
2260
lex->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
2262
| ALTER opt_column field_ident DROP DEFAULT
2265
lex->alter_info.alter_list.push_back(new Alter_column($3.str,
2267
lex->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1843
2269
| 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))
2273
lex->select_lex.db=$3->db.str;
2274
if (lex->select_lex.db == NULL &&
2275
lex->copy_db_to(&lex->select_lex.db, &dummy))
1852
2277
DRIZZLE_YYABORT;
1855
if (check_table_name($3->table.str,$3->table.length))
2279
if (check_table_name($3->table.str,$3->table.length) || ($3->db.str && check_db_name(&$3->db)))
1857
2281
my_error(ER_WRONG_TABLE_NAME, MYF(0), $3->table.str);
1858
2282
DRIZZLE_YYABORT;
1861
Lex->name= $3->table;
1862
statement->alter_info.flags.set(ALTER_RENAME);
2284
lex->name= $3->table;
2285
lex->alter_info.flags.set(ALTER_RENAME);
1864
2287
| 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 |
2290
lex->create_info.table_charset=
2291
lex->create_info.default_table_charset= $3;
2292
lex->create_info.used_fields|= (HA_CREATE_USED_CHARSET |
1871
2293
HA_CREATE_USED_DEFAULT_CHARSET);
1872
statement->alter_info.flags.set(ALTER_CONVERT);
2294
lex->alter_info.flags.set(ALTER_CONVERT);
1874
2296
| create_table_options_space_separated
1876
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1878
statement->alter_info.flags.set(ALTER_OPTIONS);
2299
lex->alter_info.flags.set(ALTER_OPTIONS);
1882
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1884
statement->alter_info.flags.set(ALTER_FORCE);
2303
Lex->alter_info.flags.set(ALTER_FORCE);
1886
2305
| alter_order_clause
1888
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1890
statement->alter_info.flags.set(ALTER_ORDER);
2308
lex->alter_info.flags.set(ALTER_ORDER);
2078
2609
| 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
2613
STRAIGHT_JOIN { Lex->current_select->options|= SELECT_STRAIGHT_JOIN; }
2614
| DISTINCT { Lex->current_select->options|= SELECT_DISTINCT; }
2615
| SQL_SMALL_RESULT { Lex->current_select->options|= SELECT_SMALL_RESULT; }
2616
| SQL_BIG_RESULT { Lex->current_select->options|= SELECT_BIG_RESULT; }
2130
2617
| SQL_BUFFER_RESULT
2132
if (check_simple_select(YYSession))
2619
if (check_simple_select())
2133
2620
DRIZZLE_YYABORT;
2134
2621
Lex->current_select->options|= OPTION_BUFFER_RESULT;
2136
| select_option_small_or_big
2138
| select_option_distinct_or_all
2140
2623
| SQL_CALC_FOUND_ROWS
2142
if (check_simple_select(YYSession))
2625
if (check_simple_select())
2143
2626
DRIZZLE_YYABORT;
2144
2627
Lex->current_select->options|= OPTION_FOUND_ROWS;
2629
| ALL { Lex->current_select->options|= SELECT_ALL; }
2148
2632
select_lock_type:
2150
2634
| FOR_SYM UPDATE_SYM
2152
Lex->current_select->set_lock_for_tables(TL_WRITE);
2637
lex->current_select->set_lock_for_tables(TL_WRITE);
2154
2639
| LOCK_SYM IN_SYM SHARE_SYM MODE_SYM
2156
Lex->current_select->
2642
lex->current_select->
2157
2643
set_lock_for_tables(TL_READ_WITH_SHARED_LOCKS);
2682
3136
| SUBDATE_SYM '(' expr ',' INTERVAL_SYM expr interval ')'
2683
3137
{ $$= new (YYSession->mem_root) Item_date_add_interval($3, $6, $7, 1); }
2684
3138
| 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)))
3139
{ $$= new (YYSession->mem_root) Item_func_substr($3,$5,$7); }
2696
3140
| 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)))
3141
{ $$= new (YYSession->mem_root) Item_func_substr($3,$5); }
2707
3142
| 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)))
3143
{ $$= new (YYSession->mem_root) Item_func_substr($3,$5,$7); }
2719
3144
| 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)))
3145
{ $$= new (YYSession->mem_root) Item_func_substr($3,$5); }
2730
3146
| SYSDATE optional_braces
2732
$$= new (YYSession->mem_root) Item_func_sysdate_local();
2733
Lex->setCacheable(false);
3147
{ $$= new (YYSession->mem_root) Item_func_sysdate_local(); }
2735
3148
| SYSDATE '(' expr ')'
2737
$$= new (YYSession->mem_root) Item_func_sysdate_local($3);
2738
Lex->setCacheable(false);
3149
{ $$= new (YYSession->mem_root) Item_func_sysdate_local($3); }
2740
3150
| TIMESTAMP_ADD '(' interval_time_stamp ',' expr ',' expr ')'
2741
3151
{ $$= new (YYSession->mem_root) Item_date_add_interval($7,$5,$3,0); }
2742
3152
| TIMESTAMP_DIFF '(' interval_time_stamp ',' expr ',' expr ')'
2819
3184
| QUARTER_SYM '(' expr ')'
2820
3185
{ $$ = new (YYSession->mem_root) Item_func_quarter($3); }
2821
3186
| REPEAT_SYM '(' expr ',' expr ')'
2822
{ $$= new (YYSession->mem_root) Item_func_repeat(*YYSession, $3, $5); }
3187
{ $$= new (YYSession->mem_root) Item_func_repeat($3,$5); }
2823
3188
| REPLACE '(' expr ',' expr ',' expr ')'
2824
{ $$= new (YYSession->mem_root) Item_func_replace(*YYSession, $3, $5, $7); }
3189
{ $$= new (YYSession->mem_root) Item_func_replace($3,$5,$7); }
3190
| REVERSE_SYM '(' expr ')'
3191
{ $$= new (YYSession->mem_root) Item_func_reverse($3); }
2825
3192
| TRUNCATE_SYM '(' expr ',' expr ')'
2826
3193
{ $$= new (YYSession->mem_root) Item_func_round($3,$5,1); }
2827
| WAIT_SYM '(' expr ')'
3194
| WEIGHT_STRING_SYM '(' expr opt_ws_levels ')'
3195
{ $$= new (YYSession->mem_root) Item_func_weight_string($3, 0, $4); }
3196
| 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)))
3198
$$= new (YYSession->mem_root)
3199
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)))
3201
| WEIGHT_STRING_SYM '(' expr AS BINARY ws_nweights ')'
3203
$3= create_func_char_cast(YYSession, $3, $6, &my_charset_bin);
3204
$$= new (YYSession->mem_root)
3205
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); }
4271
NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4272
| HEX_NUM { $$= (ulong) strtol($1.str, (char**) 0, 16); }
4273
| LONG_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4274
| ULONGLONG_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4275
| DECIMAL_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4276
| FLOAT_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4280
NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4281
| HEX_NUM { $$= (ulong) strtol($1.str, (char**) 0, 16); }
4282
| LONG_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4283
| 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); }
4288
NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4289
| ULONGLONG_NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4290
| LONG_NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4291
| DECIMAL_NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4292
| FLOAT_NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4297
{ my_parse_error(ER(ER_ONLY_INTEGERS_ALLOWED)); }
4306
ulong_num { $$= $1 != 0 ? HA_CHOICE_YES : HA_CHOICE_NO; }
4307
| DEFAULT { $$= HA_CHOICE_UNDEF; }
3923
4310
select_var_list_init:
3925
if (not Lex->describe && (not (Lex->result= new select_dumpvar())))
4313
if (!lex->describe && (!(lex->result= new select_dumpvar())))
3926
4314
DRIZZLE_YYABORT;
3928
4316
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;
4375
DROP opt_temporary table_or_tables if_exists table_list
4378
lex->sql_command = SQLCOM_DROP_TABLE;
4379
lex->drop_temporary= $2;
4380
lex->drop_if_exists= $4;
4001
4382
| 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))
4385
lex->sql_command= SQLCOM_DROP_INDEX;
4386
lex->alter_info.reset();
4387
lex->alter_info.flags.set(ALTER_DROP_INDEX);
4388
lex->alter_info.build_method= $2;
4389
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::KEY,
4391
if (!lex->current_select->add_table_to_list(lex->session, $6, NULL,
4392
TL_OPTION_UPDATING))
4010
4393
DRIZZLE_YYABORT;
4012
| DROP DATABASE if_exists schema_name
4395
| DROP DATABASE if_exists ident
4014
statement::DropSchema *statement= new statement::DropSchema(YYSession);
4015
Lex->statement= statement;
4016
statement->drop_if_exists=$3;
4398
lex->sql_command= SQLCOM_DROP_DB;
4399
lex->drop_if_exists=$3;
4023
4404
| table_list ',' table_name
4346
Lex->lock_option= TL_READ;
4348
Lex->current_select->parsing_place= SELECT_LIST;
4759
lex->lock_option= TL_READ;
4760
mysql_init_select(lex);
4761
lex->current_select->parsing_place= SELECT_LIST;
4762
memset(&lex->create_info, 0, sizeof(lex->create_info));
4356
4769
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 */
4772
lex->sql_command= SQLCOM_SHOW_DATABASES;
4774
new(YYSession->mem_root) command::Select(SQLCOM_SHOW_DATABASES,
4776
if (lex->command == NULL)
4778
if (prepare_schema_table(YYSession, lex, 0, "SCHEMATA"))
4781
| opt_full TABLES opt_db show_wild
4784
lex->sql_command= SQLCOM_SHOW_TABLES;
4786
new(YYSession->mem_root) command::Select(SQLCOM_SHOW_TABLES,
4788
if (lex->command == NULL)
4790
lex->select_lex.db= $3;
4791
if (prepare_schema_table(YYSession, lex, 0, "TABLE_NAMES"))
4374
4794
| 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 */
4797
lex->sql_command= SQLCOM_SHOW_TABLE_STATUS;
4799
new(YYSession->mem_root) command::Select(SQLCOM_SHOW_TABLE_STATUS,
4801
if (lex->command == NULL)
4803
lex->select_lex.db= $3;
4804
if (prepare_schema_table(YYSession, lex, 0, "TABLES"))
4807
| OPEN_SYM TABLES opt_db show_wild
4810
lex->sql_command= SQLCOM_SHOW_OPEN_TABLES;
4812
new(YYSession->mem_root) command::Select(SQLCOM_SHOW_OPEN_TABLES,
4814
if (lex->command == NULL)
4816
lex->select_lex.db= $3;
4817
if (prepare_schema_table(YYSession, lex, 0, "OPEN_TABLES"))
4820
| ENGINE_SYM known_storage_engines STATUS_SYM /* This should either go... well it should go */
4822
Lex->show_engine= $2;
4823
Lex->sql_command= SQLCOM_SHOW_ENGINE_STATUS;
4825
| opt_full COLUMNS from_or_in table_ident opt_db show_wild
4828
lex->sql_command= SQLCOM_SHOW_FIELDS;
4830
new(YYSession->mem_root) command::Select(SQLCOM_SHOW_FIELDS, YYSession);
4831
if (lex->command == NULL)
4835
if (prepare_schema_table(YYSession, lex, $4, "COLUMNS"))
4386
4838
| keys_or_index from_or_in table_ident opt_db where_clause
4388
if (not show::buildIndex(YYSession, $4, $3))
4841
lex->sql_command= SQLCOM_SHOW_KEYS;
4842
lex->command= new(YYSession->mem_root) command::Select(SQLCOM_SHOW_KEYS,
4844
if (lex->command == NULL)
4848
if (prepare_schema_table(YYSession, lex, $3, "STATISTICS"))
4391
4851
| COUNT_SYM '(' '*' ')' WARNINGS
4393
show::buildSelectWarning(YYSession);
4853
(void) create_select_for_variable("warning_count");
4855
lex->command= new(YYSession->mem_root) command::Select(SQLCOM_SELECT,
4857
if (lex->command == NULL)
4395
4860
| COUNT_SYM '(' '*' ')' ERRORS
4397
show::buildSelectError(YYSession);
4862
(void) create_select_for_variable("error_count");
4864
lex->command= new(YYSession->mem_root) command::Select(SQLCOM_SELECT,
4866
if (lex->command == NULL)
4399
4869
| WARNINGS opt_limit_clause_init
4401
show::buildWarnings(YYSession);
4870
{ Lex->sql_command = SQLCOM_SHOW_WARNS;}
4403
4871
| ERRORS opt_limit_clause_init
4405
show::buildErrors(YYSession);
4872
{ Lex->sql_command = SQLCOM_SHOW_ERRORS;}
4407
4873
| 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))
4876
lex->sql_command= SQLCOM_SHOW_STATUS;
4878
new(YYSession->mem_root) command::ShowStatus(SQLCOM_SHOW_STATUS,
4881
if (lex->command == NULL)
4883
lex->option_type= $1;
4884
if (prepare_schema_table(YYSession, lex, 0, "STATUS"))
4887
| opt_full PROCESSLIST_SYM
4888
{ Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;}
4889
| opt_var_type VARIABLES show_wild
4892
lex->sql_command= SQLCOM_SHOW_VARIABLES;
4894
new(YYSession->mem_root) command::Select(SQLCOM_SHOW_VARIABLES,
4896
if (lex->command == NULL)
4898
lex->option_type= $1;
4899
if (prepare_schema_table(YYSession, lex, 0, "VARIABLES"))
4902
| CREATE DATABASE opt_if_not_exists ident
4904
Lex->sql_command=SQLCOM_SHOW_CREATE_DB;
4905
Lex->create_info.options=$3;
4417
4908
| 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))
4911
lex->sql_command = SQLCOM_SHOW_CREATE;
4912
if (!lex->select_lex.add_table_to_list(YYSession, $3, NULL,0))
4435
4913
DRIZZLE_YYABORT;
4872
5376
simple_ident_q:
4873
5377
ident '.' ident
4875
$$= parser::buildIdent(Lex, NULL_LEX_STRING, $1, $3);
5379
Session *session= YYSession;
5380
LEX *lex= session->lex;
5383
Select_Lex *sel= lex->current_select;
5384
if (sel->no_table_names_allowed)
5386
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5387
MYF(0), $1.str, session->where);
5389
$$= (sel->parsing_place != IN_HAVING ||
5390
sel->get_in_sum_expr() > 0) ?
5391
(Item*) new Item_field(Lex->current_context(),
5392
(const char *)NULL, $1.str, $3.str) :
5393
(Item*) new Item_ref(Lex->current_context(),
5394
(const char *)NULL, $1.str, $3.str);
4877
5397
| '.' ident '.' ident
4879
$$= parser::buildIdent(Lex, NULL_LEX_STRING, $2, $4);
5399
Session *session= YYSession;
5400
LEX *lex= session->lex;
5401
Select_Lex *sel= lex->current_select;
5402
if (sel->no_table_names_allowed)
5404
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5405
MYF(0), $2.str, session->where);
5407
$$= (sel->parsing_place != IN_HAVING ||
5408
sel->get_in_sum_expr() > 0) ?
5409
(Item*) new Item_field(Lex->current_context(), NULL, $2.str, $4.str) :
5410
(Item*) new Item_ref(Lex->current_context(),
5411
(const char *)NULL, $2.str, $4.str);
4881
5413
| ident '.' ident '.' ident
4883
$$= parser::buildIdent(Lex, $1, $3, $5);
5415
Session *session= YYSession;
5416
LEX *lex= session->lex;
5417
Select_Lex *sel= lex->current_select;
5418
if (sel->no_table_names_allowed)
5420
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5421
MYF(0), $3.str, session->where);
5423
$$= (sel->parsing_place != IN_HAVING ||
5424
sel->get_in_sum_expr() > 0) ?
5425
(Item*) new Item_field(Lex->current_context(),
5426
(YYSession->client_capabilities &
5427
CLIENT_NO_SCHEMA ? NULL : $1.str),
5429
(Item*) new Item_ref(Lex->current_context(),
5430
(YYSession->client_capabilities &
5431
CLIENT_NO_SCHEMA ? NULL : $1.str),
4892
5438
| ident '.' ident '.' ident
4894
if (not parser::checkFieldIdent(Lex, $1, $3))
5441
reinterpret_cast<TableList*>(Lex->current_select->table_list.first);
5442
if (my_strcasecmp(table_alias_charset, $1.str, table->db))
5444
my_error(ER_WRONG_DB_NAME, MYF(0), $1.str);
5447
if (my_strcasecmp(table_alias_charset, $3.str,
5450
my_error(ER_WRONG_TABLE_NAME, MYF(0), $3.str);
4899
5455
| ident '.' ident
4901
if (not parser::checkFieldIdent(Lex, NULL_LEX_STRING, $1))
5458
reinterpret_cast<TableList*>(Lex->current_select->table_list.first);
5459
if (my_strcasecmp(table_alias_charset, $1.str, table->alias))
5461
my_error(ER_WRONG_TABLE_NAME, MYF(0), $1.str);
4902
5462
DRIZZLE_YYABORT;
5466
| '.' ident { $$=$2;} /* For Delphi */
4915
$$= new Table_ident($1);
4917
| schema_name '.' ident
4919
$$=new Table_ident($1,$3);
4923
$$= new Table_ident($2);
5470
ident { $$=new Table_ident($1); }
5471
| ident '.' ident { $$=new Table_ident(YYSession, $1,$3,0);}
5472
| '.' ident { $$=new Table_ident($2);} /* For Delphi */
4942
5479
const CHARSET_INFO * const cs= system_charset_info;
5221
5828
sys_option_value:
5222
5829
option_type internal_variable_name equal set_expr_or_default
5225
5834
{ /* 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)));
5836
lex->option_type= $1;
5837
lex->var_list.push_back(new set_var(lex->option_type, $2.var,
5838
&$2.base_name, $4));
5233
5841
| 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)
5844
lex->option_type= $1;
5845
lex->var_list.push_back(new set_var(lex->option_type,
5846
find_sys_var(YYSession, "tx_isolation"),
5848
new Item_int((int32_t) $5)));
5245
'@' user_variable_ident equal expr
5853
'@' ident_or_text equal expr
5247
Lex->var_list.push_back(SetVarPtr(new set_var_user(new Item_func_set_user_var($2,$4))));
5855
Lex->var_list.push_back(new set_var_user(new Item_func_set_user_var($2,$4)));
5249
5857
| '@' '@' 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; }
5860
lex->var_list.push_back(new set_var($3, $4.var, &$4.base_name, $6));
5270
5864
internal_variable_name:
5271
internal_variable_ident
5867
Session *session= YYSession;
5273
5869
/* We have to lookup here since local vars can shadow sysvars */
5275
5871
/* Not an SP local variable */
5276
sys_var *tmp= find_sys_var(std::string($1.str, $1.length));
5872
sys_var *tmp=find_sys_var(session, $1.str, $1.length);
5278
5874
DRIZZLE_YYABORT;
5280
5876
$$.base_name= null_lex_str;
5881
if (check_reserved_words(&$1))
5883
my_parse_error(ER(ER_SYNTAX_ERROR));
5887
sys_var *tmp=find_sys_var(YYSession, $3.str, $3.length);
5890
if (!tmp->is_struct())
5891
my_error(ER_VARIABLE_IS_NOT_STRUCT, MYF(0), $3.str);
5898
sys_var *tmp=find_sys_var(YYSession, $3.str, $3.length);
5901
if (!tmp->is_struct())
5902
my_error(ER_VARIABLE_IS_NOT_STRUCT, MYF(0), $3.str);
5904
$$.base_name.str= (char*) "default";
5905
$$.base_name.length= 7;
5285
5909
isolation_types: