99
129
This function is not for use in semantic actions and is internal to
100
130
the parser, as it performs some pre-return cleanup.
101
In semantic actions, please use parser::my_parse_error or my_error to
131
In semantic actions, please use my_parse_error or my_error to
102
132
push an error into the error stack and DRIZZLE_YYABORT
103
133
to abort from the parser.
106
static void base_sql_error(drizzled::Session *session, const char *s)
108
parser::errorOn(session, s);
136
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());
111
319
} /* namespace drizzled; */
113
321
using namespace drizzled;
118
unsigned long ulong_num;
119
326
uint64_t ulonglong_number;
120
327
int64_t longlong_number;
121
328
drizzled::LEX_STRING lex_str;
131
338
drizzled::Key_part_spec *key_part;
132
339
const drizzled::plugin::Function *udf;
133
340
drizzled::TableList *table_list;
134
drizzled::enum_field_types field_val;
135
drizzled::sys_var_with_base variable;
136
drizzled::sql_var_t var_type;
341
struct drizzled::sys_var_with_base variable;
342
enum drizzled::sql_var_t var_type;
137
343
drizzled::Key::Keytype key_type;
138
drizzled::ha_key_alg key_alg;
139
drizzled::ha_rkey_function ha_rkey_mode;
140
drizzled::enum_tx_isolation tx_isolation;
141
drizzled::Cast_target cast_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;
142
350
const drizzled::CHARSET_INFO *charset;
143
351
drizzled::thr_lock_type lock_type;
144
352
drizzled::interval_type interval, interval_time_st;
145
drizzled::type::timestamp_t date_time_type;
353
enum drizzled::enum_drizzle_timestamp_type date_time_type;
146
354
drizzled::Select_Lex *select_lex;
147
355
drizzled::chooser_compare_func_creator boolfunc2creator;
148
drizzled::st_lex *lex;
149
drizzled::index_hint_type index_hint;
150
drizzled::enum_filetype filetype;
151
drizzled::ha_build_method build_method;
152
drizzled::message::Table::ForeignKeyConstraint::ForeignKeyOption m_fk_option;
153
drizzled::execute_string_t execute_string;
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;
157
364
namespace drizzled
159
bool my_yyoverflow(short **a, union ParserType **b, unsigned long *yystacksize);
366
bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
166
%name-prefix="base_sql_"
167
%parse-param { drizzled::Session *session }
168
%lex-param { drizzled::Session *session }
370
%pure_parser /* We have threads */
173
Currently there are 70 shift/reduce conflicts.
372
Currently there are 88 shift/reduce conflicts.
174
373
We should not introduce new conflicts any more.
179
378
Comments for TOKENS.
827
1017
/* create a table */
830
CREATE CATALOG_SYM catalog_name
832
Lex->statement= new statement::catalog::Create(YYSession, $3);
834
| CREATE opt_table_options TABLE_SYM opt_if_not_exists table_ident
836
Lex->statement= new statement::CreateTable(YYSession, $5, $2);
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;
838
if (not Lex->select_lex.add_table_to_list(YYSession, $5, NULL,
842
Lex->col_list.clear();
1040
message::Table &proto= statement->create_table_proto;
1042
proto.set_name($5->table.str);
1044
proto.set_type(message::Table::TEMPORARY);
1046
proto.set_type(message::Table::STANDARD);
844
create_table_definition
846
Lex->current_select= &Lex->select_lex;
1050
LEX *lex= YYSession->lex;
1051
lex->current_select= &lex->select_lex;
848
1053
| CREATE build_method
850
Lex->statement= new statement::CreateIndex(YYSession, $2);
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;
852
1066
opt_unique INDEX_SYM ident key_alg ON table_ident '(' key_list ')' key_options
854
if (not Lex->current_select->add_table_to_list(Lex->session, $9,
1069
statement::CreateIndex *statement= (statement::CreateIndex *)Lex->statement;
1071
if (!lex->current_select->add_table_to_list(lex->session, $9,
1073
TL_OPTION_UPDATING))
857
1074
DRIZZLE_YYABORT;
859
parser::buildKey(Lex, $4, $6);
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();
861
| CREATE DATABASE opt_if_not_exists schema_name
1080
| CREATE DATABASE opt_if_not_exists ident
863
Lex->statement= new statement::CreateSchema(YYSession);
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;
865
1091
opt_create_database_options
871
create_table_definition:
872
'(' field_list ')' opt_create_table_options create_select_as
874
| '(' create_select ')'
876
Lex->current_select->set_braces(1);
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);}
879
| '(' create_like ')' opt_create_table_options
881
| create_like opt_create_table_options
883
| opt_create_table_options create_select_as
889
| opt_duplicate_as create_select
891
Lex->current_select->set_braces(0);
1133
| opt_duplicate opt_as create_select
1134
{ Lex->current_select->set_braces(0);}
894
| opt_duplicate_as '(' create_select ')'
896
Lex->current_select->set_braces(1);
1136
| opt_duplicate opt_as '(' create_select ')'
1137
{ Lex->current_select->set_braces(1);}
904
((statement::CreateTable *)(YYSession->getLex()->statement))->is_create_table_like= true;
906
if (not YYSession->getLex()->select_lex.add_table_to_list(YYSession, $2, NULL, 0, TL_READ))
918
This rule is used for both CREATE TABLE .. SELECT, AND INSERT ... SELECT
923
Lex->lock_option= TL_READ;
924
if (Lex->sql_command == SQLCOM_INSERT)
1145
lex->lock_option= TL_READ;
1146
if (lex->sql_command == SQLCOM_INSERT)
926
delete Lex->statement;
927
Lex->statement= new statement::InsertSelect(YYSession);
1148
lex->sql_command= SQLCOM_INSERT_SELECT;
1149
delete lex->statement;
1151
new(std::nothrow) statement::InsertSelect(YYSession);
1152
if (lex->statement == NULL)
929
else if (Lex->sql_command == SQLCOM_REPLACE)
1155
else if (lex->sql_command == SQLCOM_REPLACE)
931
delete Lex->statement;
932
Lex->statement= new statement::ReplaceSelect(YYSession);
1157
lex->sql_command= SQLCOM_REPLACE_SELECT;
1158
delete lex->statement;
1160
new(std::nothrow) statement::ReplaceSelect(YYSession);
1161
if (lex->statement == NULL)
935
1165
The following work only with the local list, the global list
936
1166
is created correctly in this case
938
Lex->current_select->table_list.save_and_clear(&Lex->save_list);
940
Lex->current_select->parsing_place= SELECT_LIST;
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;
942
1172
select_options select_item_list
1012
1217
create_table_option
1013
1218
| create_table_option create_table_options
1014
1219
| create_table_option ',' create_table_options
1016
1222
create_table_option:
1017
custom_engine_option;
1019
custom_engine_option:
1020
ENGINE_SYM equal ident_or_text
1022
Lex->table()->mutable_engine()->set_name($3.str);
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_proto.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_proto.mutable_options();
1239
tableopts->set_block_size($3);
1240
statement->create_info.used_fields|= HA_CREATE_USED_BLOCK_SIZE;
1024
1242
| COMMENT_SYM opt_equal TEXT_STRING_sys
1026
Lex->table()->mutable_options()->set_comment($3.str);
1244
message::Table::TableOptions *tableopts;
1245
tableopts= ((statement::CreateTable *)Lex->statement)->create_table_proto.mutable_options();
1247
tableopts->set_comment($3.str);
1028
1249
| AUTO_INC opt_equal ulonglong_num
1030
Lex->table()->mutable_options()->set_auto_increment_value($3);
1032
| REPLICATION opt_equal TRUE_SYM
1034
Lex->table()->mutable_options()->set_dont_replicate(false);
1036
| REPLICATION opt_equal FALSE_SYM
1038
Lex->table()->mutable_options()->set_dont_replicate(true);
1040
| ROW_FORMAT_SYM equal row_format_or_text
1042
parser::buildEngineOption(Lex, "ROW_FORMAT", $3);
1044
| FILE_SYM equal TEXT_STRING_sys
1046
parser::buildEngineOption(Lex, "FILE", $3);
1048
| ident_or_text equal engine_option_value
1050
parser::buildEngineOption(Lex, $1.str, $3);
1052
| ident_or_text equal ulonglong_num
1054
parser::buildEngineOption(Lex, $1.str, $3);
1251
message::Table::TableOptions *tableopts;
1252
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1254
tableopts= ((statement::CreateTable *)Lex->statement)->create_table_proto.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;
1264
statement->create_info.row_type= $3;
1265
statement->create_info.used_fields|= HA_CREATE_USED_ROW_FORMAT;
1266
statement->alter_info.flags.set(ALTER_ROW_FORMAT);
1056
1268
| default_collation
1269
| KEY_BLOCK_SIZE opt_equal ulong_num
1271
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1273
statement->create_info.used_fields|= HA_CREATE_USED_KEY_BLOCK_SIZE;
1275
message::Table::TableOptions *tableopts;
1276
tableopts= ((statement::CreateTable *)Lex->statement)->create_table_proto.mutable_options();
1277
tableopts->set_key_block_size($3);
1059
1281
default_collation:
1060
1282
opt_default COLLATE_SYM opt_equal collation_name_or_default
1062
if (not parser::buildCollation(Lex, $4))
1284
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1286
HA_CREATE_INFO *cinfo= &statement->create_info;
1287
if ((cinfo->used_fields & HA_CREATE_USED_DEFAULT_CHARSET) &&
1288
cinfo->default_table_charset && $4 &&
1289
!my_charset_same(cinfo->default_table_charset,$4))
1291
my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
1292
$4->name, cinfo->default_table_charset->csname);
1295
statement->create_info.default_table_charset= $4;
1296
statement->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET;
1069
1300
default_collation_schema:
1070
1301
opt_default COLLATE_SYM opt_equal collation_name_or_default
1072
((statement::CreateSchema *)Lex->statement)->schema_message.set_collation($4->name);
1088
$$.str= YYSession->strmake($1.str, $1.length);
1089
$$.length= $1.length;
1303
statement::CreateSchema *statement= (statement::CreateSchema *)Lex->statement;
1305
message::Schema &schema_message= statement->schema_message;
1306
schema_message.set_collation($4->name);
1310
column_format_types:
1311
DEFAULT { $$= COLUMN_FORMAT_TYPE_DEFAULT; }
1312
| FIXED_SYM { $$= COLUMN_FORMAT_TYPE_FIXED; }
1313
| DYNAMIC_SYM { $$= COLUMN_FORMAT_TYPE_DYNAMIC; };
1316
DEFAULT { $$= ROW_TYPE_DEFAULT; }
1317
| FIXED_SYM { $$= ROW_TYPE_FIXED; }
1318
| DYNAMIC_SYM { $$= ROW_TYPE_DYNAMIC; }
1319
| COMPRESSED_SYM { $$= ROW_TYPE_COMPRESSED; }
1320
| REDUNDANT_SYM { $$= ROW_TYPE_REDUNDANT; }
1321
| COMPACT_SYM { $$= ROW_TYPE_COMPACT; }
1322
| PAGE_SYM { $$= ROW_TYPE_PAGE; }
1093
1325
opt_select_from:
1109
1341
field_spec opt_check_constraint
1110
1342
| field_spec references
1112
Lex->col_list.clear(); /* Alloced by memory::sql_alloc */
1344
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1117
1349
key_type opt_ident key_alg '(' key_list ')' key_options
1119
parser::buildKey(Lex, $1, $2);
1352
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1353
Key *key= new Key($1, $2, &statement->key_create_info, 0,
1355
statement->alter_info.key_list.push_back(key);
1356
lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1121
1358
| opt_constraint constraint_key_type opt_ident key_alg
1122
1359
'(' key_list ')' key_options
1124
parser::buildKey(Lex, $2, $3.str ? $3 : $1);
1362
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1363
Key *key= new Key($2, $3.str ? $3 : $1, &statement->key_create_info, 0,
1365
statement->alter_info.key_list.push_back(key);
1366
lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1126
1368
| opt_constraint FOREIGN KEY_SYM opt_ident '(' key_list ')' references
1128
parser::buildForeignKey(Lex, $1.str ? $1 : $4, $8);
1371
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1372
Key *key= new Foreign_key($4.str ? $4 : $1, lex->col_list,
1375
statement->fk_delete_opt,
1376
statement->fk_update_opt,
1377
statement->fk_match_option);
1378
statement->alter_info.key_list.push_back(key);
1379
key= new Key(Key::MULTIPLE, $1.str ? $1 : $4,
1380
&default_key_create_info, 1,
1382
statement->alter_info.key_list.push_back(key);
1383
lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1384
/* Only used for ALTER TABLE. Ignored otherwise. */
1385
statement->alter_info.flags.set(ALTER_FOREIGN_KEY);
1130
1387
| constraint opt_check_constraint
1132
Lex->col_list.clear(); /* Alloced by memory::sql_alloc */
1389
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1134
1391
| opt_constraint check_constraint
1136
Lex->col_list.clear(); /* Alloced by memory::sql_alloc */
1393
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1161
parser::buildCreateFieldIdent(Lex);
1419
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1420
lex->length=lex->dec=0;
1422
statement->default_value= statement->on_update_value= 0;
1423
statement->comment= null_lex_str;
1425
statement->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
1427
message::AlterTable &alter_proto=
1428
((statement::CreateTable *)Lex->statement)->alter_info.alter_proto;
1429
statement->current_proto_field= alter_proto.add_added_field();
1165
1434
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1169
Lex->field()->set_name($1.str);
1436
if (statement->current_proto_field)
1437
statement->current_proto_field->set_name($1.str);
1172
if (add_field_to_list(Lex->session, &$1, (enum enum_field_types) $3,
1173
Lex->length, Lex->dec, Lex->type,
1439
if (add_field_to_list(lex->session, &$1, (enum enum_field_types) $3,
1440
lex->length,lex->dec,lex->type,
1174
1441
statement->column_format,
1175
1442
statement->default_value, statement->on_update_value,
1176
1443
&statement->comment,
1177
statement->change, &Lex->interval_list, Lex->charset))
1444
statement->change, &lex->interval_list, lex->charset))
1178
1445
DRIZZLE_YYABORT;
1180
Lex->setField(NULL);
1447
statement->current_proto_field= NULL;
1185
field_definition opt_attribute {}
1451
type opt_attribute {}
1189
int_type ignored_field_number_length opt_field_number_signed opt_zerofill
1191
$$= parser::buildIntegerColumn(Lex, $1, ($3 or $4));
1458
Lex->length=(char*) 0; /* use default length */
1459
statement::CreateTable *statement=
1460
(statement::CreateTable *)Lex->statement;
1462
if (statement->current_proto_field)
1464
if ($1 == DRIZZLE_TYPE_LONG)
1465
statement->current_proto_field->set_type(message::Table::Field::INTEGER);
1466
else if ($1 == DRIZZLE_TYPE_LONGLONG)
1467
statement->current_proto_field->set_type(message::Table::Field::BIGINT);
1193
1472
| real_type opt_precision
1195
assert ($1 == DRIZZLE_TYPE_DOUBLE);
1196
$$= parser::buildDoubleColumn(Lex);
1200
$$= parser::buildVarcharColumn(Lex, $3.str);
1204
$$= parser::buildVarcharColumn(Lex, "1");
1206
| varchar '(' NUM ')'
1208
$$= parser::buildVarcharColumn(Lex, $3.str);
1210
| VARBINARY '(' NUM ')'
1212
$$= parser::buildVarbinaryColumn(Lex, $3.str);
1476
statement::CreateTable *statement=
1477
(statement::CreateTable *)Lex->statement;
1479
if (statement->current_proto_field)
1481
assert ($1 == DRIZZLE_TYPE_DOUBLE);
1482
statement->current_proto_field->set_type(message::Table::Field::DOUBLE);
1488
$$=DRIZZLE_TYPE_VARCHAR;
1490
statement::CreateTable *statement=
1491
(statement::CreateTable *)Lex->statement;
1493
if (statement->current_proto_field)
1495
statement->current_proto_field->set_type(message::Table::Field::VARCHAR);
1496
message::Table::Field::StringFieldOptions *string_field_options;
1498
string_field_options= statement->current_proto_field->mutable_string_options();
1500
string_field_options->set_length(atoi($3.str));
1505
Lex->length=(char*) "1";
1506
$$=DRIZZLE_TYPE_VARCHAR;
1508
statement::CreateTable *statement=
1509
(statement::CreateTable *)Lex->statement;
1511
if (statement->current_proto_field)
1512
statement->current_proto_field->set_type(message::Table::Field::VARCHAR);
1514
| varchar '(' NUM ')'
1517
$$= DRIZZLE_TYPE_VARCHAR;
1519
statement::CreateTable *statement=
1520
(statement::CreateTable *)Lex->statement;
1522
if (statement->current_proto_field)
1524
statement->current_proto_field->set_type(message::Table::Field::VARCHAR);
1526
message::Table::Field::StringFieldOptions *string_field_options;
1528
string_field_options= statement->current_proto_field->mutable_string_options();
1530
string_field_options->set_length(atoi($3.str));
1533
| VARBINARY '(' NUM ')'
1536
Lex->charset=&my_charset_bin;
1537
$$= DRIZZLE_TYPE_VARCHAR;
1539
statement::CreateTable *statement=
1540
(statement::CreateTable *)Lex->statement;
1542
if (statement->current_proto_field)
1544
statement->current_proto_field->set_type(message::Table::Field::VARCHAR);
1545
message::Table::Field::StringFieldOptions *string_field_options;
1547
string_field_options= statement->current_proto_field->mutable_string_options();
1549
string_field_options->set_length(atoi($3.str));
1550
string_field_options->set_collation_id(my_charset_bin.number);
1551
string_field_options->set_collation(my_charset_bin.name);
1216
1556
$$=DRIZZLE_TYPE_DATE;
1219
Lex->field()->set_type(message::Table::Field::DATE);
1223
$$=DRIZZLE_TYPE_TIME;
1226
Lex->field()->set_type(message::Table::Field::TIME);
1230
$$=parser::buildTimestampColumn(Lex, NULL);
1232
| TIMESTAMP_SYM '(' NUM ')'
1234
$$=parser::buildTimestampColumn(Lex, $3.str);
1558
statement::CreateTable *statement=
1559
(statement::CreateTable *)Lex->statement;
1561
if (statement->current_proto_field)
1562
statement->current_proto_field->set_type(message::Table::Field::DATE);
1566
$$=DRIZZLE_TYPE_TIMESTAMP;
1568
statement::CreateTable *statement=
1569
(statement::CreateTable *)Lex->statement;
1571
if (statement->current_proto_field)
1572
statement->current_proto_field->set_type(message::Table::Field::TIMESTAMP);
1238
1576
$$=DRIZZLE_TYPE_DATETIME;
1241
Lex->field()->set_type(message::Table::Field::DATETIME);
1245
$$= parser::buildBlobColumn(Lex);
1249
$$=DRIZZLE_TYPE_BLOB;
1250
Lex->length=(char*) 0; /* use default length */
1253
Lex->field()->set_type(message::Table::Field::BLOB);
1255
| DECIMAL_SYM float_options
1257
$$= parser::buildDecimalColumn(Lex);
1259
| NUMERIC_SYM float_options
1261
$$= parser::buildDecimalColumn(Lex);
1263
| FIXED_SYM float_options
1265
$$= parser::buildDecimalColumn(Lex);
1269
Lex->interval_list.clear();
1578
statement::CreateTable *statement=
1579
(statement::CreateTable *)Lex->statement;
1581
if (statement->current_proto_field)
1582
statement->current_proto_field->set_type(message::Table::Field::DATETIME);
1586
Lex->charset=&my_charset_bin;
1587
$$=DRIZZLE_TYPE_BLOB;
1588
Lex->length=(char*) 0; /* use default length */
1590
statement::CreateTable *statement=
1591
(statement::CreateTable *)Lex->statement;
1593
if (statement->current_proto_field)
1594
statement->current_proto_field->set_type(message::Table::Field::BLOB);
1598
$$=DRIZZLE_TYPE_BLOB;
1599
Lex->length=(char*) 0; /* use default length */
1601
statement::CreateTable *statement=
1602
(statement::CreateTable *)Lex->statement;
1604
if (statement->current_proto_field)
1605
statement->current_proto_field->set_type(message::Table::Field::BLOB);
1607
| DECIMAL_SYM float_options
1609
$$=DRIZZLE_TYPE_DECIMAL;
1611
statement::CreateTable *statement=
1612
(statement::CreateTable *)Lex->statement;
1614
if (statement->current_proto_field)
1615
statement->current_proto_field->set_type(message::Table::Field::DECIMAL);
1617
| NUMERIC_SYM float_options
1619
$$=DRIZZLE_TYPE_DECIMAL;
1621
statement::CreateTable *statement=
1622
(statement::CreateTable *)Lex->statement;
1624
if (statement->current_proto_field)
1625
statement->current_proto_field->set_type(message::Table::Field::DECIMAL);
1627
| FIXED_SYM float_options
1629
$$=DRIZZLE_TYPE_DECIMAL;
1631
statement::CreateTable *statement=
1632
(statement::CreateTable *)Lex->statement;
1634
if (statement->current_proto_field)
1635
statement->current_proto_field->set_type(message::Table::Field::DECIMAL);
1638
{Lex->interval_list.empty();}
1273
1641
$$=DRIZZLE_TYPE_ENUM;
1276
Lex->field()->set_type(message::Table::Field::ENUM);
1280
$$= parser::buildUuidColumn(Lex);
1284
$$= parser::buildBooleanColumn(Lex);
1643
statement::CreateTable *statement=
1644
(statement::CreateTable *)Lex->statement;
1646
if (statement->current_proto_field)
1647
statement->current_proto_field->set_type(message::Table::Field::ENUM);
1288
$$= parser::buildSerialColumn(Lex);
1651
$$=DRIZZLE_TYPE_LONGLONG;
1652
Lex->type|= (AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_FLAG);
1654
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1655
if (statement->current_proto_field)
1657
message::Table::Field::FieldConstraints *constraints;
1658
constraints= statement->current_proto_field->mutable_constraints();
1659
constraints->set_is_nullable(false);
1661
statement->current_proto_field->set_type(message::Table::Field::BIGINT);
1407
1766
statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1409
1768
| ON UPDATE_SYM NOW_SYM optional_braces
1411
((statement::AlterTable *)Lex->statement)->on_update_value= new Item_func_now_local();
1769
{ ((statement::AlterTable *)Lex->statement)->on_update_value= new Item_func_now_local(); }
1415
parser::buildAutoOnColumn(Lex);
1772
Lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG;
1774
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1775
if (statement->current_proto_field)
1777
message::Table::Field::FieldConstraints *constraints;
1779
constraints= statement->current_proto_field->mutable_constraints();
1780
constraints->set_is_nullable(false);
1417
1783
| SERIAL_SYM DEFAULT VALUE_SYM
1419
(void)parser::buildSerialColumn(Lex);
1786
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1788
lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_FLAG;
1789
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1791
if (statement->current_proto_field)
1793
message::Table::Field::FieldConstraints *constraints;
1794
constraints= statement->current_proto_field->mutable_constraints();
1795
constraints->set_is_nullable(false);
1421
1798
| opt_primary KEY_SYM
1423
parser::buildPrimaryOnColumn(Lex);
1801
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1803
lex->type|= PRI_KEY_FLAG | NOT_NULL_FLAG;
1804
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1806
if (statement->current_proto_field)
1808
message::Table::Field::FieldConstraints *constraints;
1809
constraints= statement->current_proto_field->mutable_constraints();
1810
constraints->set_is_nullable(false);
1427
parser::buildKeyOnColumn(Lex);
1816
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1818
lex->type|= UNIQUE_FLAG;
1819
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1429
1821
| UNIQUE_SYM KEY_SYM
1431
parser::buildKeyOnColumn(Lex);
1824
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1826
lex->type|= UNIQUE_KEY_FLAG;
1827
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1433
1829
| COMMENT_SYM TEXT_STRING_sys
1435
1831
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1436
1832
statement->comment= $2;
1439
Lex->field()->set_comment($2.str);
1834
if (statement->current_proto_field)
1835
statement->current_proto_field->set_comment($2.str);
1441
1837
| COLLATE_SYM collation_name
2679
3090
{ $$= new (YYSession->mem_root) Item_date_add_interval($3, $6, $7, 1); }
2680
3091
| SUBSTRING '(' expr ',' expr ',' expr ')'
3093
std::string reverse_str("substr");
2682
3094
List<Item> *args= new (YYSession->mem_root) List<Item>;
2683
3095
args->push_back($3);
2684
3096
args->push_back($5);
2685
3097
args->push_back($7);
2686
if (! ($$= parser::reserved_keyword_function(YYSession, "substr", args)))
3098
if (! ($$= reserved_keyword_function(reverse_str, args)))
2688
3100
DRIZZLE_YYABORT;
2691
3103
| SUBSTRING '(' expr ',' expr ')'
3105
std::string reverse_str("substr");
2693
3106
List<Item> *args= new (YYSession->mem_root) List<Item>;
2694
3107
args->push_back($3);
2695
3108
args->push_back($5);
2696
if (! ($$= parser::reserved_keyword_function(YYSession, "substr", args)))
3109
if (! ($$= reserved_keyword_function(reverse_str, args)))
2698
3111
DRIZZLE_YYABORT;
2701
3114
| SUBSTRING '(' expr FROM expr FOR_SYM expr ')'
3116
std::string reverse_str("substr");
2703
3117
List<Item> *args= new (YYSession->mem_root) List<Item>;
2704
3118
args->push_back($3);
2705
3119
args->push_back($5);
2706
3120
args->push_back($7);
2707
if (! ($$= parser::reserved_keyword_function(YYSession, "substr", args)))
3121
if (! ($$= reserved_keyword_function(reverse_str, args)))
2709
3123
DRIZZLE_YYABORT;
2712
3126
| SUBSTRING '(' expr FROM expr ')'
3128
std::string reverse_str("substr");
2714
3129
List<Item> *args= new (YYSession->mem_root) List<Item>;
2715
3130
args->push_back($3);
2716
3131
args->push_back($5);
2717
if (! ($$= parser::reserved_keyword_function(YYSession, "substr", args)))
3132
if (! ($$= reserved_keyword_function(reverse_str, args)))
2719
3134
DRIZZLE_YYABORT;
2722
3137
| SYSDATE optional_braces
2724
$$= new (YYSession->mem_root) Item_func_sysdate_local();
2725
Lex->setCacheable(false);
3138
{ $$= new (YYSession->mem_root) Item_func_sysdate_local(); }
2727
3139
| SYSDATE '(' expr ')'
2729
$$= new (YYSession->mem_root) Item_func_sysdate_local($3);
2730
Lex->setCacheable(false);
3140
{ $$= new (YYSession->mem_root) Item_func_sysdate_local($3); }
2732
3141
| TIMESTAMP_ADD '(' interval_time_stamp ',' expr ',' expr ')'
2733
3142
{ $$= new (YYSession->mem_root) Item_date_add_interval($7,$5,$3,0); }
2734
3143
| TIMESTAMP_DIFF '(' interval_time_stamp ',' expr ',' expr ')'
3978
DROP CATALOG_SYM catalog_name
3980
Lex->statement= new statement::catalog::Drop(YYSession, $3);
3982
| DROP opt_temporary table_or_tables if_exists table_list
3984
statement::DropTable *statement= new statement::DropTable(YYSession);
3985
Lex->statement= statement;
4341
DROP opt_temporary table_or_tables if_exists table_list
4344
lex->sql_command = SQLCOM_DROP_TABLE;
4345
statement::DropTable *statement= new(std::nothrow) statement::DropTable(YYSession);
4346
lex->statement= statement;
4347
if (lex->statement == NULL)
3986
4349
statement->drop_temporary= $2;
3987
4350
statement->drop_if_exists= $4;
3989
4352
| DROP build_method INDEX_SYM ident ON table_ident {}
3991
statement::DropIndex *statement= new statement::DropIndex(YYSession);
3992
Lex->statement= statement;
4355
lex->sql_command= SQLCOM_DROP_INDEX;
4356
statement::DropIndex *statement= new(std::nothrow) statement::DropIndex(YYSession);
4357
lex->statement= statement;
4358
if (lex->statement == NULL)
3993
4360
statement->alter_info.flags.set(ALTER_DROP_INDEX);
3994
4361
statement->alter_info.build_method= $2;
3995
4362
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY, $4.str));
3996
if (not Lex->current_select->add_table_to_list(Lex->session, $6, NULL,
3997
TL_OPTION_UPDATING))
4363
if (!lex->current_select->add_table_to_list(lex->session, $6, NULL,
4364
TL_OPTION_UPDATING))
3998
4365
DRIZZLE_YYABORT;
4000
| DROP DATABASE if_exists schema_name
4367
| DROP DATABASE if_exists ident
4002
statement::DropSchema *statement= new statement::DropSchema(YYSession);
4003
Lex->statement= statement;
4370
lex->sql_command= SQLCOM_DROP_DB;
4371
statement::DropSchema *statement= new(std::nothrow) statement::DropSchema(YYSession);
4372
lex->statement= statement;
4373
if (lex->statement == NULL)
4004
4375
statement->drop_if_exists=$3;
4011
4380
| table_list ',' table_name
4321
Lex->lock_option= TL_READ;
4323
Lex->current_select->parsing_place= SELECT_LIST;
4690
lex->lock_option= TL_READ;
4691
mysql_init_select(lex);
4692
lex->current_select->parsing_place= SELECT_LIST;
4331
4699
DATABASES show_wild
4333
if (not show::buildScemas(YYSession))
4702
lex->sql_command= SQLCOM_SELECT;
4704
new(std::nothrow) statement::Select(YYSession);
4705
if (lex->statement == NULL)
4708
Session *session= YYSession;
4710
std::string column_name= "Database";
4713
column_name.append(" (");
4714
column_name.append(Lex->wild->ptr());
4715
column_name.append(")");
4718
if (Lex->current_select->where)
4720
if (prepare_new_schema_table(YYSession, lex, "SCHEMAS"))
4725
if (prepare_new_schema_table(YYSession, lex, "SCHEMA_NAMES"))
4729
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "SCHEMA_NAME");
4730
my_field->is_autogenerated_name= false;
4731
my_field->set_name(column_name.c_str(), column_name.length(), system_charset_info);
4733
if (session->add_item_to_list(my_field))
4334
4734
DRIZZLE_YYABORT;
4337
4736
| TABLES opt_db show_wild
4339
if (not show::buildTables(YYSession, $2))
4342
/* SHOW TEMPORARY TABLES */
4343
| TEMPORARY_SYM TABLES show_wild
4345
if (not show::buildTemporaryTables(YYSession))
4348
/* SHOW TABLE STATUS */
4739
lex->sql_command= SQLCOM_SELECT;
4741
new(std::nothrow) statement::Select(YYSession);
4742
if (lex->statement == NULL)
4745
Session *session= YYSession;
4747
std::string column_name= "Tables_in_";
4751
column_name.append($2);
4752
lex->select_lex.db= $2;
4753
if (not plugin::StorageEngine::doesSchemaExist($2))
4755
my_error(ER_BAD_DB_ERROR, MYF(0), $2);
4760
column_name.append(session->db);
4765
column_name.append(" (");
4766
column_name.append(Lex->wild->ptr());
4767
column_name.append(")");
4770
if (Lex->current_select->where)
4772
if (prepare_new_schema_table(YYSession, lex, "TABLES"))
4777
if (prepare_new_schema_table(YYSession, lex, "SHOW_TABLES"))
4781
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "TABLE_NAME");
4782
my_field->is_autogenerated_name= false;
4783
my_field->set_name(column_name.c_str(), column_name.length(), system_charset_info);
4785
if (session->add_item_to_list(my_field))
4349
4788
| TABLE_SYM STATUS_SYM opt_db show_wild
4351
if (not show::buildTableStatus(YYSession, $3))
4791
lex->sql_command= SQLCOM_SELECT;
4793
new(std::nothrow) statement::Select(YYSession);
4794
if (lex->statement == NULL)
4797
Session *session= YYSession;
4799
std::string column_name= "Tables_in_";
4803
lex->select_lex.db= $3;
4805
if (not plugin::StorageEngine::doesSchemaExist($3))
4807
my_error(ER_BAD_DB_ERROR, MYF(0), $3);
4811
if (prepare_new_schema_table(session, lex, "SHOW_TABLE_STATUS"))
4814
if (session->add_item_to_list( new Item_field(&session->lex->current_select->
4818
(session->lex->current_select->with_wild)++;
4354
/* SHOW COLUMNS FROM table_name */
4355
4820
| COLUMNS from_or_in table_ident opt_db show_wild
4357
if (not show::buildColumns(YYSession, $4, $3))
4360
/* SHOW INDEXES from table */
4823
Session *session= YYSession;
4824
statement::Select *select;
4826
lex->sql_command= SQLCOM_SELECT;
4828
select= new(std::nothrow) statement::Select(session);
4830
lex->statement= select;
4832
if (lex->statement == NULL)
4836
select->setShowPredicate($4, $3->table.str);
4837
else if ($3->db.str)
4838
select->setShowPredicate($3->db.str, $3->table.str);
4840
select->setShowPredicate(session->db, $3->table.str);
4843
drizzled::TableIdentifier identifier(select->getShowSchema().c_str(), $3->table.str);
4844
if (not plugin::StorageEngine::doesTableExist(*session, identifier))
4846
my_error(ER_NO_SUCH_TABLE, MYF(0),
4847
select->getShowSchema().c_str(),
4852
if (prepare_new_schema_table(session, lex, "SHOW_COLUMNS"))
4855
if (session->add_item_to_list( new Item_field(&session->lex->current_select->
4859
(session->lex->current_select->with_wild)++;
4361
4862
| keys_or_index from_or_in table_ident opt_db where_clause
4363
if (not show::buildIndex(YYSession, $4, $3))
4865
Session *session= YYSession;
4866
statement::Select *select;
4868
lex->sql_command= SQLCOM_SELECT;
4870
select= new(std::nothrow) statement::Select(session);
4872
lex->statement= select;
4874
if (lex->statement == NULL)
4878
select->setShowPredicate($4, $3->table.str);
4879
else if ($3->db.str)
4880
select->setShowPredicate($3->db.str, $3->table.str);
4882
select->setShowPredicate(session->db, $3->table.str);
4885
drizzled::TableIdentifier identifier(select->getShowSchema().c_str(), $3->table.str);
4886
if (not plugin::StorageEngine::doesTableExist(*session, identifier))
4888
my_error(ER_NO_SUCH_TABLE, MYF(0),
4889
select->getShowSchema().c_str(),
4894
if (prepare_new_schema_table(session, lex, "show_indexes"))
4897
if (session->add_item_to_list( new Item_field(&session->lex->current_select->
4901
(session->lex->current_select->with_wild)++;
4366
4903
| COUNT_SYM '(' '*' ')' WARNINGS
4368
show::buildSelectWarning(YYSession);
4905
(void) create_select_for_variable("warning_count");
4907
lex->statement= new(std::nothrow) statement::Select(YYSession);
4908
if (lex->statement == NULL)
4370
4911
| COUNT_SYM '(' '*' ')' ERRORS
4372
show::buildSelectError(YYSession);
4913
(void) create_select_for_variable("error_count");
4915
lex->statement= new(std::nothrow) statement::Select(YYSession);
4916
if (lex->statement == NULL)
4374
4919
| WARNINGS opt_limit_clause_init
4376
show::buildWarnings(YYSession);
4921
Lex->sql_command = SQLCOM_SHOW_WARNS;
4922
Lex->statement= new(std::nothrow) statement::ShowWarnings(YYSession);
4923
if (Lex->statement == NULL)
4378
4926
| ERRORS opt_limit_clause_init
4380
show::buildErrors(YYSession);
4928
Lex->sql_command = SQLCOM_SHOW_ERRORS;
4929
Lex->statement= new(std::nothrow) statement::ShowErrors(YYSession);
4930
if (Lex->statement == NULL)
4382
4933
| opt_var_type STATUS_SYM show_wild
4384
if (not show::buildStatus(YYSession, $1))
4387
| engine_option_value STATUS_SYM
4389
if (not show::buildEngineStatus(YYSession, $1))
4392
| CREATE TABLE_SYM table_ident
4394
if (not show::buildCreateTable(YYSession, $3))
4936
lex->sql_command= SQLCOM_SELECT;
4938
new(std::nothrow) statement::Select(YYSession);
4939
if (lex->statement == NULL)
4942
Session *session= YYSession;
4944
if ($1 == OPT_GLOBAL)
4946
if (prepare_new_schema_table(session, lex, "GLOBAL_STATUS"))
4951
if (prepare_new_schema_table(session, lex, "SESSION_STATUS"))
4955
std::string key("Variable_name");
4956
std::string value("Value");
4958
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "VARIABLE_NAME");
4959
my_field->is_autogenerated_name= false;
4960
my_field->set_name(key.c_str(), key.length(), system_charset_info);
4962
if (session->add_item_to_list(my_field))
4965
my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "VARIABLE_VALUE");
4966
my_field->is_autogenerated_name= false;
4967
my_field->set_name(value.c_str(), value.length(), system_charset_info);
4969
if (session->add_item_to_list(my_field))
4397
4972
| PROCESSLIST_SYM
4399
if (not show::buildProcesslist(YYSession))
4976
lex->sql_command= SQLCOM_SELECT;
4978
new(std::nothrow) statement::Select(YYSession);
4979
if (lex->statement == NULL)
4982
Session *session= YYSession;
4984
if (prepare_new_schema_table(session, lex, "PROCESSLIST"))
4987
if (session->add_item_to_list( new Item_field(&session->lex->current_select->
4991
(session->lex->current_select->with_wild)++;
4402
4994
| opt_var_type VARIABLES show_wild
4404
if (not show::buildVariables(YYSession, $1))
4997
lex->sql_command= SQLCOM_SELECT;
4999
new(std::nothrow) statement::Select(YYSession);
5000
if (lex->statement == NULL)
5003
Session *session= YYSession;
5005
if ($1 == OPT_GLOBAL)
5007
if (prepare_new_schema_table(session, lex, "GLOBAL_VARIABLES"))
5012
if (prepare_new_schema_table(session, lex, "SESSION_VARIABLES"))
5016
std::string key("Variable_name");
5017
std::string value("Value");
5019
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "VARIABLE_NAME");
5020
my_field->is_autogenerated_name= false;
5021
my_field->set_name(key.c_str(), key.length(), system_charset_info);
5023
if (session->add_item_to_list(my_field))
5026
my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "VARIABLE_VALUE");
5027
my_field->is_autogenerated_name= false;
5028
my_field->set_name(value.c_str(), value.length(), system_charset_info);
5030
if (session->add_item_to_list(my_field))
4407
5033
| CREATE DATABASE opt_if_not_exists ident
4409
if (not show::buildCreateSchema(YYSession, $4))
5035
Lex->sql_command=SQLCOM_SHOW_CREATE_DB;
5036
statement::ShowCreateSchema *statement= new(std::nothrow) statement::ShowCreateSchema(YYSession);
5037
Lex->statement= statement;
5038
if (Lex->statement == NULL)
5040
statement->is_if_not_exists= $3;
5043
| CREATE TABLE_SYM table_ident
5046
lex->sql_command = SQLCOM_SHOW_CREATE;
5047
lex->statement= new(std::nothrow) statement::ShowCreate(YYSession);
5048
if (lex->statement == NULL)
5050
if (!lex->select_lex.add_table_to_list(YYSession, $3, NULL,0))
4410
5051
DRIZZLE_YYABORT;
4847
5560
simple_ident_q:
4848
5561
ident '.' ident
4850
$$= parser::buildIdent(Lex, NULL_LEX_STRING, $1, $3);
5563
Session *session= YYSession;
5564
LEX *lex= session->lex;
5567
Select_Lex *sel= lex->current_select;
5568
if (sel->no_table_names_allowed)
5570
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5571
MYF(0), $1.str, session->where);
5573
$$= (sel->parsing_place != IN_HAVING ||
5574
sel->get_in_sum_expr() > 0) ?
5575
(Item*) new Item_field(Lex->current_context(),
5576
(const char *)NULL, $1.str, $3.str) :
5577
(Item*) new Item_ref(Lex->current_context(),
5578
(const char *)NULL, $1.str, $3.str);
4852
5581
| '.' ident '.' ident
4854
$$= parser::buildIdent(Lex, NULL_LEX_STRING, $2, $4);
5583
Session *session= YYSession;
5584
LEX *lex= session->lex;
5585
Select_Lex *sel= lex->current_select;
5586
if (sel->no_table_names_allowed)
5588
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5589
MYF(0), $2.str, session->where);
5591
$$= (sel->parsing_place != IN_HAVING ||
5592
sel->get_in_sum_expr() > 0) ?
5593
(Item*) new Item_field(Lex->current_context(), NULL, $2.str, $4.str) :
5594
(Item*) new Item_ref(Lex->current_context(),
5595
(const char *)NULL, $2.str, $4.str);
4856
5597
| ident '.' ident '.' ident
4858
$$= parser::buildIdent(Lex, $1, $3, $5);
5599
Session *session= YYSession;
5600
LEX *lex= session->lex;
5601
Select_Lex *sel= lex->current_select;
5602
if (sel->no_table_names_allowed)
5604
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5605
MYF(0), $3.str, session->where);
5607
$$= (sel->parsing_place != IN_HAVING ||
5608
sel->get_in_sum_expr() > 0) ?
5609
(Item*) new Item_field(Lex->current_context(), $1.str, $3.str,
5611
(Item*) new Item_ref(Lex->current_context(), $1.str, $3.str,
4867
5618
| ident '.' ident '.' ident
4869
if (not parser::checkFieldIdent(Lex, $1, $3))
5621
reinterpret_cast<TableList*>(Lex->current_select->table_list.first);
5622
if (my_strcasecmp(table_alias_charset, $1.str, table->db))
5624
my_error(ER_WRONG_DB_NAME, MYF(0), $1.str);
5627
if (my_strcasecmp(table_alias_charset, $3.str,
5630
my_error(ER_WRONG_TABLE_NAME, MYF(0), $3.str);
4874
5635
| ident '.' ident
4876
if (not parser::checkFieldIdent(Lex, NULL_LEX_STRING, $1))
5638
reinterpret_cast<TableList*>(Lex->current_select->table_list.first);
5639
if (my_strcasecmp(table_alias_charset, $1.str, table->alias))
5641
my_error(ER_WRONG_TABLE_NAME, MYF(0), $1.str);
4877
5642
DRIZZLE_YYABORT;
5646
| '.' ident { $$=$2;} /* For Delphi */
4890
$$= new Table_ident($1);
4892
| schema_name '.' ident
4894
$$=new Table_ident($1,$3);
4898
$$= new Table_ident($2);
5650
ident { $$=new Table_ident($1); }
5651
| ident '.' ident { $$=new Table_ident($1,$3);}
5652
| '.' ident { $$=new Table_ident($2);} /* For Delphi */
4917
5659
const CHARSET_INFO * const cs= system_charset_info;