99
147
This function is not for use in semantic actions and is internal to
100
148
the parser, as it performs some pre-return cleanup.
101
In semantic actions, please use parser::my_parse_error or my_error to
149
In semantic actions, please use my_parse_error or my_error to
102
150
push an error into the error stack and DRIZZLE_YYABORT
103
151
to abort from the parser.
106
static void base_sql_error(drizzled::Session *session, const char *s)
108
parser::errorOn(session, s);
154
static void DRIZZLEerror(const char *s)
156
Session *session= current_session;
159
Restore the original LEX if it was replaced when parsing
160
a stored procedure. We must ensure that a parsing error
161
does not leave any side effects in the Session.
163
LEX::cleanup_lex_after_parse_error(session);
165
/* "parse error" changed into "syntax error" between bison 1.75 and 1.875 */
166
if (strcmp(s,"parse error") == 0 || strcmp(s,"syntax error") == 0)
167
s= ER(ER_SYNTAX_ERROR);
169
struct my_parse_error_st pass= { s, session };
170
my_parse_error(&pass);
174
Helper to resolve the SQL:2003 Syntax exception 1) in <in predicate>.
175
See SQL:2003, Part 2, section 8.4 <in predicate>, Note 184, page 383.
176
This function returns the proper item for the SQL expression
177
<code>left [NOT] IN ( expr )</code>
178
@param session the current thread
179
@param left the in predicand
180
@param equal true for IN predicates, false for NOT IN predicates
181
@param expr first and only expression of the in value list
182
@return an expression representing the IN predicate.
184
static Item* handle_sql2003_note184_exception(Session *session,
185
Item* left, bool equal,
189
Relevant references for this issue:
190
- SQL:2003, Part 2, section 8.4 <in predicate>, page 383,
191
- SQL:2003, Part 2, section 7.2 <row value expression>, page 296,
192
- SQL:2003, Part 2, section 6.3 <value expression primary>, page 174,
193
- SQL:2003, Part 2, section 7.15 <subquery>, page 370,
194
- SQL:2003 Feature F561, "Full value expressions".
196
The exception in SQL:2003 Note 184 means:
197
Item_singlerow_subselect, which corresponds to a <scalar subquery>,
198
should be re-interpreted as an Item_in_subselect, which corresponds
199
to a <table subquery> when used inside an <in predicate>.
201
Our reading of Note 184 is reccursive, so that all:
202
- IN (( <subquery> ))
203
- IN ((( <subquery> )))
204
- IN '('^N <subquery> ')'^N
206
should be interpreted as a <table subquery>, no matter how deep in the
207
expression the <subquery> is.
212
if (expr->type() == Item::SUBSELECT_ITEM)
214
Item_subselect *expr2 = (Item_subselect*) expr;
216
if (expr2->substype() == Item_subselect::SINGLEROW_SUBS)
218
Item_singlerow_subselect *expr3 = (Item_singlerow_subselect*) expr2;
219
Select_Lex *subselect;
222
Implement the mandated change, by altering the semantic tree:
223
left IN Item_singlerow_subselect(subselect)
226
which is represented as
227
Item_in_subselect(left, subselect)
229
subselect= expr3->invalidate_and_restore_select_lex();
230
result= new (session->mem_root) Item_in_subselect(left, subselect);
233
result = negate_expression(session, result);
240
result= new (session->mem_root) Item_func_eq(left, expr);
242
result= new (session->mem_root) Item_func_ne(left, expr);
248
@brief Creates a new Select_Lex for a UNION branch.
250
Sets up and initializes a Select_Lex structure for a query once the parser
251
discovers a UNION token. The current Select_Lex is pushed on the stack and
252
the new Select_Lex becomes the current one..=
254
@lex The parser state.
256
@is_union_distinct True if the union preceding the new select statement
259
@return <code>false</code> if successful, <code>true</code> if an error was
260
reported. In the latter case parsing should stop.
262
static bool add_select_to_union_list(Session *session, LEX *lex, bool is_union_distinct)
266
/* Only the last SELECT can have INTO...... */
267
my_error(ER_WRONG_USAGE, MYF(0), "UNION", "INTO");
270
if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE)
272
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), session };
273
my_parse_error(&pass);
276
/* This counter shouldn't be incremented for UNION parts */
278
if (new_select(lex, 0))
281
lex->current_select->linkage=UNION_TYPE;
282
if (is_union_distinct) /* UNION DISTINCT - remember position */
283
lex->current_select->master_unit()->union_distinct=
289
@brief Initializes a Select_Lex for a query within parentheses (aka
292
@return false if successful, true if an error was reported. In the latter
293
case parsing should stop.
295
static bool setup_select_in_parentheses(Session *session, LEX *lex)
297
Select_Lex * sel= lex->current_select;
298
if (sel->set_braces(1))
300
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), session };
301
my_parse_error(&pass);
304
if (sel->linkage == UNION_TYPE &&
305
!sel->master_unit()->first_select()->braces &&
306
sel->master_unit()->first_select()->linkage ==
309
struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), session };
310
my_parse_error(&pass);
313
if (sel->linkage == UNION_TYPE &&
314
sel->olap != UNSPECIFIED_OLAP_TYPE &&
315
sel->master_unit()->fake_select_lex)
317
my_error(ER_WRONG_USAGE, MYF(0), "CUBE/ROLLUP", "ORDER BY");
320
/* select in braces, can't contain global parameters */
321
if (sel->master_unit()->fake_select_lex)
322
sel->master_unit()->global_parameters=
323
sel->master_unit()->fake_select_lex;
327
static Item* reserved_keyword_function(Session *session, const std::string &name, List<Item> *item_list)
329
const plugin::Function *udf= plugin::Function::get(name.c_str(), name.length());
334
item= Create_udf_func::s_singleton.create(session, udf, item_list);
336
my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", name.c_str());
111
342
} /* namespace drizzled; */
113
344
using namespace drizzled;
118
unsigned long ulong_num;
119
350
uint64_t ulonglong_number;
120
351
int64_t longlong_number;
121
352
drizzled::LEX_STRING lex_str;
1109
1382
field_spec opt_check_constraint
1110
1383
| field_spec references
1112
Lex->col_list.clear(); /* Alloced by memory::sql_alloc */
1385
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1117
1390
key_type opt_ident key_alg '(' key_list ')' key_options
1119
parser::buildKey(Lex, $1, $2);
1392
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1393
Key *key= new Key($1, $2, &statement->key_create_info, 0,
1395
statement->alter_info.key_list.push_back(key);
1396
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1121
1398
| opt_constraint constraint_key_type opt_ident key_alg
1122
1399
'(' key_list ')' key_options
1124
parser::buildKey(Lex, $2, $3.str ? $3 : $1);
1401
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1402
Key *key= new Key($2, $3.str ? $3 : $1, &statement->key_create_info, 0,
1404
statement->alter_info.key_list.push_back(key);
1405
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1126
1407
| opt_constraint FOREIGN KEY_SYM opt_ident '(' key_list ')' references
1128
parser::buildForeignKey(Lex, $1.str ? $1 : $4, $8);
1409
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1410
Key *key= new Foreign_key($1.str ? $1 : $4, Lex->col_list,
1413
statement->fk_delete_opt,
1414
statement->fk_update_opt,
1415
statement->fk_match_option);
1417
statement->alter_info.key_list.push_back(key);
1418
key= new Key(Key::MULTIPLE, $1.str ? $1 : $4,
1419
&default_key_create_info, 1,
1421
statement->alter_info.key_list.push_back(key);
1422
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1423
/* Only used for ALTER TABLE. Ignored otherwise. */
1424
statement->alter_info.flags.set(ALTER_FOREIGN_KEY);
1130
1426
| constraint opt_check_constraint
1132
Lex->col_list.clear(); /* Alloced by memory::sql_alloc */
1428
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1134
1430
| opt_constraint check_constraint
1136
Lex->col_list.clear(); /* Alloced by memory::sql_alloc */
1432
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1188
1492
field_definition:
1189
1493
int_type ignored_field_number_length opt_field_number_signed opt_zerofill
1191
$$= parser::buildIntegerColumn(Lex, $1, ($3 or $4));
1496
Lex->length=(char*) 0; /* use default length */
1500
$1= DRIZZLE_TYPE_LONGLONG;
1505
assert ($1 == DRIZZLE_TYPE_LONG or $1 == DRIZZLE_TYPE_LONGLONG);
1506
// We update the type for unsigned types
1509
Lex->field()->set_type(message::Table::Field::BIGINT);
1510
Lex->field()->mutable_constraints()->set_is_unsigned(true);
1512
if ($1 == DRIZZLE_TYPE_LONG)
1514
Lex->field()->set_type(message::Table::Field::INTEGER);
1516
else if ($1 == DRIZZLE_TYPE_LONGLONG)
1518
Lex->field()->set_type(message::Table::Field::BIGINT);
1193
1522
| 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);
1216
$$=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);
1238
$$=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();
1528
assert ($1 == DRIZZLE_TYPE_DOUBLE);
1529
Lex->field()->set_type(message::Table::Field::DOUBLE);
1535
$$=DRIZZLE_TYPE_VARCHAR;
1539
Lex->field()->set_type(message::Table::Field::VARCHAR);
1540
message::Table::Field::StringFieldOptions *string_field_options;
1542
string_field_options= Lex->field()->mutable_string_options();
1544
string_field_options->set_length(atoi($3.str));
1549
Lex->length=(char*) "1";
1550
$$=DRIZZLE_TYPE_VARCHAR;
1553
Lex->field()->set_type(message::Table::Field::VARCHAR);
1555
| varchar '(' NUM ')'
1558
$$= DRIZZLE_TYPE_VARCHAR;
1562
Lex->field()->set_type(message::Table::Field::VARCHAR);
1564
message::Table::Field::StringFieldOptions *string_field_options;
1566
string_field_options= Lex->field()->mutable_string_options();
1568
string_field_options->set_length(atoi($3.str));
1571
| VARBINARY '(' NUM ')'
1574
Lex->charset=&my_charset_bin;
1575
$$= DRIZZLE_TYPE_VARCHAR;
1579
Lex->field()->set_type(message::Table::Field::VARCHAR);
1580
message::Table::Field::StringFieldOptions *string_field_options;
1582
string_field_options= Lex->field()->mutable_string_options();
1584
string_field_options->set_length(atoi($3.str));
1585
string_field_options->set_collation_id(my_charset_bin.number);
1586
string_field_options->set_collation(my_charset_bin.name);
1591
$$=DRIZZLE_TYPE_DATE;
1594
Lex->field()->set_type(message::Table::Field::DATE);
1598
$$=DRIZZLE_TYPE_TIME;
1601
Lex->field()->set_type(message::Table::Field::TIME);
1605
$$=DRIZZLE_TYPE_TIMESTAMP;
1609
Lex->field()->set_type(message::Table::Field::EPOCH);
1611
| TIMESTAMP_SYM '(' NUM ')'
1613
$$=DRIZZLE_TYPE_MICROTIME;
1614
Lex->length= $3.str;
1617
Lex->field()->set_type(message::Table::Field::EPOCH);
1621
$$=DRIZZLE_TYPE_DATETIME;
1624
Lex->field()->set_type(message::Table::Field::DATETIME);
1628
Lex->charset=&my_charset_bin;
1629
$$=DRIZZLE_TYPE_BLOB;
1630
Lex->length=(char*) 0; /* use default length */
1634
Lex->field()->set_type(message::Table::Field::BLOB);
1635
message::Table::Field::StringFieldOptions *string_field_options;
1637
string_field_options= Lex->field()->mutable_string_options();
1638
string_field_options->set_collation_id(my_charset_bin.number);
1639
string_field_options->set_collation(my_charset_bin.name);
1644
$$=DRIZZLE_TYPE_BLOB;
1645
Lex->length=(char*) 0; /* use default length */
1648
Lex->field()->set_type(message::Table::Field::BLOB);
1650
| DECIMAL_SYM float_options
1652
$$=DRIZZLE_TYPE_DECIMAL;
1655
Lex->field()->set_type(message::Table::Field::DECIMAL);
1657
| NUMERIC_SYM float_options
1659
$$=DRIZZLE_TYPE_DECIMAL;
1662
Lex->field()->set_type(message::Table::Field::DECIMAL);
1664
| FIXED_SYM float_options
1666
$$=DRIZZLE_TYPE_DECIMAL;
1669
Lex->field()->set_type(message::Table::Field::DECIMAL);
1672
{Lex->interval_list.empty();}
1273
1675
$$=DRIZZLE_TYPE_ENUM;
4331
4859
DATABASES show_wild
4333
if (not show::buildScemas(YYSession))
4861
Lex->sql_command= SQLCOM_SELECT;
4862
Lex->statement= new statement::Show(YYSession);
4864
std::string column_name= "Database";
4867
column_name.append(" (");
4868
column_name.append(Lex->wild->ptr());
4869
column_name.append(")");
4872
if (Lex->current_select->where)
4874
if (prepare_new_schema_table(YYSession, Lex, "SCHEMAS"))
4879
if (prepare_new_schema_table(YYSession, Lex, "SHOW_SCHEMAS"))
4883
Item_field *my_field= new Item_field(&YYSession->lex->current_select->context, NULL, NULL, "SCHEMA_NAME");
4884
my_field->is_autogenerated_name= false;
4885
my_field->set_name(column_name.c_str(), column_name.length(), system_charset_info);
4887
if (YYSession->add_item_to_list(my_field))
4334
4888
DRIZZLE_YYABORT;
4890
if (YYSession->add_order_to_list(my_field, true))
4336
4893
/* SHOW TABLES */
4337
4894
| TABLES opt_db show_wild
4339
if (not show::buildTables(YYSession, $2))
4896
Lex->sql_command= SQLCOM_SELECT;
4898
drizzled::statement::Show *select= new statement::Show(YYSession);
4899
Lex->statement= select;
4901
std::string column_name= "Tables_in_";
4903
util::string::const_shared_ptr schema(YYSession->schema());
4906
identifier::Schema identifier($2);
4907
column_name.append($2);
4908
Lex->select_lex.db= $2;
4909
if (not plugin::StorageEngine::doesSchemaExist(identifier))
4911
my_error(ER_BAD_DB_ERROR, MYF(0), $2);
4913
select->setShowPredicate($2, "");
4915
else if (schema and not schema->empty())
4917
column_name.append(*schema);
4918
select->setShowPredicate(*schema, "");
4922
my_error(ER_NO_DB_ERROR, MYF(0));
4929
column_name.append(" (");
4930
column_name.append(Lex->wild->ptr());
4931
column_name.append(")");
4934
if (prepare_new_schema_table(YYSession, Lex, "SHOW_TABLES"))
4937
Item_field *my_field= new Item_field(&YYSession->lex->current_select->context, NULL, NULL, "TABLE_NAME");
4938
my_field->is_autogenerated_name= false;
4939
my_field->set_name(column_name.c_str(), column_name.length(), system_charset_info);
4941
if (YYSession->add_item_to_list(my_field))
4944
if (YYSession->add_order_to_list(my_field, true))
4342
4947
/* SHOW TEMPORARY TABLES */
4343
4948
| TEMPORARY_SYM TABLES show_wild
4345
if (not show::buildTemporaryTables(YYSession))
4950
Lex->sql_command= SQLCOM_SELECT;
4952
Lex->statement= new statement::Show(YYSession);
4955
if (prepare_new_schema_table(YYSession, Lex, "SHOW_TEMPORARY_TABLES"))
4958
if (YYSession->add_item_to_list( new Item_field(&YYSession->lex->current_select->
4962
(YYSession->lex->current_select->with_wild)++;
4348
4965
/* SHOW TABLE STATUS */
4349
4966
| TABLE_SYM STATUS_SYM opt_db show_wild
4351
if (not show::buildTableStatus(YYSession, $3))
4968
Lex->sql_command= SQLCOM_SELECT;
4969
drizzled::statement::Show *select= new statement::Show(YYSession);
4970
Lex->statement= select;
4972
std::string column_name= "Tables_in_";
4974
util::string::const_shared_ptr schema(YYSession->schema());
4977
Lex->select_lex.db= $3;
4979
identifier::Schema identifier($3);
4980
if (not plugin::StorageEngine::doesSchemaExist(identifier))
4982
my_error(ER_BAD_DB_ERROR, MYF(0), $3);
4985
select->setShowPredicate($3, "");
4989
select->setShowPredicate(*schema, "");
4993
my_error(ER_NO_DB_ERROR, MYF(0));
4997
if (prepare_new_schema_table(YYSession, Lex, "SHOW_TABLE_STATUS"))
5000
if (YYSession->add_item_to_list( new Item_field(&YYSession->lex->current_select->
5004
(YYSession->lex->current_select->with_wild)++;
4354
5006
/* SHOW COLUMNS FROM table_name */
4355
5007
| COLUMNS from_or_in table_ident opt_db show_wild
4357
if (not show::buildColumns(YYSession, $4, $3))
5009
Lex->sql_command= SQLCOM_SELECT;
5011
drizzled::statement::Show *select= new statement::Show(YYSession);
5012
Lex->statement= select;
5014
util::string::const_shared_ptr schema(YYSession->schema());
5017
select->setShowPredicate($4, $3->table.str);
5019
else if ($3->db.str)
5021
select->setShowPredicate($3->db.str, $3->table.str);
5025
select->setShowPredicate(*schema, $3->table.str);
5029
my_error(ER_NO_DB_ERROR, MYF(0));
5034
drizzled::identifier::Table identifier(select->getShowSchema().c_str(), $3->table.str);
5035
if (not plugin::StorageEngine::doesTableExist(*YYSession, identifier))
5037
my_error(ER_NO_SUCH_TABLE, MYF(0),
5038
select->getShowSchema().c_str(),
5043
if (prepare_new_schema_table(YYSession, Lex, "SHOW_COLUMNS"))
5046
if (YYSession->add_item_to_list( new Item_field(&YYSession->lex->current_select->
5050
(YYSession->lex->current_select->with_wild)++;
4360
5053
/* SHOW INDEXES from table */
4361
5054
| keys_or_index from_or_in table_ident opt_db where_clause
4363
if (not show::buildIndex(YYSession, $4, $3))
5056
Lex->sql_command= SQLCOM_SELECT;
5057
drizzled::statement::Show *select= new statement::Show(YYSession);
5058
Lex->statement= select;
5060
util::string::const_shared_ptr schema(YYSession->schema());
5063
select->setShowPredicate($4, $3->table.str);
5065
else if ($3->db.str)
5067
select->setShowPredicate($3->db.str, $3->table.str);
5071
select->setShowPredicate(*schema, $3->table.str);
5075
my_error(ER_NO_DB_ERROR, MYF(0));
5080
drizzled::identifier::Table identifier(select->getShowSchema().c_str(), $3->table.str);
5081
if (not plugin::StorageEngine::doesTableExist(*YYSession, identifier))
5083
my_error(ER_NO_SUCH_TABLE, MYF(0),
5084
select->getShowSchema().c_str(),
5089
if (prepare_new_schema_table(YYSession, Lex, "SHOW_INDEXES"))
5092
if (YYSession->add_item_to_list( new Item_field(&YYSession->lex->current_select->
5096
(YYSession->lex->current_select->with_wild)++;
4366
5098
| COUNT_SYM '(' '*' ')' WARNINGS
4368
show::buildSelectWarning(YYSession);
5100
(void) create_select_for_variable("warning_count");
5101
Lex->statement= new statement::Show(YYSession);
4370
5103
| COUNT_SYM '(' '*' ')' ERRORS
4372
show::buildSelectError(YYSession);
5105
(void) create_select_for_variable("error_count");
5106
Lex->statement= new statement::Show(YYSession);
4374
5108
| WARNINGS opt_limit_clause_init
4376
show::buildWarnings(YYSession);
5110
Lex->sql_command = SQLCOM_SHOW_WARNS;
5111
Lex->statement= new statement::ShowWarnings(YYSession);
4378
5113
| ERRORS opt_limit_clause_init
4380
show::buildErrors(YYSession);
5115
Lex->sql_command = SQLCOM_SHOW_ERRORS;
5116
Lex->statement= new statement::ShowErrors(YYSession);
4382
5118
| 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))
5120
Lex->sql_command= SQLCOM_SELECT;
5121
Lex->statement= new statement::Show(YYSession);
5123
if ($1 == OPT_GLOBAL)
5125
if (prepare_new_schema_table(YYSession, Lex, "GLOBAL_STATUS"))
5130
if (prepare_new_schema_table(YYSession, Lex, "SESSION_STATUS"))
5134
std::string key("Variable_name");
5135
std::string value("Value");
5137
Item_field *my_field= new Item_field(&YYSession->lex->current_select->context, NULL, NULL, "VARIABLE_NAME");
5138
my_field->is_autogenerated_name= false;
5139
my_field->set_name(key.c_str(), key.length(), system_charset_info);
5141
if (YYSession->add_item_to_list(my_field))
5144
my_field= new Item_field(&YYSession->lex->current_select->context, NULL, NULL, "VARIABLE_VALUE");
5145
my_field->is_autogenerated_name= false;
5146
my_field->set_name(value.c_str(), value.length(), system_charset_info);
5148
if (YYSession->add_item_to_list(my_field))
4392
5151
| CREATE TABLE_SYM table_ident
4394
if (not show::buildCreateTable(YYSession, $3))
5153
Lex->sql_command= SQLCOM_SELECT;
5154
statement::Show *select= new statement::Show(YYSession);
5155
Lex->statement= select;
5157
if (Lex->statement == NULL)
5160
if (prepare_new_schema_table(YYSession, Lex, "TABLE_SQL_DEFINITION"))
5163
util::string::const_shared_ptr schema(YYSession->schema());
5166
select->setShowPredicate($3->db.str, $3->table.str);
5170
select->setShowPredicate(*schema, $3->table.str);
5174
my_error(ER_NO_DB_ERROR, MYF(0));
5178
std::string key("Table");
5179
std::string value("Create Table");
5181
Item_field *my_field= new Item_field(&YYSession->lex->current_select->context, NULL, NULL, "TABLE_NAME");
5182
my_field->is_autogenerated_name= false;
5183
my_field->set_name(key.c_str(), key.length(), system_charset_info);
5185
if (YYSession->add_item_to_list(my_field))
5188
my_field= new Item_field(&YYSession->lex->current_select->context, NULL, NULL, "TABLE_SQL_DEFINITION");
5189
my_field->is_autogenerated_name= false;
5190
my_field->set_name(value.c_str(), value.length(), system_charset_info);
5192
if (YYSession->add_item_to_list(my_field))
4397
5195
| PROCESSLIST_SYM
4399
if (not show::buildProcesslist(YYSession))
5198
Lex->sql_command= SQLCOM_SELECT;
5199
Lex->statement= new statement::Show(YYSession);
5201
if (prepare_new_schema_table(YYSession, Lex, "PROCESSLIST"))
5204
if (YYSession->add_item_to_list( new Item_field(&YYSession->lex->current_select->
5208
(YYSession->lex->current_select->with_wild)++;
4402
5211
| opt_var_type VARIABLES show_wild
4404
if (not show::buildVariables(YYSession, $1))
5213
Lex->sql_command= SQLCOM_SELECT;
5214
Lex->statement= new statement::Show(YYSession);
5216
if ($1 == OPT_GLOBAL)
5218
if (prepare_new_schema_table(YYSession, Lex, "GLOBAL_VARIABLES"))
5223
if (prepare_new_schema_table(YYSession, Lex, "SESSION_VARIABLES"))
5227
std::string key("Variable_name");
5228
std::string value("Value");
5230
Item_field *my_field= new Item_field(&YYSession->lex->current_select->context, NULL, NULL, "VARIABLE_NAME");
5231
my_field->is_autogenerated_name= false;
5232
my_field->set_name(key.c_str(), key.length(), system_charset_info);
5234
if (YYSession->add_item_to_list(my_field))
5237
my_field= new Item_field(&YYSession->lex->current_select->context, NULL, NULL, "VARIABLE_VALUE");
5238
my_field->is_autogenerated_name= false;
5239
my_field->set_name(value.c_str(), value.length(), system_charset_info);
5241
if (YYSession->add_item_to_list(my_field))
4407
5244
| CREATE DATABASE opt_if_not_exists ident
4409
if (not show::buildCreateSchema(YYSession, $4))
5246
Lex->sql_command= SQLCOM_SELECT;
5247
drizzled::statement::Show *select= new statement::Show(YYSession);
5248
Lex->statement= select;
5250
if (prepare_new_schema_table(YYSession, Lex, "SCHEMA_SQL_DEFINITION"))
5253
util::string::const_shared_ptr schema(YYSession->schema());
5256
select->setShowPredicate($4.str);
5260
select->setShowPredicate(*schema);
5264
my_error(ER_NO_DB_ERROR, MYF(0));
5268
std::string key("Database");
5269
std::string value("Create Database");
5271
Item_field *my_field= new Item_field(&YYSession->lex->current_select->context, NULL, NULL, "SCHEMA_NAME");
5272
my_field->is_autogenerated_name= false;
5273
my_field->set_name(key.c_str(), key.length(), system_charset_info);
5275
if (YYSession->add_item_to_list(my_field))
5278
my_field= new Item_field(&YYSession->lex->current_select->context, NULL, NULL, "SCHEMA_SQL_DEFINITION");
5279
my_field->is_autogenerated_name= false;
5280
my_field->set_name(value.c_str(), value.length(), system_charset_info);
5282
if (YYSession->add_item_to_list(my_field))
4414
5287
/* empty */ { $$= 0; }
4847
5798
simple_ident_q:
4848
5799
ident '.' ident
4850
$$= parser::buildIdent(Lex, NULL_LEX_STRING, $1, $3);
5802
Select_Lex *sel= Lex->current_select;
5803
if (sel->no_table_names_allowed)
5805
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5806
MYF(0), $1.str, YYSession->where);
5808
$$= (sel->parsing_place != IN_HAVING ||
5809
sel->get_in_sum_expr() > 0) ?
5810
(Item*) new Item_field(Lex->current_context(),
5811
(const char *)NULL, $1.str, $3.str) :
5812
(Item*) new Item_ref(Lex->current_context(),
5813
(const char *)NULL, $1.str, $3.str);
4852
5816
| '.' ident '.' ident
4854
$$= parser::buildIdent(Lex, NULL_LEX_STRING, $2, $4);
5818
Select_Lex *sel= Lex->current_select;
5819
if (sel->no_table_names_allowed)
5821
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5822
MYF(0), $2.str, YYSession->where);
5824
$$= (sel->parsing_place != IN_HAVING ||
5825
sel->get_in_sum_expr() > 0) ?
5826
(Item*) new Item_field(Lex->current_context(), NULL, $2.str, $4.str) :
5827
(Item*) new Item_ref(Lex->current_context(),
5828
(const char *)NULL, $2.str, $4.str);
4856
5830
| ident '.' ident '.' ident
4858
$$= parser::buildIdent(Lex, $1, $3, $5);
5832
Select_Lex *sel= Lex->current_select;
5833
if (sel->no_table_names_allowed)
5835
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5836
MYF(0), $3.str, YYSession->where);
5838
$$= (sel->parsing_place != IN_HAVING ||
5839
sel->get_in_sum_expr() > 0) ?
5840
(Item*) new Item_field(Lex->current_context(), $1.str, $3.str,
5842
(Item*) new Item_ref(Lex->current_context(), $1.str, $3.str,
4867
5849
| ident '.' ident '.' ident
4869
if (not parser::checkFieldIdent(Lex, $1, $3))
5852
reinterpret_cast<TableList*>(Lex->current_select->table_list.first);
5853
if (my_strcasecmp(table_alias_charset, $1.str, table->getSchemaName()))
5855
my_error(ER_WRONG_DB_NAME, MYF(0), $1.str);
5858
if (my_strcasecmp(table_alias_charset, $3.str,
5859
table->getTableName()))
5861
my_error(ER_WRONG_TABLE_NAME, MYF(0), $3.str);
4874
5866
| ident '.' ident
4876
if (not parser::checkFieldIdent(Lex, NULL_LEX_STRING, $1))
5869
reinterpret_cast<TableList*>(Lex->current_select->table_list.first);
5870
if (my_strcasecmp(table_alias_charset, $1.str, table->alias))
5872
my_error(ER_WRONG_TABLE_NAME, MYF(0), $1.str);
4877
5873
DRIZZLE_YYABORT;
5877
| '.' ident { $$=$2;} /* For Delphi */
4890
$$= new Table_ident($1);
4892
| schema_name '.' ident
4894
$$=new Table_ident($1,$3);
4898
$$= new Table_ident($2);
5881
ident { $$=new Table_ident($1); }
5882
| schema_name '.' ident { $$=new Table_ident($1,$3);}
5883
| '.' ident { $$=new Table_ident($2);} /* For Delphi */