129
104
This function is not for use in semantic actions and is internal to
130
105
the parser, as it performs some pre-return cleanup.
131
In semantic actions, please use my_parse_error or my_error to
106
In semantic actions, please use parser::my_parse_error or my_error to
132
107
push an error into the error stack and DRIZZLE_YYABORT
133
108
to abort from the parser.
136
111
static void DRIZZLEerror(const char *s)
138
Session *session= current_session;
141
Restore the original LEX if it was replaced when parsing
142
a stored procedure. We must ensure that a parsing error
143
does not leave any side effects in the Session.
145
LEX::cleanup_lex_after_parse_error(session);
147
/* "parse error" changed into "syntax error" between bison 1.75 and 1.875 */
148
if (strcmp(s,"parse error") == 0 || strcmp(s,"syntax error") == 0)
149
s= ER(ER_SYNTAX_ERROR);
154
Helper to resolve the SQL:2003 Syntax exception 1) in <in predicate>.
155
See SQL:2003, Part 2, section 8.4 <in predicate>, Note 184, page 383.
156
This function returns the proper item for the SQL expression
157
<code>left [NOT] IN ( expr )</code>
158
@param session the current thread
159
@param left the in predicand
160
@param equal true for IN predicates, false for NOT IN predicates
161
@param expr first and only expression of the in value list
162
@return an expression representing the IN predicate.
164
static Item* handle_sql2003_note184_exception(Session *session,
165
Item* left, bool equal,
169
Relevant references for this issue:
170
- SQL:2003, Part 2, section 8.4 <in predicate>, page 383,
171
- SQL:2003, Part 2, section 7.2 <row value expression>, page 296,
172
- SQL:2003, Part 2, section 6.3 <value expression primary>, page 174,
173
- SQL:2003, Part 2, section 7.15 <subquery>, page 370,
174
- SQL:2003 Feature F561, "Full value expressions".
176
The exception in SQL:2003 Note 184 means:
177
Item_singlerow_subselect, which corresponds to a <scalar subquery>,
178
should be re-interpreted as an Item_in_subselect, which corresponds
179
to a <table subquery> when used inside an <in predicate>.
181
Our reading of Note 184 is reccursive, so that all:
182
- IN (( <subquery> ))
183
- IN ((( <subquery> )))
184
- IN '('^N <subquery> ')'^N
186
should be interpreted as a <table subquery>, no matter how deep in the
187
expression the <subquery> is.
192
if (expr->type() == Item::SUBSELECT_ITEM)
194
Item_subselect *expr2 = (Item_subselect*) expr;
196
if (expr2->substype() == Item_subselect::SINGLEROW_SUBS)
198
Item_singlerow_subselect *expr3 = (Item_singlerow_subselect*) expr2;
199
Select_Lex *subselect;
202
Implement the mandated change, by altering the semantic tree:
203
left IN Item_singlerow_subselect(subselect)
206
which is represented as
207
Item_in_subselect(left, subselect)
209
subselect= expr3->invalidate_and_restore_select_lex();
210
result= new (session->mem_root) Item_in_subselect(left, subselect);
213
result = negate_expression(session, result);
220
result= new (session->mem_root) Item_func_eq(left, expr);
222
result= new (session->mem_root) Item_func_ne(left, expr);
228
@brief Creates a new Select_Lex for a UNION branch.
230
Sets up and initializes a Select_Lex structure for a query once the parser
231
discovers a UNION token. The current Select_Lex is pushed on the stack and
232
the new Select_Lex becomes the current one..=
234
@lex The parser state.
236
@is_union_distinct True if the union preceding the new select statement
239
@return <code>false</code> if successful, <code>true</code> if an error was
240
reported. In the latter case parsing should stop.
242
static bool add_select_to_union_list(LEX *lex, bool is_union_distinct)
246
/* Only the last SELECT can have INTO...... */
247
my_error(ER_WRONG_USAGE, MYF(0), "UNION", "INTO");
250
if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE)
252
my_parse_error(ER(ER_SYNTAX_ERROR));
255
/* This counter shouldn't be incremented for UNION parts */
257
if (mysql_new_select(lex, 0))
259
mysql_init_select(lex);
260
lex->current_select->linkage=UNION_TYPE;
261
if (is_union_distinct) /* UNION DISTINCT - remember position */
262
lex->current_select->master_unit()->union_distinct=
268
@brief Initializes a Select_Lex for a query within parentheses (aka
271
@return false if successful, true if an error was reported. In the latter
272
case parsing should stop.
274
static bool setup_select_in_parentheses(LEX *lex)
276
Select_Lex * sel= lex->current_select;
277
if (sel->set_braces(1))
279
my_parse_error(ER(ER_SYNTAX_ERROR));
282
if (sel->linkage == UNION_TYPE &&
283
!sel->master_unit()->first_select()->braces &&
284
sel->master_unit()->first_select()->linkage ==
287
my_parse_error(ER(ER_SYNTAX_ERROR));
290
if (sel->linkage == UNION_TYPE &&
291
sel->olap != UNSPECIFIED_OLAP_TYPE &&
292
sel->master_unit()->fake_select_lex)
294
my_error(ER_WRONG_USAGE, MYF(0), "CUBE/ROLLUP", "ORDER BY");
297
/* select in braces, can't contain global parameters */
298
if (sel->master_unit()->fake_select_lex)
299
sel->master_unit()->global_parameters=
300
sel->master_unit()->fake_select_lex;
304
static Item* reserved_keyword_function(const std::string &name, List<Item> *item_list)
306
const plugin::Function *udf= plugin::Function::get(name.c_str(), name.length());
311
item= Create_udf_func::s_singleton.create(current_session, udf, item_list);
313
my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", name.c_str());
319
116
} /* namespace drizzled; */
338
136
drizzled::Key_part_spec *key_part;
339
137
const drizzled::plugin::Function *udf;
340
138
drizzled::TableList *table_list;
341
struct drizzled::sys_var_with_base variable;
342
enum drizzled::sql_var_t var_type;
139
drizzled::enum_field_types field_val;
140
drizzled::sys_var_with_base variable;
141
drizzled::sql_var_t var_type;
343
142
drizzled::Key::Keytype key_type;
344
enum drizzled::ha_key_alg key_alg;
345
enum drizzled::row_type row_type;
346
enum drizzled::column_format_type column_format_type;
347
enum drizzled::ha_rkey_function ha_rkey_mode;
348
enum drizzled::enum_tx_isolation tx_isolation;
349
enum drizzled::Cast_target cast_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;
350
147
const drizzled::CHARSET_INFO *charset;
351
148
drizzled::thr_lock_type lock_type;
352
149
drizzled::interval_type interval, interval_time_st;
353
enum drizzled::enum_drizzle_timestamp_type date_time_type;
150
drizzled::type::timestamp_t date_time_type;
354
151
drizzled::Select_Lex *select_lex;
355
152
drizzled::chooser_compare_func_creator boolfunc2creator;
356
struct drizzled::st_lex *lex;
357
enum drizzled::index_hint_type index_hint;
358
enum drizzled::enum_filetype filetype;
359
enum drizzled::ha_build_method build_method;
360
enum drizzled::Foreign_key::fk_option m_fk_option;
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;
364
162
namespace drizzled
366
bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
164
bool my_yyoverflow(short **a, YYSTYPE **b, unsigned long *yystacksize);
370
169
%pure_parser /* We have threads */
372
Currently there are 88 shift/reduce conflicts.
172
Currently there are 70 shift/reduce conflicts.
373
173
We should not introduce new conflicts any more.
378
178
Comments for TOKENS.
1017
828
/* create a table */
1020
CREATE opt_table_options TABLE_SYM opt_if_not_exists table_ident
1022
Session *session= YYSession;
1023
LEX *lex= session->lex;
1024
lex->sql_command= SQLCOM_CREATE_TABLE;
1025
statement::CreateTable *statement= new(std::nothrow) statement::CreateTable(YYSession);
1026
lex->statement= statement;
1027
if (lex->statement == NULL)
1029
if (!lex->select_lex.add_table_to_list(session, $5, NULL,
1033
lex->col_list.empty();
1034
statement->change=NULL;
1035
statement->is_if_not_exists= $4;
1036
statement->create_info.db_type= NULL;
1037
statement->create_info.default_table_charset= NULL;
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);
1040
message::Table &proto= statement->create_table_message;
1042
proto.set_name($5->table.str);
1044
proto.set_type(message::Table::TEMPORARY);
1046
proto.set_type(message::Table::STANDARD);
839
if (not Lex->select_lex.add_table_to_list(YYSession, $5, NULL,
843
Lex->col_list.empty();
845
create_table_definition
1050
LEX *lex= YYSession->lex;
1051
lex->current_select= &lex->select_lex;
847
Lex->current_select= &Lex->select_lex;
1053
849
| CREATE build_method
1056
lex->sql_command= SQLCOM_CREATE_INDEX;
1057
statement::CreateIndex *statement= new(std::nothrow) statement::CreateIndex(YYSession);
1058
lex->statement= statement;
1059
if (lex->statement == NULL)
1061
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1062
statement->alter_info.build_method= $2;
1063
lex->col_list.empty();
1064
statement->change=NULL;
851
Lex->statement= new statement::CreateIndex(YYSession, $2);
1066
853
opt_unique INDEX_SYM ident key_alg ON table_ident '(' key_list ')' key_options
1069
statement::CreateIndex *statement= (statement::CreateIndex *)Lex->statement;
855
if (not Lex->current_select->add_table_to_list(Lex->session, $9,
1071
if (!lex->current_select->add_table_to_list(lex->session, $9,
1073
TL_OPTION_UPDATING))
1076
key= new Key($4, $6, &statement->key_create_info, 0, lex->col_list);
1077
statement->alter_info.key_list.push_back(key);
1078
lex->col_list.empty();
860
parser::buildKey(Lex, $4, $6);
1080
| CREATE DATABASE opt_if_not_exists ident
862
| CREATE DATABASE opt_if_not_exists schema_name
1084
lex->sql_command=SQLCOM_CREATE_DB;
1085
statement::CreateSchema *statement= new(std::nothrow) statement::CreateSchema(YYSession);
1086
lex->statement= statement;
1087
if (lex->statement == NULL)
1089
statement->is_if_not_exists= $3;
864
Lex->statement= new statement::CreateSchema(YYSession);
1091
866
opt_create_database_options
1099
| opt_create_table_options
1101
| LIKE table_ident opt_create_table_options
1103
Session *session= YYSession;
1104
LEX *lex= session->lex;
1105
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1107
statement->is_create_table_like= true;
1108
if (!lex->select_lex.add_table_to_list(session, $2, NULL, 0, TL_READ))
1111
| '(' LIKE table_ident ')'
1113
Session *session= YYSession;
1114
LEX *lex= session->lex;
1115
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1117
statement->is_create_table_like= true;
1118
if (!lex->select_lex.add_table_to_list(session, $3, NULL, 0, TL_READ))
1124
field_list ')' opt_create_table_options
1127
{ Lex->current_select->set_braces(1);}
872
create_table_definition:
873
'(' field_list ')' opt_create_table_options create_select_as
875
| '(' create_select ')'
877
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
1133
| opt_duplicate opt_as create_select
1134
{ Lex->current_select->set_braces(0);}
890
| opt_duplicate_as create_select
892
Lex->current_select->set_braces(0);
1136
| opt_duplicate opt_as '(' create_select ')'
1137
{ Lex->current_select->set_braces(1);}
895
| opt_duplicate_as '(' create_select ')'
897
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
1145
lex->lock_option= TL_READ;
1146
if (lex->sql_command == SQLCOM_INSERT)
924
Lex->lock_option= TL_READ;
925
if (Lex->sql_command == SQLCOM_INSERT)
1148
lex->sql_command= SQLCOM_INSERT_SELECT;
1149
delete lex->statement;
1151
new(std::nothrow) statement::InsertSelect(YYSession);
1152
if (lex->statement == NULL)
927
delete Lex->statement;
928
Lex->statement= new statement::InsertSelect(YYSession);
1155
else if (lex->sql_command == SQLCOM_REPLACE)
930
else if (Lex->sql_command == SQLCOM_REPLACE)
1157
lex->sql_command= SQLCOM_REPLACE_SELECT;
1158
delete lex->statement;
1160
new(std::nothrow) statement::ReplaceSelect(YYSession);
1161
if (lex->statement == NULL)
932
delete Lex->statement;
933
Lex->statement= new statement::ReplaceSelect(YYSession);
1165
936
The following work only with the local list, the global list
1166
937
is created correctly in this case
1168
lex->current_select->table_list.save_and_clear(&lex->save_list);
1169
mysql_init_select(lex);
1170
lex->current_select->parsing_place= SELECT_LIST;
939
Lex->current_select->table_list.save_and_clear(&Lex->save_list);
941
Lex->current_select->parsing_place= SELECT_LIST;
1172
943
select_options select_item_list
1217
1005
create_table_option
1218
1006
| create_table_option create_table_options
1219
1007
| create_table_option ',' create_table_options
1222
1009
create_table_option:
1223
ENGINE_SYM opt_equal ident_or_text
1225
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1226
message::Table::StorageEngine *protoengine;
1227
protoengine= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_engine();
1229
statement->is_engine_set= true;
1231
protoengine->set_name($3.str);
1233
| BLOCK_SIZE_SYM opt_equal ulong_num
1235
message::Table::TableOptions *tableopts;
1236
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1237
tableopts= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_options();
1239
tableopts->set_block_size($3);
1240
statement->create_info.used_fields|= HA_CREATE_USED_BLOCK_SIZE;
1010
custom_engine_option;
1012
custom_engine_option:
1013
ENGINE_SYM equal ident_or_text
1015
Lex->table()->mutable_engine()->set_name($3.str);
1242
1017
| COMMENT_SYM opt_equal TEXT_STRING_sys
1244
message::Table::TableOptions *tableopts;
1245
tableopts= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_options();
1247
tableopts->set_comment($3.str);
1019
Lex->table()->mutable_options()->set_comment($3.str);
1249
1021
| AUTO_INC opt_equal ulonglong_num
1251
message::Table::TableOptions *tableopts;
1252
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1254
tableopts= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_options();
1256
statement->create_info.auto_increment_value=$3;
1257
statement->create_info.used_fields|= HA_CREATE_USED_AUTO;
1258
tableopts->set_auto_increment_value($3);
1260
| ROW_FORMAT_SYM opt_equal row_types
1262
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1263
message::Table::TableOptions *table_options= statement->createTableMessage().mutable_options();
1265
statement->create_info.row_type= $3;
1266
statement->create_info.used_fields|= HA_CREATE_USED_ROW_FORMAT;
1267
statement->alter_info.flags.set(ALTER_ROW_FORMAT);
1269
switch(statement->create_info.row_type)
1271
case ROW_TYPE_DEFAULT:
1272
/* No use setting a default row type... just adds redundant info to message */
1274
case ROW_TYPE_FIXED:
1275
table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_FIXED);
1277
case ROW_TYPE_DYNAMIC:
1278
table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_DYNAMIC);
1280
case ROW_TYPE_COMPRESSED:
1281
table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_COMPRESSED);
1283
case ROW_TYPE_REDUNDANT:
1284
table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_REDUNDANT);
1286
case ROW_TYPE_COMPACT:
1287
table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_COMPACT);
1290
table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_PAGE);
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);
1296
1041
| default_collation
1297
| KEY_BLOCK_SIZE opt_equal ulong_num
1299
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1301
statement->create_info.used_fields|= HA_CREATE_USED_KEY_BLOCK_SIZE;
1303
message::Table::TableOptions *tableopts;
1304
tableopts= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_options();
1305
tableopts->set_key_block_size($3);
1309
1044
default_collation:
1310
1045
opt_default COLLATE_SYM opt_equal collation_name_or_default
1312
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1314
HA_CREATE_INFO *cinfo= &statement->create_info;
1315
if ((cinfo->used_fields & HA_CREATE_USED_DEFAULT_CHARSET) &&
1316
cinfo->default_table_charset && $4 &&
1317
!my_charset_same(cinfo->default_table_charset,$4))
1319
my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
1320
$4->name, cinfo->default_table_charset->csname);
1323
statement->create_info.default_table_charset= $4;
1324
statement->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET;
1047
if (not parser::buildCollation(Lex, $4))
1328
1054
default_collation_schema:
1329
1055
opt_default COLLATE_SYM opt_equal collation_name_or_default
1331
statement::CreateSchema *statement= (statement::CreateSchema *)Lex->statement;
1333
message::Schema &schema_message= statement->schema_message;
1334
schema_message.set_collation($4->name);
1338
column_format_types:
1339
DEFAULT { $$= COLUMN_FORMAT_TYPE_DEFAULT; }
1340
| FIXED_SYM { $$= COLUMN_FORMAT_TYPE_FIXED; }
1341
| DYNAMIC_SYM { $$= COLUMN_FORMAT_TYPE_DYNAMIC; };
1344
DEFAULT { $$= ROW_TYPE_DEFAULT; }
1345
| FIXED_SYM { $$= ROW_TYPE_FIXED; }
1346
| DYNAMIC_SYM { $$= ROW_TYPE_DYNAMIC; }
1347
| COMPRESSED_SYM { $$= ROW_TYPE_COMPRESSED; }
1348
| REDUNDANT_SYM { $$= ROW_TYPE_REDUNDANT; }
1349
| COMPACT_SYM { $$= ROW_TYPE_COMPACT; }
1350
| PAGE_SYM { $$= ROW_TYPE_PAGE; }
1057
((statement::CreateSchema *)Lex->statement)->schema_message.set_collation($4->name);
1073
$$.str= YYSession->strmake($1.str, $1.length);
1074
$$.length= $1.length;
1353
1078
opt_select_from:
1447
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1448
lex->length=lex->dec=0;
1450
statement->default_value= statement->on_update_value= 0;
1451
statement->comment= null_lex_str;
1453
statement->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
1455
message::AlterTable &alter_proto=
1456
((statement::CreateTable *)Lex->statement)->alter_info.alter_proto;
1457
statement->current_proto_field= alter_proto.add_added_field();
1146
parser::buildCreateFieldIdent(Lex);
1462
1150
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1464
if (statement->current_proto_field)
1465
statement->current_proto_field->set_name($1.str);
1154
Lex->field()->set_name($1.str);
1467
if (add_field_to_list(lex->session, &$1, (enum enum_field_types) $3,
1468
lex->length,lex->dec,lex->type,
1157
if (add_field_to_list(Lex->session, &$1, (enum enum_field_types) $3,
1158
Lex->length, Lex->dec, Lex->type,
1469
1159
statement->column_format,
1470
1160
statement->default_value, statement->on_update_value,
1471
1161
&statement->comment,
1472
statement->change, &lex->interval_list, lex->charset))
1162
statement->change, &Lex->interval_list, Lex->charset))
1473
1163
DRIZZLE_YYABORT;
1475
statement->current_proto_field= NULL;
1165
Lex->setField(NULL);
1479
type opt_attribute {}
1170
field_definition opt_attribute {}
1486
Lex->length=(char*) 0; /* use default length */
1487
statement::CreateTable *statement=
1488
(statement::CreateTable *)Lex->statement;
1490
if (statement->current_proto_field)
1492
if ($1 == DRIZZLE_TYPE_LONG)
1493
statement->current_proto_field->set_type(message::Table::Field::INTEGER);
1494
else if ($1 == DRIZZLE_TYPE_LONGLONG)
1495
statement->current_proto_field->set_type(message::Table::Field::BIGINT);
1174
int_type ignored_field_number_length opt_field_number_signed opt_zerofill
1176
$$= parser::buildIntegerColumn(Lex, $1, ($3 or $4));
1500
1178
| real_type opt_precision
1504
statement::CreateTable *statement=
1505
(statement::CreateTable *)Lex->statement;
1507
if (statement->current_proto_field)
1509
assert ($1 == DRIZZLE_TYPE_DOUBLE);
1510
statement->current_proto_field->set_type(message::Table::Field::DOUBLE);
1516
$$=DRIZZLE_TYPE_VARCHAR;
1518
statement::CreateTable *statement=
1519
(statement::CreateTable *)Lex->statement;
1521
if (statement->current_proto_field)
1523
statement->current_proto_field->set_type(message::Table::Field::VARCHAR);
1524
message::Table::Field::StringFieldOptions *string_field_options;
1526
string_field_options= statement->current_proto_field->mutable_string_options();
1528
string_field_options->set_length(atoi($3.str));
1533
Lex->length=(char*) "1";
1534
$$=DRIZZLE_TYPE_VARCHAR;
1536
statement::CreateTable *statement=
1537
(statement::CreateTable *)Lex->statement;
1539
if (statement->current_proto_field)
1540
statement->current_proto_field->set_type(message::Table::Field::VARCHAR);
1542
| varchar '(' NUM ')'
1545
$$= DRIZZLE_TYPE_VARCHAR;
1547
statement::CreateTable *statement=
1548
(statement::CreateTable *)Lex->statement;
1550
if (statement->current_proto_field)
1552
statement->current_proto_field->set_type(message::Table::Field::VARCHAR);
1554
message::Table::Field::StringFieldOptions *string_field_options;
1556
string_field_options= statement->current_proto_field->mutable_string_options();
1558
string_field_options->set_length(atoi($3.str));
1561
| VARBINARY '(' NUM ')'
1564
Lex->charset=&my_charset_bin;
1565
$$= DRIZZLE_TYPE_VARCHAR;
1567
statement::CreateTable *statement=
1568
(statement::CreateTable *)Lex->statement;
1570
if (statement->current_proto_field)
1572
statement->current_proto_field->set_type(message::Table::Field::VARCHAR);
1573
message::Table::Field::StringFieldOptions *string_field_options;
1575
string_field_options= statement->current_proto_field->mutable_string_options();
1577
string_field_options->set_length(atoi($3.str));
1578
string_field_options->set_collation_id(my_charset_bin.number);
1579
string_field_options->set_collation(my_charset_bin.name);
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);
1195
| VARBINARY '(' NUM ')'
1197
$$= parser::buildVarbinaryColumn(Lex, $3.str);
1584
1201
$$=DRIZZLE_TYPE_DATE;
1586
statement::CreateTable *statement=
1587
(statement::CreateTable *)Lex->statement;
1589
if (statement->current_proto_field)
1590
statement->current_proto_field->set_type(message::Table::Field::DATE);
1594
$$=DRIZZLE_TYPE_TIMESTAMP;
1596
statement::CreateTable *statement=
1597
(statement::CreateTable *)Lex->statement;
1599
if (statement->current_proto_field)
1600
statement->current_proto_field->set_type(message::Table::Field::TIMESTAMP);
1204
Lex->field()->set_type(message::Table::Field::DATE);
1208
$$=DRIZZLE_TYPE_TIME;
1211
Lex->field()->set_type(message::Table::Field::TIME);
1215
$$=parser::buildTimestampColumn(Lex, NULL);
1217
| TIMESTAMP_SYM '(' NUM ')'
1219
$$=parser::buildTimestampColumn(Lex, $3.str);
1604
1223
$$=DRIZZLE_TYPE_DATETIME;
1606
statement::CreateTable *statement=
1607
(statement::CreateTable *)Lex->statement;
1609
if (statement->current_proto_field)
1610
statement->current_proto_field->set_type(message::Table::Field::DATETIME);
1614
Lex->charset=&my_charset_bin;
1615
$$=DRIZZLE_TYPE_BLOB;
1616
Lex->length=(char*) 0; /* use default length */
1618
statement::CreateTable *statement=
1619
(statement::CreateTable *)Lex->statement;
1621
if (statement->current_proto_field)
1623
statement->current_proto_field->set_type(message::Table::Field::BLOB);
1624
message::Table::Field::StringFieldOptions *string_field_options;
1626
string_field_options= statement->current_proto_field->mutable_string_options();
1627
string_field_options->set_collation_id(my_charset_bin.number);
1628
string_field_options->set_collation(my_charset_bin.name);
1633
$$=DRIZZLE_TYPE_BLOB;
1634
Lex->length=(char*) 0; /* use default length */
1636
statement::CreateTable *statement=
1637
(statement::CreateTable *)Lex->statement;
1639
if (statement->current_proto_field)
1640
statement->current_proto_field->set_type(message::Table::Field::BLOB);
1642
| DECIMAL_SYM float_options
1644
$$=DRIZZLE_TYPE_DECIMAL;
1646
statement::CreateTable *statement=
1647
(statement::CreateTable *)Lex->statement;
1649
if (statement->current_proto_field)
1650
statement->current_proto_field->set_type(message::Table::Field::DECIMAL);
1652
| NUMERIC_SYM float_options
1654
$$=DRIZZLE_TYPE_DECIMAL;
1656
statement::CreateTable *statement=
1657
(statement::CreateTable *)Lex->statement;
1659
if (statement->current_proto_field)
1660
statement->current_proto_field->set_type(message::Table::Field::DECIMAL);
1662
| FIXED_SYM float_options
1664
$$=DRIZZLE_TYPE_DECIMAL;
1666
statement::CreateTable *statement=
1667
(statement::CreateTable *)Lex->statement;
1669
if (statement->current_proto_field)
1670
statement->current_proto_field->set_type(message::Table::Field::DECIMAL);
1673
{Lex->interval_list.empty();}
1226
Lex->field()->set_type(message::Table::Field::DATETIME);
1230
$$= parser::buildBlobColumn(Lex);
1234
$$=DRIZZLE_TYPE_BLOB;
1235
Lex->length=(char*) 0; /* use default length */
1238
Lex->field()->set_type(message::Table::Field::BLOB);
1240
| DECIMAL_SYM float_options
1242
$$= parser::buildDecimalColumn(Lex);
1244
| NUMERIC_SYM float_options
1246
$$= parser::buildDecimalColumn(Lex);
1248
| FIXED_SYM float_options
1250
$$= parser::buildDecimalColumn(Lex);
1254
Lex->interval_list.empty();
1676
1258
$$=DRIZZLE_TYPE_ENUM;
1678
statement::CreateTable *statement=
1679
(statement::CreateTable *)Lex->statement;
1681
if (statement->current_proto_field)
1682
statement->current_proto_field->set_type(message::Table::Field::ENUM);
1261
Lex->field()->set_type(message::Table::Field::ENUM);
1265
$$= parser::buildUuidColumn(Lex);
1269
$$= parser::buildBooleanColumn(Lex);
1686
$$=DRIZZLE_TYPE_LONGLONG;
1687
Lex->type|= (AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_FLAG);
1689
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1690
if (statement->current_proto_field)
1692
message::Table::Field::FieldConstraints *constraints;
1693
constraints= statement->current_proto_field->mutable_constraints();
1694
constraints->set_is_nullable(false);
1696
statement->current_proto_field->set_type(message::Table::Field::BIGINT);
1273
$$= parser::buildSerialColumn(Lex);
1801
1392
statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1803
1394
| ON UPDATE_SYM NOW_SYM optional_braces
1804
{ ((statement::AlterTable *)Lex->statement)->on_update_value= new Item_func_now_local(); }
1396
((statement::AlterTable *)Lex->statement)->on_update_value= new Item_func_now_local();
1807
Lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG;
1809
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1810
if (statement->current_proto_field)
1812
message::Table::Field::FieldConstraints *constraints;
1814
constraints= statement->current_proto_field->mutable_constraints();
1815
constraints->set_is_nullable(false);
1400
parser::buildAutoOnColumn(Lex);
1818
1402
| SERIAL_SYM DEFAULT VALUE_SYM
1821
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1823
lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_FLAG;
1824
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1826
if (statement->current_proto_field)
1828
message::Table::Field::FieldConstraints *constraints;
1829
constraints= statement->current_proto_field->mutable_constraints();
1830
constraints->set_is_nullable(false);
1404
(void)parser::buildSerialColumn(Lex);
1833
1406
| opt_primary KEY_SYM
1836
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1838
lex->type|= PRI_KEY_FLAG | NOT_NULL_FLAG;
1839
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1841
if (statement->current_proto_field)
1843
message::Table::Field::FieldConstraints *constraints;
1844
constraints= statement->current_proto_field->mutable_constraints();
1845
constraints->set_is_nullable(false);
1408
parser::buildPrimaryOnColumn(Lex);
1851
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1853
lex->type|= UNIQUE_FLAG;
1854
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1412
parser::buildKeyOnColumn(Lex);
1856
1414
| UNIQUE_SYM KEY_SYM
1859
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1861
lex->type|= UNIQUE_KEY_FLAG;
1862
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1416
parser::buildKeyOnColumn(Lex);
1864
1418
| COMMENT_SYM TEXT_STRING_sys
1866
1420
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1867
1421
statement->comment= $2;
1869
if (statement->current_proto_field)
1870
statement->current_proto_field->set_comment($2.str);
1424
Lex->field()->set_comment($2.str);
1872
1426
| COLLATE_SYM collation_name
4733
lex->lock_option= TL_READ;
4734
mysql_init_select(lex);
4735
lex->current_select->parsing_place= SELECT_LIST;
4346
Lex->lock_option= TL_READ;
4348
Lex->current_select->parsing_place= SELECT_LIST;
4742
4356
DATABASES show_wild
4745
Session *session= YYSession;
4747
lex->sql_command= SQLCOM_SELECT;
4749
new(std::nothrow) statement::Select(session);
4750
if (lex->statement == NULL)
4753
std::string column_name= "Database";
4756
column_name.append(" (");
4757
column_name.append(Lex->wild->ptr());
4758
column_name.append(")");
4761
if (Lex->current_select->where)
4763
if (prepare_new_schema_table(session, lex, "SCHEMAS"))
4768
if (prepare_new_schema_table(session, lex, "SHOW_SCHEMAS"))
4772
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "SCHEMA_NAME");
4773
my_field->is_autogenerated_name= false;
4774
my_field->set_name(column_name.c_str(), column_name.length(), system_charset_info);
4776
if (session->add_item_to_list(my_field))
4358
if (not show::buildScemas(YYSession))
4777
4359
DRIZZLE_YYABORT;
4779
4362
| TABLES opt_db show_wild
4782
Session *session= YYSession;
4784
lex->sql_command= SQLCOM_SELECT;
4786
statement::Select *select=
4787
new(std::nothrow) statement::Select(YYSession);
4789
lex->statement= select;
4791
if (lex->statement == NULL)
4795
std::string column_name= "Tables_in_";
4799
SchemaIdentifier identifier($2);
4800
column_name.append($2);
4801
lex->select_lex.db= $2;
4802
if (not plugin::StorageEngine::doesSchemaExist(identifier))
4804
my_error(ER_BAD_DB_ERROR, MYF(0), $2);
4806
select->setShowPredicate($2, "");
4808
else if (not session->db.empty())
4810
column_name.append(session->db);
4811
select->setShowPredicate(session->db, "");
4815
my_error(ER_NO_DB_ERROR, MYF(0));
4821
column_name.append(" (");
4822
column_name.append(Lex->wild->ptr());
4823
column_name.append(")");
4826
if (prepare_new_schema_table(YYSession, lex, "SHOW_TABLES"))
4829
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "TABLE_NAME");
4830
my_field->is_autogenerated_name= false;
4831
my_field->set_name(column_name.c_str(), column_name.length(), system_charset_info);
4833
if (session->add_item_to_list(my_field))
4364
if (not show::buildTables(YYSession, $2))
4834
4365
DRIZZLE_YYABORT;
4367
/* SHOW TEMPORARY TABLES */
4836
4368
| TEMPORARY_SYM TABLES show_wild
4839
Session *session= YYSession;
4841
lex->sql_command= SQLCOM_SELECT;
4843
statement::Select *select=
4844
new(std::nothrow) statement::Select(YYSession);
4846
lex->statement= select;
4848
if (lex->statement == NULL)
4852
if (prepare_new_schema_table(YYSession, lex, "SHOW_TEMPORARY_TABLES"))
4855
if (session->add_item_to_list( new Item_field(&session->lex->current_select->
4859
(session->lex->current_select->with_wild)++;
4370
if (not show::buildTemporaryTables(YYSession))
4373
/* SHOW TABLE STATUS */
4862
4374
| TABLE_SYM STATUS_SYM opt_db show_wild
4865
lex->sql_command= SQLCOM_SELECT;
4866
statement::Select *select=
4867
new(std::nothrow) statement::Select(YYSession);
4869
lex->statement= select;
4871
if (lex->statement == NULL)
4874
Session *session= YYSession;
4876
std::string column_name= "Tables_in_";
4880
lex->select_lex.db= $3;
4882
SchemaIdentifier identifier($3);
4883
if (not plugin::StorageEngine::doesSchemaExist(identifier))
4885
my_error(ER_BAD_DB_ERROR, MYF(0), $3);
4888
select->setShowPredicate($3, "");
4892
select->setShowPredicate(session->db, "");
4895
if (prepare_new_schema_table(session, lex, "SHOW_TABLE_STATUS"))
4898
if (session->add_item_to_list( new Item_field(&session->lex->current_select->
4902
(session->lex->current_select->with_wild)++;
4376
if (not show::buildTableStatus(YYSession, $3))
4379
/* SHOW COLUMNS FROM table_name */
4904
4380
| COLUMNS from_or_in table_ident opt_db show_wild
4907
Session *session= YYSession;
4908
statement::Select *select;
4910
lex->sql_command= SQLCOM_SELECT;
4912
select= new(std::nothrow) statement::Select(session);
4914
lex->statement= select;
4916
if (lex->statement == NULL)
4920
select->setShowPredicate($4, $3->table.str);
4921
else if ($3->db.str)
4922
select->setShowPredicate($3->db.str, $3->table.str);
4924
select->setShowPredicate(session->db, $3->table.str);
4927
drizzled::TableIdentifier identifier(select->getShowSchema().c_str(), $3->table.str);
4928
if (not plugin::StorageEngine::doesTableExist(*session, identifier))
4930
my_error(ER_NO_SUCH_TABLE, MYF(0),
4931
select->getShowSchema().c_str(),
4936
if (prepare_new_schema_table(session, lex, "SHOW_COLUMNS"))
4939
if (session->add_item_to_list( new Item_field(&session->lex->current_select->
4943
(session->lex->current_select->with_wild)++;
4382
if (not show::buildColumns(YYSession, $4, $3))
4385
/* SHOW INDEXES from table */
4946
4386
| keys_or_index from_or_in table_ident opt_db where_clause
4949
Session *session= YYSession;
4950
statement::Select *select;
4952
lex->sql_command= SQLCOM_SELECT;
4954
select= new(std::nothrow) statement::Select(session);
4956
lex->statement= select;
4958
if (lex->statement == NULL)
4962
select->setShowPredicate($4, $3->table.str);
4963
else if ($3->db.str)
4964
select->setShowPredicate($3->db.str, $3->table.str);
4966
select->setShowPredicate(session->db, $3->table.str);
4969
drizzled::TableIdentifier identifier(select->getShowSchema().c_str(), $3->table.str);
4970
if (not plugin::StorageEngine::doesTableExist(*session, identifier))
4972
my_error(ER_NO_SUCH_TABLE, MYF(0),
4973
select->getShowSchema().c_str(),
4978
if (prepare_new_schema_table(session, lex, "SHOW_INDEXES"))
4981
if (session->add_item_to_list( new Item_field(&session->lex->current_select->
4985
(session->lex->current_select->with_wild)++;
4388
if (not show::buildIndex(YYSession, $4, $3))
4987
4391
| COUNT_SYM '(' '*' ')' WARNINGS
4989
(void) create_select_for_variable("warning_count");
4991
lex->statement= new(std::nothrow) statement::Select(YYSession);
4992
if (lex->statement == NULL)
4393
show::buildSelectWarning(YYSession);
4995
4395
| COUNT_SYM '(' '*' ')' ERRORS
4997
(void) create_select_for_variable("error_count");
4999
lex->statement= new(std::nothrow) statement::Select(YYSession);
5000
if (lex->statement == NULL)
4397
show::buildSelectError(YYSession);
5003
4399
| WARNINGS opt_limit_clause_init
5005
Lex->sql_command = SQLCOM_SHOW_WARNS;
5006
Lex->statement= new(std::nothrow) statement::ShowWarnings(YYSession);
5007
if (Lex->statement == NULL)
4401
show::buildWarnings(YYSession);
5010
4403
| ERRORS opt_limit_clause_init
5012
Lex->sql_command = SQLCOM_SHOW_ERRORS;
5013
Lex->statement= new(std::nothrow) statement::ShowErrors(YYSession);
5014
if (Lex->statement == NULL)
4405
show::buildErrors(YYSession);
5017
4407
| opt_var_type STATUS_SYM show_wild
5020
lex->sql_command= SQLCOM_SELECT;
5022
new(std::nothrow) statement::Select(YYSession);
5023
if (lex->statement == NULL)
5026
Session *session= YYSession;
5028
if ($1 == OPT_GLOBAL)
5030
if (prepare_new_schema_table(session, lex, "GLOBAL_STATUS"))
5035
if (prepare_new_schema_table(session, lex, "SESSION_STATUS"))
5039
std::string key("Variable_name");
5040
std::string value("Value");
5042
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "VARIABLE_NAME");
5043
my_field->is_autogenerated_name= false;
5044
my_field->set_name(key.c_str(), key.length(), system_charset_info);
5046
if (session->add_item_to_list(my_field))
5049
my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "VARIABLE_VALUE");
5050
my_field->is_autogenerated_name= false;
5051
my_field->set_name(value.c_str(), value.length(), system_charset_info);
5053
if (session->add_item_to_list(my_field))
4409
if (not show::buildStatus(YYSession, $1))
4412
| engine_option_value STATUS_SYM
4414
if (not show::buildEngineStatus(YYSession, $1))
4417
| CREATE TABLE_SYM table_ident
4419
if (not show::buildCreateTable(YYSession, $3))
5056
4422
| PROCESSLIST_SYM
5060
lex->sql_command= SQLCOM_SELECT;
5062
new(std::nothrow) statement::Select(YYSession);
5063
if (lex->statement == NULL)
5066
Session *session= YYSession;
5068
if (prepare_new_schema_table(session, lex, "PROCESSLIST"))
5071
if (session->add_item_to_list( new Item_field(&session->lex->current_select->
5075
(session->lex->current_select->with_wild)++;
4424
if (not show::buildProcesslist(YYSession))
5078
4427
| opt_var_type VARIABLES show_wild
5081
lex->sql_command= SQLCOM_SELECT;
5083
new(std::nothrow) statement::Select(YYSession);
5084
if (lex->statement == NULL)
5087
Session *session= YYSession;
5089
if ($1 == OPT_GLOBAL)
5091
if (prepare_new_schema_table(session, lex, "GLOBAL_VARIABLES"))
5096
if (prepare_new_schema_table(session, lex, "SESSION_VARIABLES"))
5100
std::string key("Variable_name");
5101
std::string value("Value");
5103
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "VARIABLE_NAME");
5104
my_field->is_autogenerated_name= false;
5105
my_field->set_name(key.c_str(), key.length(), system_charset_info);
5107
if (session->add_item_to_list(my_field))
5110
my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "VARIABLE_VALUE");
5111
my_field->is_autogenerated_name= false;
5112
my_field->set_name(value.c_str(), value.length(), system_charset_info);
5114
if (session->add_item_to_list(my_field))
4429
if (not show::buildVariables(YYSession, $1))
5117
4432
| CREATE DATABASE opt_if_not_exists ident
5119
Lex->sql_command=SQLCOM_SHOW_CREATE_DB;
5120
statement::ShowCreateSchema *statement= new(std::nothrow) statement::ShowCreateSchema(YYSession);
5121
Lex->statement= statement;
5122
if (Lex->statement == NULL)
5124
statement->is_if_not_exists= $3;
5127
| CREATE TABLE_SYM table_ident
5130
lex->sql_command = SQLCOM_SHOW_CREATE;
5131
lex->statement= new(std::nothrow) statement::ShowCreate(YYSession);
5132
if (lex->statement == NULL)
5134
if (!lex->select_lex.add_table_to_list(YYSession, $3, NULL,0))
4434
if (not show::buildCreateSchema(YYSession, $4))
5135
4435
DRIZZLE_YYABORT;
5644
4872
simple_ident_q:
5645
4873
ident '.' ident
5647
Session *session= YYSession;
5648
LEX *lex= session->lex;
5651
Select_Lex *sel= lex->current_select;
5652
if (sel->no_table_names_allowed)
5654
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5655
MYF(0), $1.str, session->where);
5657
$$= (sel->parsing_place != IN_HAVING ||
5658
sel->get_in_sum_expr() > 0) ?
5659
(Item*) new Item_field(Lex->current_context(),
5660
(const char *)NULL, $1.str, $3.str) :
5661
(Item*) new Item_ref(Lex->current_context(),
5662
(const char *)NULL, $1.str, $3.str);
4875
$$= parser::buildIdent(Lex, NULL_LEX_STRING, $1, $3);
5665
4877
| '.' ident '.' ident
5667
Session *session= YYSession;
5668
LEX *lex= session->lex;
5669
Select_Lex *sel= lex->current_select;
5670
if (sel->no_table_names_allowed)
5672
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5673
MYF(0), $2.str, session->where);
5675
$$= (sel->parsing_place != IN_HAVING ||
5676
sel->get_in_sum_expr() > 0) ?
5677
(Item*) new Item_field(Lex->current_context(), NULL, $2.str, $4.str) :
5678
(Item*) new Item_ref(Lex->current_context(),
5679
(const char *)NULL, $2.str, $4.str);
4879
$$= parser::buildIdent(Lex, NULL_LEX_STRING, $2, $4);
5681
4881
| ident '.' ident '.' ident
5683
Session *session= YYSession;
5684
LEX *lex= session->lex;
5685
Select_Lex *sel= lex->current_select;
5686
if (sel->no_table_names_allowed)
5688
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5689
MYF(0), $3.str, session->where);
5691
$$= (sel->parsing_place != IN_HAVING ||
5692
sel->get_in_sum_expr() > 0) ?
5693
(Item*) new Item_field(Lex->current_context(), $1.str, $3.str,
5695
(Item*) new Item_ref(Lex->current_context(), $1.str, $3.str,
4883
$$= parser::buildIdent(Lex, $1, $3, $5);
5702
4892
| ident '.' ident '.' ident
5705
reinterpret_cast<TableList*>(Lex->current_select->table_list.first);
5706
if (my_strcasecmp(table_alias_charset, $1.str, table->db))
5708
my_error(ER_WRONG_DB_NAME, MYF(0), $1.str);
5711
if (my_strcasecmp(table_alias_charset, $3.str,
5714
my_error(ER_WRONG_TABLE_NAME, MYF(0), $3.str);
4894
if (not parser::checkFieldIdent(Lex, $1, $3))
5719
4899
| ident '.' ident
5722
reinterpret_cast<TableList*>(Lex->current_select->table_list.first);
5723
if (my_strcasecmp(table_alias_charset, $1.str, table->alias))
5725
my_error(ER_WRONG_TABLE_NAME, MYF(0), $1.str);
4901
if (not parser::checkFieldIdent(Lex, NULL_LEX_STRING, $1))
5726
4902
DRIZZLE_YYABORT;
5730
| '.' ident { $$=$2;} /* For Delphi */
5734
ident { $$=new Table_ident($1); }
5735
| ident '.' ident { $$=new Table_ident($1,$3);}
5736
| '.' ident { $$=new Table_ident($2);} /* For Delphi */
4915
$$= new Table_ident($1);
4917
| schema_name '.' ident
4919
$$=new Table_ident($1,$3);
4923
$$= new Table_ident($2);
5743
4942
const CHARSET_INFO * const cs= system_charset_info;