104
140
This function is not for use in semantic actions and is internal to
105
141
the parser, as it performs some pre-return cleanup.
106
In semantic actions, please use parser::my_parse_error or my_error to
142
In semantic actions, please use my_parse_error or my_error to
107
143
push an error into the error stack and DRIZZLE_YYABORT
108
144
to abort from the parser.
111
147
static void DRIZZLEerror(const char *s)
149
Session *session= current_session;
152
Restore the original LEX if it was replaced when parsing
153
a stored procedure. We must ensure that a parsing error
154
does not leave any side effects in the Session.
156
LEX::cleanup_lex_after_parse_error(session);
158
/* "parse error" changed into "syntax error" between bison 1.75 and 1.875 */
159
if (strcmp(s,"parse error") == 0 || strcmp(s,"syntax error") == 0)
160
s= ER(ER_SYNTAX_ERROR);
162
struct my_parse_error_st pass= { s, session };
163
my_parse_error(&pass);
167
Helper to resolve the SQL:2003 Syntax exception 1) in <in predicate>.
168
See SQL:2003, Part 2, section 8.4 <in predicate>, Note 184, page 383.
169
This function returns the proper item for the SQL expression
170
<code>left [NOT] IN ( expr )</code>
171
@param session the current thread
172
@param left the in predicand
173
@param equal true for IN predicates, false for NOT IN predicates
174
@param expr first and only expression of the in value list
175
@return an expression representing the IN predicate.
177
static Item* handle_sql2003_note184_exception(Session *session,
178
Item* left, bool equal,
182
Relevant references for this issue:
183
- SQL:2003, Part 2, section 8.4 <in predicate>, page 383,
184
- SQL:2003, Part 2, section 7.2 <row value expression>, page 296,
185
- SQL:2003, Part 2, section 6.3 <value expression primary>, page 174,
186
- SQL:2003, Part 2, section 7.15 <subquery>, page 370,
187
- SQL:2003 Feature F561, "Full value expressions".
189
The exception in SQL:2003 Note 184 means:
190
Item_singlerow_subselect, which corresponds to a <scalar subquery>,
191
should be re-interpreted as an Item_in_subselect, which corresponds
192
to a <table subquery> when used inside an <in predicate>.
194
Our reading of Note 184 is reccursive, so that all:
195
- IN (( <subquery> ))
196
- IN ((( <subquery> )))
197
- IN '('^N <subquery> ')'^N
199
should be interpreted as a <table subquery>, no matter how deep in the
200
expression the <subquery> is.
205
if (expr->type() == Item::SUBSELECT_ITEM)
207
Item_subselect *expr2 = (Item_subselect*) expr;
209
if (expr2->substype() == Item_subselect::SINGLEROW_SUBS)
211
Item_singlerow_subselect *expr3 = (Item_singlerow_subselect*) expr2;
212
Select_Lex *subselect;
215
Implement the mandated change, by altering the semantic tree:
216
left IN Item_singlerow_subselect(subselect)
219
which is represented as
220
Item_in_subselect(left, subselect)
222
subselect= expr3->invalidate_and_restore_select_lex();
223
result= new (session->mem_root) Item_in_subselect(left, subselect);
226
result = negate_expression(session, result);
233
result= new (session->mem_root) Item_func_eq(left, expr);
235
result= new (session->mem_root) Item_func_ne(left, expr);
241
@brief Creates a new Select_Lex for a UNION branch.
243
Sets up and initializes a Select_Lex structure for a query once the parser
244
discovers a UNION token. The current Select_Lex is pushed on the stack and
245
the new Select_Lex becomes the current one..=
247
@lex The parser state.
249
@is_union_distinct True if the union preceding the new select statement
252
@return <code>false</code> if successful, <code>true</code> if an error was
253
reported. In the latter case parsing should stop.
255
static bool add_select_to_union_list(Session *session, LEX *lex, bool is_union_distinct)
259
/* Only the last SELECT can have INTO...... */
260
my_error(ER_WRONG_USAGE, MYF(0), "UNION", "INTO");
263
if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE)
265
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), session };
266
my_parse_error(&pass);
269
/* This counter shouldn't be incremented for UNION parts */
271
if (mysql_new_select(lex, 0))
273
mysql_init_select(lex);
274
lex->current_select->linkage=UNION_TYPE;
275
if (is_union_distinct) /* UNION DISTINCT - remember position */
276
lex->current_select->master_unit()->union_distinct=
282
@brief Initializes a Select_Lex for a query within parentheses (aka
285
@return false if successful, true if an error was reported. In the latter
286
case parsing should stop.
288
static bool setup_select_in_parentheses(Session *session, LEX *lex)
290
Select_Lex * sel= lex->current_select;
291
if (sel->set_braces(1))
293
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), session };
294
my_parse_error(&pass);
297
if (sel->linkage == UNION_TYPE &&
298
!sel->master_unit()->first_select()->braces &&
299
sel->master_unit()->first_select()->linkage ==
302
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), session };
303
my_parse_error(&pass);
306
if (sel->linkage == UNION_TYPE &&
307
sel->olap != UNSPECIFIED_OLAP_TYPE &&
308
sel->master_unit()->fake_select_lex)
310
my_error(ER_WRONG_USAGE, MYF(0), "CUBE/ROLLUP", "ORDER BY");
313
/* select in braces, can't contain global parameters */
314
if (sel->master_unit()->fake_select_lex)
315
sel->master_unit()->global_parameters=
316
sel->master_unit()->fake_select_lex;
320
static Item* reserved_keyword_function(Session *session, const std::string &name, List<Item> *item_list)
322
const plugin::Function *udf= plugin::Function::get(name.c_str(), name.length());
327
item= Create_udf_func::s_singleton.create(session, udf, item_list);
329
my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", name.c_str());
116
335
} /* namespace drizzled; */
828
1026
/* 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);
1029
CREATE opt_table_options TABLE_SYM opt_if_not_exists table_ident
1031
Session *session= YYSession;
1032
LEX *lex= session->lex;
1033
lex->sql_command= SQLCOM_CREATE_TABLE;
1034
statement::CreateTable *statement= new(std::nothrow) statement::CreateTable(YYSession);
1035
lex->statement= statement;
1036
if (lex->statement == NULL)
1038
if (!lex->select_lex.add_table_to_list(session, $5, NULL,
1042
lex->col_list.empty();
1043
statement->change=NULL;
1044
statement->is_if_not_exists= $4;
1045
statement->create_info.db_type= NULL;
1046
statement->create_info.default_table_charset= NULL;
839
if (not Lex->select_lex.add_table_to_list(YYSession, $5, NULL,
843
Lex->col_list.empty();
1049
message::Table &proto= statement->create_table_message;
1051
proto.set_name($5->table.str);
1053
proto.set_type(message::Table::TEMPORARY);
1055
proto.set_type(message::Table::STANDARD);
845
create_table_definition
847
Lex->current_select= &Lex->select_lex;
1059
LEX *lex= YYSession->lex;
1060
lex->current_select= &lex->select_lex;
849
1062
| CREATE build_method
851
Lex->statement= new statement::CreateIndex(YYSession, $2);
1065
lex->sql_command= SQLCOM_CREATE_INDEX;
1066
statement::CreateIndex *statement= new(std::nothrow) statement::CreateIndex(YYSession);
1067
lex->statement= statement;
1068
if (lex->statement == NULL)
1070
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1071
statement->alter_info.build_method= $2;
1072
lex->col_list.empty();
1073
statement->change=NULL;
853
1075
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,
1078
statement::CreateIndex *statement= (statement::CreateIndex *)Lex->statement;
1080
if (!lex->current_select->add_table_to_list(lex->session, $9,
1082
TL_OPTION_UPDATING))
858
1083
DRIZZLE_YYABORT;
860
parser::buildKey(Lex, $4, $6);
1085
key= new Key($4, $6, &statement->key_create_info, 0, lex->col_list);
1086
statement->alter_info.key_list.push_back(key);
1087
lex->col_list.empty();
862
| CREATE DATABASE opt_if_not_exists schema_name
1089
| CREATE DATABASE opt_if_not_exists ident
864
Lex->statement= new statement::CreateSchema(YYSession);
1093
lex->sql_command=SQLCOM_CREATE_DB;
1094
statement::CreateSchema *statement= new(std::nothrow) statement::CreateSchema(YYSession);
1095
lex->statement= statement;
1096
if (lex->statement == NULL)
1098
statement->is_if_not_exists= $3;
866
1100
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);
1108
| opt_create_table_options
1110
| LIKE table_ident opt_create_table_options
1112
Session *session= YYSession;
1113
LEX *lex= session->lex;
1114
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1116
statement->is_create_table_like= true;
1117
if (!lex->select_lex.add_table_to_list(session, $2, NULL, 0, TL_READ))
1120
| '(' LIKE table_ident ')'
1122
Session *session= YYSession;
1123
LEX *lex= session->lex;
1124
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1126
statement->is_create_table_like= true;
1127
if (!lex->select_lex.add_table_to_list(session, $3, NULL, 0, TL_READ))
1133
field_list ')' opt_create_table_options
1136
{ 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);
1142
| opt_duplicate opt_as create_select
1143
{ Lex->current_select->set_braces(0);}
895
| opt_duplicate_as '(' create_select ')'
897
Lex->current_select->set_braces(1);
1145
| opt_duplicate opt_as '(' create_select ')'
1146
{ 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)
1154
lex->lock_option= TL_READ;
1155
if (lex->sql_command == SQLCOM_INSERT)
927
delete Lex->statement;
928
Lex->statement= new statement::InsertSelect(YYSession);
1157
lex->sql_command= SQLCOM_INSERT_SELECT;
1158
delete lex->statement;
1160
new(std::nothrow) statement::InsertSelect(YYSession);
1161
if (lex->statement == NULL)
930
else if (Lex->sql_command == SQLCOM_REPLACE)
1164
else if (lex->sql_command == SQLCOM_REPLACE)
932
delete Lex->statement;
933
Lex->statement= new statement::ReplaceSelect(YYSession);
1166
lex->sql_command= SQLCOM_REPLACE_SELECT;
1167
delete lex->statement;
1169
new(std::nothrow) statement::ReplaceSelect(YYSession);
1170
if (lex->statement == NULL)
936
1174
The following work only with the local list, the global list
937
1175
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;
1177
lex->current_select->table_list.save_and_clear(&lex->save_list);
1178
mysql_init_select(lex);
1179
lex->current_select->parsing_place= SELECT_LIST;
943
1181
select_options select_item_list
1146
parser::buildCreateFieldIdent(Lex);
1445
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1446
lex->length=lex->dec=0;
1448
statement->default_value= statement->on_update_value= 0;
1449
statement->comment= null_lex_str;
1451
statement->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
1453
message::AlterTable &alter_proto=
1454
((statement::CreateTable *)Lex->statement)->alter_info.alter_proto;
1455
statement->current_proto_field= alter_proto.add_added_field();
1150
1460
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1154
Lex->field()->set_name($1.str);
1462
if (statement->current_proto_field)
1463
statement->current_proto_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,
1465
if (add_field_to_list(lex->session, &$1, (enum enum_field_types) $3,
1466
lex->length,lex->dec,lex->type,
1159
1467
statement->column_format,
1160
1468
statement->default_value, statement->on_update_value,
1161
1469
&statement->comment,
1162
statement->change, &Lex->interval_list, Lex->charset))
1470
statement->change, &lex->interval_list, lex->charset))
1163
1471
DRIZZLE_YYABORT;
1165
Lex->setField(NULL);
1473
statement->current_proto_field= NULL;
1170
field_definition opt_attribute {}
1477
type opt_attribute {}
1174
int_type ignored_field_number_length opt_field_number_signed opt_zerofill
1176
$$= parser::buildIntegerColumn(Lex, $1, ($3 or $4));
1484
Lex->length=(char*) 0; /* use default length */
1485
statement::CreateTable *statement=
1486
(statement::CreateTable *)Lex->statement;
1488
if (statement->current_proto_field)
1490
if ($1 == DRIZZLE_TYPE_LONG)
1491
statement->current_proto_field->set_type(message::Table::Field::INTEGER);
1492
else if ($1 == DRIZZLE_TYPE_LONGLONG)
1493
statement->current_proto_field->set_type(message::Table::Field::BIGINT);
1178
1498
| 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);
1195
| VARBINARY '(' NUM ')'
1197
$$= parser::buildVarbinaryColumn(Lex, $3.str);
1502
statement::CreateTable *statement=
1503
(statement::CreateTable *)Lex->statement;
1505
if (statement->current_proto_field)
1507
assert ($1 == DRIZZLE_TYPE_DOUBLE);
1508
statement->current_proto_field->set_type(message::Table::Field::DOUBLE);
1514
$$=DRIZZLE_TYPE_VARCHAR;
1516
statement::CreateTable *statement=
1517
(statement::CreateTable *)Lex->statement;
1519
if (statement->current_proto_field)
1521
statement->current_proto_field->set_type(message::Table::Field::VARCHAR);
1522
message::Table::Field::StringFieldOptions *string_field_options;
1524
string_field_options= statement->current_proto_field->mutable_string_options();
1526
string_field_options->set_length(atoi($3.str));
1531
Lex->length=(char*) "1";
1532
$$=DRIZZLE_TYPE_VARCHAR;
1534
statement::CreateTable *statement=
1535
(statement::CreateTable *)Lex->statement;
1537
if (statement->current_proto_field)
1538
statement->current_proto_field->set_type(message::Table::Field::VARCHAR);
1540
| varchar '(' NUM ')'
1543
$$= DRIZZLE_TYPE_VARCHAR;
1545
statement::CreateTable *statement=
1546
(statement::CreateTable *)Lex->statement;
1548
if (statement->current_proto_field)
1550
statement->current_proto_field->set_type(message::Table::Field::VARCHAR);
1552
message::Table::Field::StringFieldOptions *string_field_options;
1554
string_field_options= statement->current_proto_field->mutable_string_options();
1556
string_field_options->set_length(atoi($3.str));
1559
| VARBINARY '(' NUM ')'
1562
Lex->charset=&my_charset_bin;
1563
$$= DRIZZLE_TYPE_VARCHAR;
1565
statement::CreateTable *statement=
1566
(statement::CreateTable *)Lex->statement;
1568
if (statement->current_proto_field)
1570
statement->current_proto_field->set_type(message::Table::Field::VARCHAR);
1571
message::Table::Field::StringFieldOptions *string_field_options;
1573
string_field_options= statement->current_proto_field->mutable_string_options();
1575
string_field_options->set_length(atoi($3.str));
1576
string_field_options->set_collation_id(my_charset_bin.number);
1577
string_field_options->set_collation(my_charset_bin.name);
1201
1582
$$=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);
1215
$$=parser::buildTimestampColumn(Lex, NULL);
1217
| TIMESTAMP_SYM '(' NUM ')'
1219
$$=parser::buildTimestampColumn(Lex, $3.str);
1584
statement::CreateTable *statement=
1585
(statement::CreateTable *)Lex->statement;
1587
if (statement->current_proto_field)
1588
statement->current_proto_field->set_type(message::Table::Field::DATE);
1592
$$=DRIZZLE_TYPE_TIMESTAMP;
1594
statement::CreateTable *statement=
1595
(statement::CreateTable *)Lex->statement;
1597
if (statement->current_proto_field)
1598
statement->current_proto_field->set_type(message::Table::Field::TIMESTAMP);
1223
1602
$$=DRIZZLE_TYPE_DATETIME;
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();
1604
statement::CreateTable *statement=
1605
(statement::CreateTable *)Lex->statement;
1607
if (statement->current_proto_field)
1608
statement->current_proto_field->set_type(message::Table::Field::DATETIME);
1612
Lex->charset=&my_charset_bin;
1613
$$=DRIZZLE_TYPE_BLOB;
1614
Lex->length=(char*) 0; /* use default length */
1616
statement::CreateTable *statement=
1617
(statement::CreateTable *)Lex->statement;
1619
if (statement->current_proto_field)
1621
statement->current_proto_field->set_type(message::Table::Field::BLOB);
1622
message::Table::Field::StringFieldOptions *string_field_options;
1624
string_field_options= statement->current_proto_field->mutable_string_options();
1625
string_field_options->set_collation_id(my_charset_bin.number);
1626
string_field_options->set_collation(my_charset_bin.name);
1631
$$=DRIZZLE_TYPE_BLOB;
1632
Lex->length=(char*) 0; /* use default length */
1634
statement::CreateTable *statement=
1635
(statement::CreateTable *)Lex->statement;
1637
if (statement->current_proto_field)
1638
statement->current_proto_field->set_type(message::Table::Field::BLOB);
1640
| DECIMAL_SYM float_options
1642
$$=DRIZZLE_TYPE_DECIMAL;
1644
statement::CreateTable *statement=
1645
(statement::CreateTable *)Lex->statement;
1647
if (statement->current_proto_field)
1648
statement->current_proto_field->set_type(message::Table::Field::DECIMAL);
1650
| NUMERIC_SYM float_options
1652
$$=DRIZZLE_TYPE_DECIMAL;
1654
statement::CreateTable *statement=
1655
(statement::CreateTable *)Lex->statement;
1657
if (statement->current_proto_field)
1658
statement->current_proto_field->set_type(message::Table::Field::DECIMAL);
1660
| FIXED_SYM float_options
1662
$$=DRIZZLE_TYPE_DECIMAL;
1664
statement::CreateTable *statement=
1665
(statement::CreateTable *)Lex->statement;
1667
if (statement->current_proto_field)
1668
statement->current_proto_field->set_type(message::Table::Field::DECIMAL);
1671
{Lex->interval_list.empty();}
1258
1674
$$=DRIZZLE_TYPE_ENUM;
1261
Lex->field()->set_type(message::Table::Field::ENUM);
1265
$$= parser::buildUuidColumn(Lex);
1269
$$= parser::buildBooleanColumn(Lex);
1676
statement::CreateTable *statement=
1677
(statement::CreateTable *)Lex->statement;
1679
if (statement->current_proto_field)
1680
statement->current_proto_field->set_type(message::Table::Field::ENUM);
1273
$$= parser::buildSerialColumn(Lex);
1684
$$=DRIZZLE_TYPE_LONGLONG;
1685
Lex->type|= (AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_FLAG);
1687
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1688
if (statement->current_proto_field)
1690
message::Table::Field::FieldConstraints *constraints;
1691
constraints= statement->current_proto_field->mutable_constraints();
1692
constraints->set_is_nullable(false);
1694
statement->current_proto_field->set_type(message::Table::Field::BIGINT);
4346
Lex->lock_option= TL_READ;
4348
Lex->current_select->parsing_place= SELECT_LIST;
4755
lex->lock_option= TL_READ;
4756
mysql_init_select(lex);
4757
lex->current_select->parsing_place= SELECT_LIST;
4356
4764
DATABASES show_wild
4358
if (not show::buildScemas(YYSession))
4767
Session *session= YYSession;
4769
lex->sql_command= SQLCOM_SELECT;
4771
new(std::nothrow) statement::Select(session);
4772
if (lex->statement == NULL)
4775
std::string column_name= "Database";
4778
column_name.append(" (");
4779
column_name.append(Lex->wild->ptr());
4780
column_name.append(")");
4783
if (Lex->current_select->where)
4785
if (prepare_new_schema_table(session, lex, "SCHEMAS"))
4790
if (prepare_new_schema_table(session, lex, "SHOW_SCHEMAS"))
4794
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "SCHEMA_NAME");
4795
my_field->is_autogenerated_name= false;
4796
my_field->set_name(column_name.c_str(), column_name.length(), system_charset_info);
4798
if (session->add_item_to_list(my_field))
4801
if (session->add_order_to_list(my_field, true))
4362
4804
| TABLES opt_db show_wild
4364
if (not show::buildTables(YYSession, $2))
4807
Session *session= YYSession;
4809
lex->sql_command= SQLCOM_SELECT;
4811
statement::Select *select=
4812
new(std::nothrow) statement::Select(YYSession);
4814
lex->statement= select;
4816
if (lex->statement == NULL)
4820
std::string column_name= "Tables_in_";
4824
SchemaIdentifier identifier($2);
4825
column_name.append($2);
4826
lex->select_lex.db= $2;
4827
if (not plugin::StorageEngine::doesSchemaExist(identifier))
4829
my_error(ER_BAD_DB_ERROR, MYF(0), $2);
4831
select->setShowPredicate($2, "");
4833
else if (not session->db.empty())
4835
column_name.append(session->db);
4836
select->setShowPredicate(session->db, "");
4840
my_error(ER_NO_DB_ERROR, MYF(0));
4846
column_name.append(" (");
4847
column_name.append(Lex->wild->ptr());
4848
column_name.append(")");
4851
if (prepare_new_schema_table(YYSession, lex, "SHOW_TABLES"))
4854
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "TABLE_NAME");
4855
my_field->is_autogenerated_name= false;
4856
my_field->set_name(column_name.c_str(), column_name.length(), system_charset_info);
4858
if (session->add_item_to_list(my_field))
4861
if (session->add_order_to_list(my_field, true))
4367
/* SHOW TEMPORARY TABLES */
4368
4864
| TEMPORARY_SYM TABLES show_wild
4370
if (not show::buildTemporaryTables(YYSession))
4867
Session *session= YYSession;
4869
lex->sql_command= SQLCOM_SELECT;
4871
statement::Select *select=
4872
new(std::nothrow) statement::Select(YYSession);
4874
lex->statement= select;
4876
if (lex->statement == NULL)
4880
if (prepare_new_schema_table(YYSession, lex, "SHOW_TEMPORARY_TABLES"))
4883
if (session->add_item_to_list( new Item_field(&session->lex->current_select->
4887
(session->lex->current_select->with_wild)++;
4373
/* SHOW TABLE STATUS */
4374
4890
| TABLE_SYM STATUS_SYM opt_db show_wild
4376
if (not show::buildTableStatus(YYSession, $3))
4893
lex->sql_command= SQLCOM_SELECT;
4894
statement::Select *select=
4895
new(std::nothrow) statement::Select(YYSession);
4897
lex->statement= select;
4899
if (lex->statement == NULL)
4902
Session *session= YYSession;
4904
std::string column_name= "Tables_in_";
4908
lex->select_lex.db= $3;
4910
SchemaIdentifier identifier($3);
4911
if (not plugin::StorageEngine::doesSchemaExist(identifier))
4913
my_error(ER_BAD_DB_ERROR, MYF(0), $3);
4916
select->setShowPredicate($3, "");
4920
select->setShowPredicate(session->db, "");
4923
if (prepare_new_schema_table(session, lex, "SHOW_TABLE_STATUS"))
4926
if (session->add_item_to_list( new Item_field(&session->lex->current_select->
4930
(session->lex->current_select->with_wild)++;
4379
/* SHOW COLUMNS FROM table_name */
4380
4932
| COLUMNS from_or_in table_ident opt_db show_wild
4382
if (not show::buildColumns(YYSession, $4, $3))
4385
/* SHOW INDEXES from table */
4935
Session *session= YYSession;
4936
statement::Select *select;
4938
lex->sql_command= SQLCOM_SELECT;
4940
select= new(std::nothrow) statement::Select(session);
4942
lex->statement= select;
4944
if (lex->statement == NULL)
4948
select->setShowPredicate($4, $3->table.str);
4949
else if ($3->db.str)
4950
select->setShowPredicate($3->db.str, $3->table.str);
4952
select->setShowPredicate(session->db, $3->table.str);
4955
drizzled::TableIdentifier identifier(select->getShowSchema().c_str(), $3->table.str);
4956
if (not plugin::StorageEngine::doesTableExist(*session, identifier))
4958
my_error(ER_NO_SUCH_TABLE, MYF(0),
4959
select->getShowSchema().c_str(),
4964
if (prepare_new_schema_table(session, lex, "SHOW_COLUMNS"))
4967
if (session->add_item_to_list( new Item_field(&session->lex->current_select->
4971
(session->lex->current_select->with_wild)++;
4386
4974
| keys_or_index from_or_in table_ident opt_db where_clause
4388
if (not show::buildIndex(YYSession, $4, $3))
4977
Session *session= YYSession;
4978
statement::Select *select;
4980
lex->sql_command= SQLCOM_SELECT;
4982
select= new(std::nothrow) statement::Select(session);
4984
lex->statement= select;
4986
if (lex->statement == NULL)
4990
select->setShowPredicate($4, $3->table.str);
4991
else if ($3->db.str)
4992
select->setShowPredicate($3->db.str, $3->table.str);
4994
select->setShowPredicate(session->db, $3->table.str);
4997
drizzled::TableIdentifier identifier(select->getShowSchema().c_str(), $3->table.str);
4998
if (not plugin::StorageEngine::doesTableExist(*session, identifier))
5000
my_error(ER_NO_SUCH_TABLE, MYF(0),
5001
select->getShowSchema().c_str(),
5006
if (prepare_new_schema_table(session, lex, "SHOW_INDEXES"))
5009
if (session->add_item_to_list( new Item_field(&session->lex->current_select->
5013
(session->lex->current_select->with_wild)++;
4391
5015
| COUNT_SYM '(' '*' ')' WARNINGS
4393
show::buildSelectWarning(YYSession);
5017
(void) create_select_for_variable("warning_count");
5019
lex->statement= new(std::nothrow) statement::Select(YYSession);
5020
if (lex->statement == NULL)
4395
5023
| COUNT_SYM '(' '*' ')' ERRORS
4397
show::buildSelectError(YYSession);
5025
(void) create_select_for_variable("error_count");
5027
lex->statement= new(std::nothrow) statement::Select(YYSession);
5028
if (lex->statement == NULL)
4399
5031
| WARNINGS opt_limit_clause_init
4401
show::buildWarnings(YYSession);
5033
Lex->sql_command = SQLCOM_SHOW_WARNS;
5034
Lex->statement= new(std::nothrow) statement::ShowWarnings(YYSession);
5035
if (Lex->statement == NULL)
4403
5038
| ERRORS opt_limit_clause_init
4405
show::buildErrors(YYSession);
5040
Lex->sql_command = SQLCOM_SHOW_ERRORS;
5041
Lex->statement= new(std::nothrow) statement::ShowErrors(YYSession);
5042
if (Lex->statement == NULL)
4407
5045
| 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))
4417
| CREATE TABLE_SYM table_ident
4419
if (not show::buildCreateTable(YYSession, $3))
5048
lex->sql_command= SQLCOM_SELECT;
5050
new(std::nothrow) statement::Select(YYSession);
5051
if (lex->statement == NULL)
5054
Session *session= YYSession;
5056
if ($1 == OPT_GLOBAL)
5058
if (prepare_new_schema_table(session, lex, "GLOBAL_STATUS"))
5063
if (prepare_new_schema_table(session, lex, "SESSION_STATUS"))
5067
std::string key("Variable_name");
5068
std::string value("Value");
5070
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "VARIABLE_NAME");
5071
my_field->is_autogenerated_name= false;
5072
my_field->set_name(key.c_str(), key.length(), system_charset_info);
5074
if (session->add_item_to_list(my_field))
5077
my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "VARIABLE_VALUE");
5078
my_field->is_autogenerated_name= false;
5079
my_field->set_name(value.c_str(), value.length(), system_charset_info);
5081
if (session->add_item_to_list(my_field))
4422
5084
| PROCESSLIST_SYM
4424
if (not show::buildProcesslist(YYSession))
5088
lex->sql_command= SQLCOM_SELECT;
5090
new(std::nothrow) statement::Select(YYSession);
5091
if (lex->statement == NULL)
5094
Session *session= YYSession;
5096
if (prepare_new_schema_table(session, lex, "PROCESSLIST"))
5099
if (session->add_item_to_list( new Item_field(&session->lex->current_select->
5103
(session->lex->current_select->with_wild)++;
4427
5106
| opt_var_type VARIABLES show_wild
4429
if (not show::buildVariables(YYSession, $1))
5109
lex->sql_command= SQLCOM_SELECT;
5111
new(std::nothrow) statement::Select(YYSession);
5112
if (lex->statement == NULL)
5115
Session *session= YYSession;
5117
if ($1 == OPT_GLOBAL)
5119
if (prepare_new_schema_table(session, lex, "GLOBAL_VARIABLES"))
5124
if (prepare_new_schema_table(session, lex, "SESSION_VARIABLES"))
5128
std::string key("Variable_name");
5129
std::string value("Value");
5131
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "VARIABLE_NAME");
5132
my_field->is_autogenerated_name= false;
5133
my_field->set_name(key.c_str(), key.length(), system_charset_info);
5135
if (session->add_item_to_list(my_field))
5138
my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "VARIABLE_VALUE");
5139
my_field->is_autogenerated_name= false;
5140
my_field->set_name(value.c_str(), value.length(), system_charset_info);
5142
if (session->add_item_to_list(my_field))
4432
5145
| CREATE DATABASE opt_if_not_exists ident
4434
if (not show::buildCreateSchema(YYSession, $4))
5147
Lex->sql_command=SQLCOM_SHOW_CREATE_DB;
5148
statement::ShowCreateSchema *statement= new(std::nothrow) statement::ShowCreateSchema(YYSession);
5149
Lex->statement= statement;
5150
if (Lex->statement == NULL)
5152
statement->is_if_not_exists= $3;
5155
| CREATE TABLE_SYM table_ident
5158
lex->sql_command = SQLCOM_SHOW_CREATE;
5159
lex->statement= new(std::nothrow) statement::ShowCreate(YYSession);
5160
if (lex->statement == NULL)
5162
if (!lex->select_lex.add_table_to_list(YYSession, $3, NULL,0))
4435
5163
DRIZZLE_YYABORT;
4872
5672
simple_ident_q:
4873
5673
ident '.' ident
4875
$$= parser::buildIdent(Lex, NULL_LEX_STRING, $1, $3);
5675
Session *session= YYSession;
5676
LEX *lex= session->lex;
5679
Select_Lex *sel= lex->current_select;
5680
if (sel->no_table_names_allowed)
5682
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5683
MYF(0), $1.str, session->where);
5685
$$= (sel->parsing_place != IN_HAVING ||
5686
sel->get_in_sum_expr() > 0) ?
5687
(Item*) new Item_field(Lex->current_context(),
5688
(const char *)NULL, $1.str, $3.str) :
5689
(Item*) new Item_ref(Lex->current_context(),
5690
(const char *)NULL, $1.str, $3.str);
4877
5693
| '.' ident '.' ident
4879
$$= parser::buildIdent(Lex, NULL_LEX_STRING, $2, $4);
5695
Session *session= YYSession;
5696
LEX *lex= session->lex;
5697
Select_Lex *sel= lex->current_select;
5698
if (sel->no_table_names_allowed)
5700
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5701
MYF(0), $2.str, session->where);
5703
$$= (sel->parsing_place != IN_HAVING ||
5704
sel->get_in_sum_expr() > 0) ?
5705
(Item*) new Item_field(Lex->current_context(), NULL, $2.str, $4.str) :
5706
(Item*) new Item_ref(Lex->current_context(),
5707
(const char *)NULL, $2.str, $4.str);
4881
5709
| ident '.' ident '.' ident
4883
$$= parser::buildIdent(Lex, $1, $3, $5);
5711
Session *session= YYSession;
5712
LEX *lex= session->lex;
5713
Select_Lex *sel= lex->current_select;
5714
if (sel->no_table_names_allowed)
5716
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5717
MYF(0), $3.str, session->where);
5719
$$= (sel->parsing_place != IN_HAVING ||
5720
sel->get_in_sum_expr() > 0) ?
5721
(Item*) new Item_field(Lex->current_context(), $1.str, $3.str,
5723
(Item*) new Item_ref(Lex->current_context(), $1.str, $3.str,
4892
5730
| ident '.' ident '.' ident
4894
if (not parser::checkFieldIdent(Lex, $1, $3))
5733
reinterpret_cast<TableList*>(Lex->current_select->table_list.first);
5734
if (my_strcasecmp(table_alias_charset, $1.str, table->db))
5736
my_error(ER_WRONG_DB_NAME, MYF(0), $1.str);
5739
if (my_strcasecmp(table_alias_charset, $3.str,
5742
my_error(ER_WRONG_TABLE_NAME, MYF(0), $3.str);
4899
5747
| ident '.' ident
4901
if (not parser::checkFieldIdent(Lex, NULL_LEX_STRING, $1))
5750
reinterpret_cast<TableList*>(Lex->current_select->table_list.first);
5751
if (my_strcasecmp(table_alias_charset, $1.str, table->alias))
5753
my_error(ER_WRONG_TABLE_NAME, MYF(0), $1.str);
4902
5754
DRIZZLE_YYABORT;
5758
| '.' ident { $$=$2;} /* For Delphi */
4915
$$= new Table_ident($1);
4917
| schema_name '.' ident
4919
$$=new Table_ident($1,$3);
4923
$$= new Table_ident($2);
5762
ident { $$=new Table_ident($1); }
5763
| ident '.' ident { $$=new Table_ident($1,$3);}
5764
| '.' ident { $$=new Table_ident($2);} /* For Delphi */
4942
5771
const CHARSET_INFO * const cs= system_charset_info;