36
36
#define YYINITDEPTH 100
37
37
#define YYMAXDEPTH 3200 /* Because of 64K stack */
38
38
#define Lex (YYSession->lex)
41
#include "drizzled/parser.h"
39
#include <drizzled/server_includes.h>
40
#include <drizzled/lex_symbol.h>
41
#include <drizzled/function/locate.h>
42
#include <drizzled/function/str/char.h>
43
#include <drizzled/function/str/collation.h>
44
#include <drizzled/function/str/database.h>
45
#include <drizzled/function/str/insert.h>
46
#include <drizzled/function/str/left.h>
47
#include <drizzled/function/str/repeat.h>
48
#include <drizzled/function/str/replace.h>
49
#include <drizzled/function/str/reverse.h>
50
#include <drizzled/function/str/right.h>
51
#include <drizzled/function/str/set_collation.h>
52
#include <drizzled/function/str/substr.h>
53
#include <drizzled/function/str/trim.h>
54
#include <drizzled/function/str/user.h>
55
#include <drizzled/function/str/weight_string.h>
57
#include <drizzled/function/time/curdate.h>
58
#include <drizzled/function/time/date_add_interval.h>
59
#include <drizzled/function/time/dayofmonth.h>
60
#include <drizzled/function/time/extract.h>
61
#include <drizzled/function/time/hour.h>
62
#include <drizzled/function/time/microsecond.h>
63
#include <drizzled/function/time/minute.h>
64
#include <drizzled/function/time/month.h>
65
#include <drizzled/function/time/now.h>
66
#include <drizzled/function/time/quarter.h>
67
#include <drizzled/function/time/second.h>
68
#include <drizzled/function/time/sysdate_local.h>
69
#include <drizzled/function/time/timestamp_diff.h>
70
#include <drizzled/function/time/typecast.h>
71
#include <drizzled/function/time/year.h>
73
#include <drizzled/error.h>
74
#include <drizzled/nested_join.h>
75
#include <drizzled/sql_parse.h>
76
#include <drizzled/item/copy_string.h>
77
#include <drizzled/item/cmpfunc.h>
78
#include <drizzled/item/uint.h>
79
#include <drizzled/item/null.h>
80
#include <drizzled/session.h>
81
#include <drizzled/item/func.h>
82
#include <drizzled/sql_base.h>
83
#include <drizzled/item/create.h>
84
#include <drizzled/item/default_value.h>
85
#include <drizzled/item/insert_value.h>
86
#include <drizzled/lex_string.h>
87
#include <drizzled/function/get_system_var.h>
88
#include <mysys/thr_lock.h>
89
#include <drizzled/message/table.pb.h>
90
#include <drizzled/statement.h>
91
#include <drizzled/statement/alter_schema.h>
92
#include <drizzled/statement/alter_table.h>
93
#include <drizzled/statement/analyze.h>
94
#include <drizzled/statement/change_schema.h>
95
#include <drizzled/statement/check.h>
96
#include <drizzled/statement/checksum.h>
97
#include <drizzled/statement/commit.h>
98
#include <drizzled/statement/create_index.h>
99
#include <drizzled/statement/create_schema.h>
100
#include <drizzled/statement/create_table.h>
101
#include <drizzled/statement/delete.h>
102
#include <drizzled/statement/drop_index.h>
103
#include <drizzled/statement/drop_schema.h>
104
#include <drizzled/statement/drop_table.h>
105
#include <drizzled/statement/empty_query.h>
106
#include <drizzled/statement/flush.h>
107
#include <drizzled/statement/insert.h>
108
#include <drizzled/statement/insert_select.h>
109
#include <drizzled/statement/kill.h>
110
#include <drizzled/statement/load.h>
111
#include <drizzled/statement/optimize.h>
112
#include <drizzled/statement/release_savepoint.h>
113
#include <drizzled/statement/rename_table.h>
114
#include <drizzled/statement/replace.h>
115
#include <drizzled/statement/replace_select.h>
116
#include <drizzled/statement/rollback.h>
117
#include <drizzled/statement/rollback_to_savepoint.h>
118
#include <drizzled/statement/savepoint.h>
119
#include <drizzled/statement/select.h>
120
#include <drizzled/statement/set_option.h>
121
#include <drizzled/statement/show_create.h>
122
#include <drizzled/statement/show_create_schema.h>
123
#include <drizzled/statement/show_engine_status.h>
124
#include <drizzled/statement/show_errors.h>
125
#include <drizzled/statement/show_processlist.h>
126
#include <drizzled/statement/show_status.h>
127
#include <drizzled/statement/show_warnings.h>
128
#include <drizzled/statement/start_transaction.h>
129
#include <drizzled/statement/truncate.h>
130
#include <drizzled/statement/unlock_tables.h>
131
#include <drizzled/statement/update.h>
133
using namespace drizzled;
43
139
int yylex(void *yylval, void *yysession);
45
141
#define yyoverflow(A,B,C,D,E,F) \
47
143
ulong val= *(F); \
48
if (drizzled::my_yyoverflow((B), (D), &val)) \
144
if (my_yyoverflow((B), (D), &val)) \
50
146
yyerror((char*) (A)); \
304
static Item* reserved_keyword_function(const std::string &name, List<Item> *item_list)
306
const plugin::Function *udf= plugin::Function::get(name.c_str(), name.length());
311
item= Create_udf_func::s_singleton.create(current_session, udf, item_list);
313
my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", name.c_str());
319
} /* namespace drizzled; */
321
using namespace drizzled;
326
387
uint64_t ulonglong_number;
327
388
int64_t longlong_number;
328
drizzled::LEX_STRING lex_str;
329
drizzled::LEX_STRING *lex_str_ptr;
330
drizzled::LEX_SYMBOL symbol;
331
drizzled::Table_ident *table;
390
LEX_STRING *lex_str_ptr;
332
393
char *simple_string;
333
drizzled::Item *item;
334
drizzled::Item_num *item_num;
335
drizzled::List<drizzled::Item> *item_list;
336
drizzled::List<drizzled::String> *string_list;
337
drizzled::String *string;
338
drizzled::Key_part_spec *key_part;
339
const drizzled::plugin::Function *udf;
340
drizzled::TableList *table_list;
341
struct drizzled::sys_var_with_base variable;
342
enum drizzled::sql_var_t var_type;
343
drizzled::Key::Keytype key_type;
344
enum drizzled::ha_key_alg key_alg;
345
enum drizzled::row_type row_type;
346
enum drizzled::column_format_type column_format_type;
347
enum drizzled::ha_rkey_function ha_rkey_mode;
348
enum drizzled::enum_tx_isolation tx_isolation;
349
enum drizzled::Cast_target cast_type;
350
const drizzled::CHARSET_INFO *charset;
351
drizzled::thr_lock_type lock_type;
352
drizzled::interval_type interval, interval_time_st;
353
enum drizzled::enum_drizzle_timestamp_type date_time_type;
354
drizzled::Select_Lex *select_lex;
355
drizzled::chooser_compare_func_creator boolfunc2creator;
356
struct drizzled::st_lex *lex;
357
enum drizzled::index_hint_type index_hint;
358
enum drizzled::enum_filetype filetype;
359
enum drizzled::ha_build_method build_method;
360
enum drizzled::Foreign_key::fk_option m_fk_option;
396
List<Item> *item_list;
397
List<String> *string_list;
399
Key_part_spec *key_part;
400
const ::drizzled::plugin::Function *udf;
401
TableList *table_list;
402
struct sys_var_with_base variable;
403
enum enum_var_type var_type;
404
Key::Keytype key_type;
405
enum ha_key_alg key_alg;
406
StorageEngine *db_type;
407
enum row_type row_type;
408
enum column_format_type column_format_type;
409
enum ha_rkey_function ha_rkey_mode;
410
enum enum_tx_isolation tx_isolation;
411
enum Cast_target cast_type;
412
const CHARSET_INFO *charset;
413
thr_lock_type lock_type;
414
interval_type interval, interval_time_st;
415
enum enum_drizzle_timestamp_type date_time_type;
416
Select_Lex *select_lex;
417
chooser_compare_func_creator boolfunc2creator;
419
struct p_elem_val *p_elem_value;
420
enum index_hint_type index_hint;
421
enum enum_filetype filetype;
422
enum ha_build_method build_method;
423
enum Foreign_key::fk_option m_fk_option;
366
427
bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
370
430
%pure_parser /* We have threads */
1022
1148
Session *session= YYSession;
1023
1149
LEX *lex= session->lex;
1024
1150
lex->sql_command= SQLCOM_CREATE_TABLE;
1025
statement::CreateTable *statement= new(std::nothrow) statement::CreateTable(YYSession);
1026
lex->statement= statement;
1151
lex->statement= new(std::nothrow) statement::CreateTable(YYSession);
1027
1152
if (lex->statement == NULL)
1028
1153
DRIZZLE_YYABORT;
1029
1154
if (!lex->select_lex.add_table_to_list(session, $5, NULL,
1030
1155
TL_OPTION_UPDATING,
1032
1157
DRIZZLE_YYABORT;
1158
lex->alter_info.reset();
1033
1159
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;
1161
memset(&lex->create_info, 0, sizeof(lex->create_info));
1162
lex->create_info.options=$2 | $4;
1163
lex->create_info.db_type= ha_default_storage_engine(session);
1164
lex->create_info.default_table_charset= NULL;
1038
1165
lex->name.str= 0;
1040
message::Table &proto= statement->create_table_message;
1042
proto.set_name($5->table.str);
1044
proto.set_type(message::Table::TEMPORARY);
1167
message::Table *proto=
1168
lex->create_table_proto= new(std::nothrow) message::Table();
1170
if (lex->create_table_proto == NULL)
1173
proto->set_name($5->table.str);
1174
if($2 & HA_LEX_CREATE_TMP_TABLE)
1175
proto->set_type(message::Table::TEMPORARY);
1046
proto.set_type(message::Table::STANDARD);
1177
proto->set_type(message::Table::STANDARD);
1180
message::Table::StorageEngine *protoengine;
1181
protoengine= proto->mutable_engine();
1182
StorageEngine *engine= ha_default_storage_engine(session);
1184
protoengine->set_name(engine->getName());
1050
1189
LEX *lex= YYSession->lex;
1051
lex->current_select= &lex->select_lex;
1190
lex->current_select= &lex->select_lex;
1191
assert(lex->create_info.db_type);
1053
| CREATE build_method
1193
| CREATE build_method opt_unique INDEX_SYM ident key_alg
1056
1197
lex->sql_command= SQLCOM_CREATE_INDEX;
1057
statement::CreateIndex *statement= new(std::nothrow) statement::CreateIndex(YYSession);
1058
lex->statement= statement;
1198
lex->statement= new(std::nothrow)
1199
statement::CreateIndex(YYSession);
1059
1200
if (lex->statement == NULL)
1060
1201
DRIZZLE_YYABORT;
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;
1066
opt_unique INDEX_SYM ident key_alg ON table_ident '(' key_list ')' key_options
1069
statement::CreateIndex *statement= (statement::CreateIndex *)Lex->statement;
1071
if (!lex->current_select->add_table_to_list(lex->session, $9,
1202
if (!lex->current_select->add_table_to_list(lex->session, $8,
1073
1204
TL_OPTION_UPDATING))
1074
1205
DRIZZLE_YYABORT;
1206
lex->alter_info.reset();
1207
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1208
lex->alter_info.build_method= $2;
1209
lex->col_list.empty();
1212
lex->create_table_proto= new message::Table();
1214
'(' key_list ')' key_options
1076
key= new Key($4, $6, &statement->key_create_info, 0, lex->col_list);
1077
statement->alter_info.key_list.push_back(key);
1218
key= new Key($3, $5, &lex->key_create_info, 0,
1220
lex->alter_info.key_list.push_back(key);
1078
1221
lex->col_list.empty();
1080
1223
| CREATE DATABASE opt_if_not_exists ident
1225
Lex->create_info.default_table_charset= NULL;
1226
Lex->create_info.used_fields= 0;
1228
opt_create_database_options
1084
1231
lex->sql_command=SQLCOM_CREATE_DB;
1085
statement::CreateSchema *statement= new(std::nothrow) statement::CreateSchema(YYSession);
1086
lex->statement= statement;
1232
lex->statement= new(std::nothrow) statement::CreateSchema(YYSession);
1087
1233
if (lex->statement == NULL)
1088
1234
DRIZZLE_YYABORT;
1089
statement->is_if_not_exists= $3;
1091
opt_create_database_options
1236
lex->create_info.options=$3;
1222
1379
create_table_option:
1223
ENGINE_SYM opt_equal ident_or_text
1380
ENGINE_SYM opt_equal storage_engines
1225
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1226
message::Table::StorageEngine *protoengine;
1227
protoengine= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_engine();
1229
statement->is_engine_set= true;
1231
protoengine->set_name($3.str);
1382
Lex->create_info.db_type= $3;
1383
Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE;
1386
message::Table::StorageEngine *protoengine;
1387
protoengine= Lex->create_table_proto->mutable_engine();
1389
protoengine->set_name($3->getName());
1233
| BLOCK_SIZE_SYM opt_equal ulong_num
1235
message::Table::TableOptions *tableopts;
1236
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1237
tableopts= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_options();
1239
tableopts->set_block_size($3);
1240
statement->create_info.used_fields|= HA_CREATE_USED_BLOCK_SIZE;
1392
| BLOCK_SIZE_SYM opt_equal ulong_num
1394
Lex->create_info.block_size= $3;
1395
Lex->create_info.used_fields|= HA_CREATE_USED_BLOCK_SIZE;
1242
1397
| COMMENT_SYM opt_equal TEXT_STRING_sys
1244
1399
message::Table::TableOptions *tableopts;
1245
tableopts= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_options();
1400
tableopts= Lex->create_table_proto->mutable_options();
1247
1402
tableopts->set_comment($3.str);
1249
1404
| AUTO_INC opt_equal ulonglong_num
1251
message::Table::TableOptions *tableopts;
1252
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1254
tableopts= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_options();
1256
statement->create_info.auto_increment_value=$3;
1257
statement->create_info.used_fields|= HA_CREATE_USED_AUTO;
1258
tableopts->set_auto_increment_value($3);
1406
Lex->create_info.auto_increment_value=$3;
1407
Lex->create_info.used_fields|= HA_CREATE_USED_AUTO;
1260
1409
| ROW_FORMAT_SYM opt_equal row_types
1262
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1263
message::Table::TableOptions *table_options= statement->createTableMessage().mutable_options();
1265
statement->create_info.row_type= $3;
1266
statement->create_info.used_fields|= HA_CREATE_USED_ROW_FORMAT;
1267
statement->alter_info.flags.set(ALTER_ROW_FORMAT);
1269
switch(statement->create_info.row_type)
1271
case ROW_TYPE_DEFAULT:
1272
/* No use setting a default row type... just adds redundant info to message */
1274
case ROW_TYPE_FIXED:
1275
table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_FIXED);
1277
case ROW_TYPE_DYNAMIC:
1278
table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_DYNAMIC);
1280
case ROW_TYPE_COMPRESSED:
1281
table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_COMPRESSED);
1283
case ROW_TYPE_REDUNDANT:
1284
table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_REDUNDANT);
1286
case ROW_TYPE_COMPACT:
1287
table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_COMPACT);
1290
table_options->set_row_type(message::Table::TableOptions::ROW_TYPE_PAGE);
1411
Lex->create_info.row_type= $3;
1412
Lex->create_info.used_fields|= HA_CREATE_USED_ROW_FORMAT;
1413
Lex->alter_info.flags.set(ALTER_ROW_FORMAT);
1296
1415
| default_collation
1297
1416
| KEY_BLOCK_SIZE opt_equal ulong_num
1299
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1301
statement->create_info.used_fields|= HA_CREATE_USED_KEY_BLOCK_SIZE;
1303
message::Table::TableOptions *tableopts;
1304
tableopts= ((statement::CreateTable *)Lex->statement)->create_table_message.mutable_options();
1305
tableopts->set_key_block_size($3);
1418
Lex->create_info.used_fields|= HA_CREATE_USED_KEY_BLOCK_SIZE;
1419
Lex->create_info.key_block_size= $3;
1309
1423
default_collation:
1310
1424
opt_default COLLATE_SYM opt_equal collation_name_or_default
1312
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1314
HA_CREATE_INFO *cinfo= &statement->create_info;
1426
HA_CREATE_INFO *cinfo= &Lex->create_info;
1315
1427
if ((cinfo->used_fields & HA_CREATE_USED_DEFAULT_CHARSET) &&
1316
1428
cinfo->default_table_charset && $4 &&
1317
1429
!my_charset_same(cinfo->default_table_charset,$4))
1377
1510
key_type opt_ident key_alg '(' key_list ')' key_options
1380
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1381
Key *key= new Key($1, $2, &statement->key_create_info, 0,
1513
Key *key= new Key($1, $2, &lex->key_create_info, 0,
1382
1514
lex->col_list);
1383
statement->alter_info.key_list.push_back(key);
1384
lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1515
lex->alter_info.key_list.push_back(key);
1516
lex->col_list.empty(); /* Alloced by sql_alloc */
1386
1518
| opt_constraint constraint_key_type opt_ident key_alg
1387
1519
'(' key_list ')' key_options
1390
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1391
Key *key= new Key($2, $3.str ? $3 : $1, &statement->key_create_info, 0,
1522
Key *key= new Key($2, $3.str ? $3 : $1, &lex->key_create_info, 0,
1392
1523
lex->col_list);
1393
statement->alter_info.key_list.push_back(key);
1394
lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1524
lex->alter_info.key_list.push_back(key);
1525
lex->col_list.empty(); /* Alloced by sql_alloc */
1396
1527
| opt_constraint FOREIGN KEY_SYM opt_ident '(' key_list ')' references
1399
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1400
1530
Key *key= new Foreign_key($4.str ? $4 : $1, lex->col_list,
1403
statement->fk_delete_opt,
1404
statement->fk_update_opt,
1405
statement->fk_match_option);
1406
statement->alter_info.key_list.push_back(key);
1535
lex->fk_match_option);
1536
lex->alter_info.key_list.push_back(key);
1407
1537
key= new Key(Key::MULTIPLE, $1.str ? $1 : $4,
1408
1538
&default_key_create_info, 1,
1409
1539
lex->col_list);
1410
statement->alter_info.key_list.push_back(key);
1411
lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1540
lex->alter_info.key_list.push_back(key);
1541
lex->col_list.empty(); /* Alloced by sql_alloc */
1412
1542
/* Only used for ALTER TABLE. Ignored otherwise. */
1413
statement->alter_info.flags.set(ALTER_FOREIGN_KEY);
1543
lex->alter_info.flags.set(ALTER_FOREIGN_KEY);
1415
1545
| constraint opt_check_constraint
1417
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1547
Lex->col_list.empty(); /* Alloced by sql_alloc */
1419
1549
| opt_constraint check_constraint
1421
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1551
Lex->col_list.empty(); /* Alloced by sql_alloc */
1486
1604
Lex->length=(char*) 0; /* use default length */
1487
statement::CreateTable *statement=
1488
(statement::CreateTable *)Lex->statement;
1490
if (statement->current_proto_field)
1492
if ($1 == DRIZZLE_TYPE_LONG)
1493
statement->current_proto_field->set_type(message::Table::Field::INTEGER);
1494
else if ($1 == DRIZZLE_TYPE_LONGLONG)
1495
statement->current_proto_field->set_type(message::Table::Field::BIGINT);
1500
| real_type opt_precision
1504
statement::CreateTable *statement=
1505
(statement::CreateTable *)Lex->statement;
1507
if (statement->current_proto_field)
1509
assert ($1 == DRIZZLE_TYPE_DOUBLE);
1510
statement->current_proto_field->set_type(message::Table::Field::DOUBLE);
1516
$$=DRIZZLE_TYPE_VARCHAR;
1518
statement::CreateTable *statement=
1519
(statement::CreateTable *)Lex->statement;
1521
if (statement->current_proto_field)
1523
statement->current_proto_field->set_type(message::Table::Field::VARCHAR);
1524
message::Table::Field::StringFieldOptions *string_field_options;
1526
string_field_options= statement->current_proto_field->mutable_string_options();
1528
string_field_options->set_length(atoi($3.str));
1533
Lex->length=(char*) "1";
1534
$$=DRIZZLE_TYPE_VARCHAR;
1536
statement::CreateTable *statement=
1537
(statement::CreateTable *)Lex->statement;
1539
if (statement->current_proto_field)
1540
statement->current_proto_field->set_type(message::Table::Field::VARCHAR);
1542
| varchar '(' NUM ')'
1545
$$= DRIZZLE_TYPE_VARCHAR;
1547
statement::CreateTable *statement=
1548
(statement::CreateTable *)Lex->statement;
1550
if (statement->current_proto_field)
1552
statement->current_proto_field->set_type(message::Table::Field::VARCHAR);
1554
message::Table::Field::StringFieldOptions *string_field_options;
1556
string_field_options= statement->current_proto_field->mutable_string_options();
1558
string_field_options->set_length(atoi($3.str));
1561
| VARBINARY '(' NUM ')'
1564
Lex->charset=&my_charset_bin;
1565
$$= DRIZZLE_TYPE_VARCHAR;
1567
statement::CreateTable *statement=
1568
(statement::CreateTable *)Lex->statement;
1570
if (statement->current_proto_field)
1572
statement->current_proto_field->set_type(message::Table::Field::VARCHAR);
1573
message::Table::Field::StringFieldOptions *string_field_options;
1575
string_field_options= statement->current_proto_field->mutable_string_options();
1577
string_field_options->set_length(atoi($3.str));
1578
string_field_options->set_collation_id(my_charset_bin.number);
1579
string_field_options->set_collation(my_charset_bin.name);
1584
$$=DRIZZLE_TYPE_DATE;
1586
statement::CreateTable *statement=
1587
(statement::CreateTable *)Lex->statement;
1589
if (statement->current_proto_field)
1590
statement->current_proto_field->set_type(message::Table::Field::DATE);
1594
$$=DRIZZLE_TYPE_TIMESTAMP;
1596
statement::CreateTable *statement=
1597
(statement::CreateTable *)Lex->statement;
1599
if (statement->current_proto_field)
1600
statement->current_proto_field->set_type(message::Table::Field::TIMESTAMP);
1604
$$=DRIZZLE_TYPE_DATETIME;
1606
statement::CreateTable *statement=
1607
(statement::CreateTable *)Lex->statement;
1609
if (statement->current_proto_field)
1610
statement->current_proto_field->set_type(message::Table::Field::DATETIME);
1614
Lex->charset=&my_charset_bin;
1615
$$=DRIZZLE_TYPE_BLOB;
1616
Lex->length=(char*) 0; /* use default length */
1618
statement::CreateTable *statement=
1619
(statement::CreateTable *)Lex->statement;
1621
if (statement->current_proto_field)
1623
statement->current_proto_field->set_type(message::Table::Field::BLOB);
1624
message::Table::Field::StringFieldOptions *string_field_options;
1626
string_field_options= statement->current_proto_field->mutable_string_options();
1627
string_field_options->set_collation_id(my_charset_bin.number);
1628
string_field_options->set_collation(my_charset_bin.name);
1633
$$=DRIZZLE_TYPE_BLOB;
1634
Lex->length=(char*) 0; /* use default length */
1636
statement::CreateTable *statement=
1637
(statement::CreateTable *)Lex->statement;
1639
if (statement->current_proto_field)
1640
statement->current_proto_field->set_type(message::Table::Field::BLOB);
1642
| DECIMAL_SYM float_options
1644
$$=DRIZZLE_TYPE_DECIMAL;
1646
statement::CreateTable *statement=
1647
(statement::CreateTable *)Lex->statement;
1649
if (statement->current_proto_field)
1650
statement->current_proto_field->set_type(message::Table::Field::DECIMAL);
1652
| NUMERIC_SYM float_options
1654
$$=DRIZZLE_TYPE_DECIMAL;
1656
statement::CreateTable *statement=
1657
(statement::CreateTable *)Lex->statement;
1659
if (statement->current_proto_field)
1660
statement->current_proto_field->set_type(message::Table::Field::DECIMAL);
1662
| FIXED_SYM float_options
1664
$$=DRIZZLE_TYPE_DECIMAL;
1666
statement::CreateTable *statement=
1667
(statement::CreateTable *)Lex->statement;
1669
if (statement->current_proto_field)
1670
statement->current_proto_field->set_type(message::Table::Field::DECIMAL);
1673
{Lex->interval_list.empty();}
1676
$$=DRIZZLE_TYPE_ENUM;
1678
statement::CreateTable *statement=
1679
(statement::CreateTable *)Lex->statement;
1681
if (statement->current_proto_field)
1682
statement->current_proto_field->set_type(message::Table::Field::ENUM);
1606
| real_type opt_precision { $$=$1; }
1607
| char '(' NUM ')' opt_binary
1610
$$=DRIZZLE_TYPE_VARCHAR;
1614
Lex->length=(char*) "1";
1615
$$=DRIZZLE_TYPE_VARCHAR;
1617
| varchar '(' NUM ')' opt_binary
1620
$$= DRIZZLE_TYPE_VARCHAR;
1622
| VARBINARY '(' NUM ')'
1625
Lex->charset=&my_charset_bin;
1626
$$= DRIZZLE_TYPE_VARCHAR;
1629
{ $$=DRIZZLE_TYPE_DATE; }
1631
{ $$=DRIZZLE_TYPE_TIMESTAMP; }
1633
{ $$=DRIZZLE_TYPE_DATETIME; }
1636
Lex->charset=&my_charset_bin;
1637
$$=DRIZZLE_TYPE_BLOB;
1638
Lex->length=(char*) 0; /* use default length */
1640
| TEXT_SYM opt_binary
1642
$$=DRIZZLE_TYPE_BLOB;
1643
Lex->length=(char*) 0; /* use default length */
1645
| DECIMAL_SYM float_options
1646
{ $$=DRIZZLE_TYPE_NEWDECIMAL;}
1647
| NUMERIC_SYM float_options
1648
{ $$=DRIZZLE_TYPE_NEWDECIMAL;}
1649
| FIXED_SYM float_options
1650
{ $$=DRIZZLE_TYPE_NEWDECIMAL;}
1652
{Lex->interval_list.empty();}
1653
'(' string_list ')' opt_binary
1654
{ $$=DRIZZLE_TYPE_ENUM; }
1686
1657
$$=DRIZZLE_TYPE_LONGLONG;
1687
1658
Lex->type|= (AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_FLAG);
1689
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1690
if (statement->current_proto_field)
1692
message::Table::Field::FieldConstraints *constraints;
1693
constraints= statement->current_proto_field->mutable_constraints();
1694
constraints->set_is_nullable(false);
1696
statement->current_proto_field->set_type(message::Table::Field::BIGINT);
1767
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1768
Lex->type&= ~ NOT_NULL_FLAG;
1770
if (statement->current_proto_field)
1772
message::Table::Field::FieldConstraints *constraints;
1773
constraints= statement->current_proto_field->mutable_constraints();
1774
constraints->set_is_nullable(true);
1726
NULL_SYM { Lex->type&= ~ NOT_NULL_FLAG; }
1777
1727
| COLUMN_FORMAT_SYM column_format_types
1779
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1781
statement->column_format= $2;
1782
statement->alter_info.flags.set(ALTER_COLUMN_FORMAT);
1786
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1787
Lex->type|= NOT_NULL_FLAG;
1789
if (statement->current_proto_field)
1791
message::Table::Field::FieldConstraints *constraints;
1792
constraints= statement->current_proto_field->mutable_constraints();
1793
constraints->set_is_nullable(false);
1796
| DEFAULT now_or_signed_literal
1798
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1800
statement->default_value=$2;
1801
statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1803
| ON UPDATE_SYM NOW_SYM optional_braces
1804
{ ((statement::AlterTable *)Lex->statement)->on_update_value= new Item_func_now_local(); }
1807
Lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG;
1809
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1810
if (statement->current_proto_field)
1812
message::Table::Field::FieldConstraints *constraints;
1814
constraints= statement->current_proto_field->mutable_constraints();
1815
constraints->set_is_nullable(false);
1729
Lex->column_format= $2;
1730
Lex->alter_info.flags.set(ALTER_COLUMN_FORMAT);
1732
| not NULL_SYM { Lex->type|= NOT_NULL_FLAG; }
1733
| DEFAULT now_or_signed_literal
1735
Lex->default_value=$2;
1736
Lex->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1738
| ON UPDATE_SYM NOW_SYM optional_braces
1739
{ Lex->on_update_value= new Item_func_now_local(); }
1740
| AUTO_INC { Lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG; }
1818
1741
| SERIAL_SYM DEFAULT VALUE_SYM
1821
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1823
1744
lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_FLAG;
1824
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1826
if (statement->current_proto_field)
1828
message::Table::Field::FieldConstraints *constraints;
1829
constraints= statement->current_proto_field->mutable_constraints();
1830
constraints->set_is_nullable(false);
1745
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1833
1747
| opt_primary KEY_SYM
1836
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1838
1750
lex->type|= PRI_KEY_FLAG | NOT_NULL_FLAG;
1839
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1841
if (statement->current_proto_field)
1843
message::Table::Field::FieldConstraints *constraints;
1844
constraints= statement->current_proto_field->mutable_constraints();
1845
constraints->set_is_nullable(false);
1751
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1851
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1853
lex->type|= UNIQUE_FLAG;
1854
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1756
lex->type|= UNIQUE_FLAG;
1757
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1856
1759
| UNIQUE_SYM KEY_SYM
1859
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1861
lex->type|= UNIQUE_KEY_FLAG;
1862
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1864
| COMMENT_SYM TEXT_STRING_sys
1866
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1867
statement->comment= $2;
1869
if (statement->current_proto_field)
1870
statement->current_proto_field->set_comment($2.str);
1762
lex->type|= UNIQUE_KEY_FLAG;
1763
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1765
| COMMENT_SYM TEXT_STRING_sys { Lex->comment= $2; }
1872
1766
| COLLATE_SYM collation_name
1874
1768
if (Lex->charset && !my_charset_same(Lex->charset,$2))
2202
2173
add_column column_def opt_place { }
2205
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2207
statement->alter_info.flags.set(ALTER_ADD_INDEX);
2176
Lex->alter_info.flags.set(ALTER_ADD_INDEX);
2209
2178
| add_column '(' field_list ')'
2211
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2213
statement->alter_info.flags.set(ALTER_ADD_COLUMN);
2214
statement->alter_info.flags.set(ALTER_ADD_INDEX);
2180
Lex->alter_info.flags.set(ALTER_ADD_COLUMN);
2181
Lex->alter_info.flags.set(ALTER_ADD_INDEX);
2216
2183
| CHANGE opt_column field_ident
2218
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2219
statement->change= $3.str;
2220
statement->alter_info.flags.set(ALTER_CHANGE_COLUMN);
2186
lex->change= $3.str;
2187
lex->alter_info.flags.set(ALTER_CHANGE_COLUMN);
2222
2189
field_spec opt_place
2223
2190
| MODIFY_SYM opt_column field_ident
2226
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2227
2193
lex->length=lex->dec=0; lex->type=0;
2228
statement->default_value= statement->on_update_value= 0;
2229
statement->comment= null_lex_str;
2194
lex->default_value= lex->on_update_value= 0;
2195
lex->comment=null_lex_str;
2230
2196
lex->charset= NULL;
2231
statement->alter_info.flags.set(ALTER_CHANGE_COLUMN);
2232
statement->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
2234
statement->current_proto_field= NULL;
2197
lex->alter_info.flags.set(ALTER_CHANGE_COLUMN);
2198
lex->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
2239
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2241
2203
if (add_field_to_list(lex->session,&$3,
2242
2204
(enum enum_field_types) $5,
2243
lex->length, lex->dec, lex->type,
2244
statement->column_format,
2245
statement->default_value,
2246
statement->on_update_value,
2247
&statement->comment,
2205
lex->length,lex->dec,lex->type,
2207
lex->default_value, lex->on_update_value,
2248
2209
$3.str, &lex->interval_list, lex->charset))
2249
2210
DRIZZLE_YYABORT;
2252
2213
| DROP opt_column field_ident
2254
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2256
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::COLUMN, $3.str));
2257
statement->alter_info.flags.set(ALTER_DROP_COLUMN);
2216
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::COLUMN,
2218
lex->alter_info.flags.set(ALTER_DROP_COLUMN);
2259
2220
| DROP FOREIGN KEY_SYM opt_ident
2261
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2263
statement->alter_info.flags.set(ALTER_DROP_INDEX);
2264
statement->alter_info.flags.set(ALTER_FOREIGN_KEY);
2222
Lex->alter_info.flags.set(ALTER_DROP_INDEX);
2223
Lex->alter_info.flags.set(ALTER_FOREIGN_KEY);
2266
2225
| DROP PRIMARY_SYM KEY_SYM
2268
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2270
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY,
2228
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::KEY,
2272
statement->alter_info.flags.set(ALTER_DROP_INDEX);
2230
lex->alter_info.flags.set(ALTER_DROP_INDEX);
2274
2232
| DROP key_or_index field_ident
2276
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2278
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY,
2280
statement->alter_info.flags.set(ALTER_DROP_INDEX);
2235
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::KEY,
2237
lex->alter_info.flags.set(ALTER_DROP_INDEX);
2282
2239
| DISABLE_SYM KEYS
2284
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2286
statement->alter_info.keys_onoff= DISABLE;
2287
statement->alter_info.flags.set(ALTER_KEYS_ONOFF);
2242
lex->alter_info.keys_onoff= DISABLE;
2243
lex->alter_info.flags.set(ALTER_KEYS_ONOFF);
2289
2245
| ENABLE_SYM KEYS
2291
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2293
statement->alter_info.keys_onoff= ENABLE;
2294
statement->alter_info.flags.set(ALTER_KEYS_ONOFF);
2248
lex->alter_info.keys_onoff= ENABLE;
2249
lex->alter_info.flags.set(ALTER_KEYS_ONOFF);
2296
2251
| ALTER opt_column field_ident SET DEFAULT signed_literal
2298
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2300
statement->alter_info.alter_list.push_back(new AlterColumn($3.str,$6));
2301
statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
2254
lex->alter_info.alter_list.push_back(new Alter_column($3.str,$6));
2255
lex->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
2303
2257
| ALTER opt_column field_ident DROP DEFAULT
2305
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2307
statement->alter_info.alter_list.push_back(new AlterColumn($3.str, (Item*) 0));
2308
statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
2260
lex->alter_info.alter_list.push_back(new Alter_column($3.str,
2262
lex->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
2310
2264
| RENAME opt_to table_ident
2313
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2316
2268
lex->select_lex.db=$3->db.str;
2317
2269
if (lex->select_lex.db == NULL &&
2318
2270
lex->copy_db_to(&lex->select_lex.db, &dummy))
2320
2272
DRIZZLE_YYABORT;
2323
if (check_table_name($3->table.str,$3->table.length))
2274
if (check_table_name($3->table.str,$3->table.length) || ($3->db.str && check_db_name(&$3->db)))
2325
2276
my_error(ER_WRONG_TABLE_NAME, MYF(0), $3->table.str);
2326
2277
DRIZZLE_YYABORT;
2329
2279
lex->name= $3->table;
2330
statement->alter_info.flags.set(ALTER_RENAME);
2280
lex->alter_info.flags.set(ALTER_RENAME);
2332
2282
| CONVERT_SYM TO_SYM collation_name_or_default
2334
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2336
statement->create_info.table_charset=
2337
statement->create_info.default_table_charset= $3;
2338
statement->create_info.used_fields|= (HA_CREATE_USED_CHARSET |
2285
lex->create_info.table_charset=
2286
lex->create_info.default_table_charset= $3;
2287
lex->create_info.used_fields|= (HA_CREATE_USED_CHARSET |
2339
2288
HA_CREATE_USED_DEFAULT_CHARSET);
2340
statement->alter_info.flags.set(ALTER_CONVERT);
2289
lex->alter_info.flags.set(ALTER_CONVERT);
2342
2291
| create_table_options_space_separated
2344
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2346
statement->alter_info.flags.set(ALTER_OPTIONS);
2294
lex->alter_info.flags.set(ALTER_OPTIONS);
2350
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2352
statement->alter_info.flags.set(ALTER_FORCE);
2298
Lex->alter_info.flags.set(ALTER_FORCE);
2354
2300
| alter_order_clause
2356
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2358
statement->alter_info.flags.set(ALTER_ORDER);
2303
lex->alter_info.flags.set(ALTER_ORDER);
4303
NUM { int error; $$= (ulong) internal::my_strtoll10($1.str, (char**) 0, &error); }
4242
NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4304
4243
| HEX_NUM { $$= (ulong) strtol($1.str, (char**) 0, 16); }
4305
| LONG_NUM { int error; $$= (ulong) internal::my_strtoll10($1.str, (char**) 0, &error); }
4306
| ULONGLONG_NUM { int error; $$= (ulong) internal::my_strtoll10($1.str, (char**) 0, &error); }
4307
| DECIMAL_NUM { int error; $$= (ulong) internal::my_strtoll10($1.str, (char**) 0, &error); }
4308
| FLOAT_NUM { int error; $$= (ulong) internal::my_strtoll10($1.str, (char**) 0, &error); }
4244
| LONG_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4245
| ULONGLONG_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4246
| DECIMAL_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4247
| FLOAT_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4251
NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4252
| HEX_NUM { $$= (ulong) strtol($1.str, (char**) 0, 16); }
4253
| LONG_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4254
| ULONGLONG_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4312
NUM { int error; $$= (uint64_t) internal::my_strtoll10($1.str, (char**) 0, &error); }
4313
| ULONGLONG_NUM { int error; $$= (uint64_t) internal::my_strtoll10($1.str, (char**) 0, &error); }
4314
| LONG_NUM { int error; $$= (uint64_t) internal::my_strtoll10($1.str, (char**) 0, &error); }
4315
| DECIMAL_NUM { int error; $$= (uint64_t) internal::my_strtoll10($1.str, (char**) 0, &error); }
4316
| FLOAT_NUM { int error; $$= (uint64_t) internal::my_strtoll10($1.str, (char**) 0, &error); }
4259
NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4260
| ULONGLONG_NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4261
| LONG_NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4262
| DECIMAL_NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4263
| FLOAT_NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4268
{ my_parse_error(ER(ER_ONLY_INTEGERS_ALLOWED)); }
4319
4276
select_var_list_init:
4742
4703
DATABASES show_wild
4745
Session *session= YYSession;
4747
lex->sql_command= SQLCOM_SELECT;
4749
new(std::nothrow) statement::Select(session);
4750
if (lex->statement == NULL)
4753
std::string column_name= "Database";
4756
column_name.append(" (");
4757
column_name.append(Lex->wild->ptr());
4758
column_name.append(")");
4761
if (Lex->current_select->where)
4763
if (prepare_new_schema_table(session, lex, "SCHEMAS"))
4768
if (prepare_new_schema_table(session, lex, "SHOW_SCHEMAS"))
4772
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "SCHEMA_NAME");
4773
my_field->is_autogenerated_name= false;
4774
my_field->set_name(column_name.c_str(), column_name.length(), system_charset_info);
4776
if (session->add_item_to_list(my_field))
4779
| TABLES opt_db show_wild
4782
Session *session= YYSession;
4784
lex->sql_command= SQLCOM_SELECT;
4786
statement::Select *select=
4787
new(std::nothrow) statement::Select(YYSession);
4789
lex->statement= select;
4791
if (lex->statement == NULL)
4795
std::string column_name= "Tables_in_";
4799
SchemaIdentifier identifier($2);
4800
column_name.append($2);
4801
lex->select_lex.db= $2;
4802
if (not plugin::StorageEngine::doesSchemaExist(identifier))
4804
my_error(ER_BAD_DB_ERROR, MYF(0), $2);
4806
select->setShowPredicate($2, "");
4808
else if (not session->db.empty())
4810
column_name.append(session->db);
4811
select->setShowPredicate(session->db, "");
4815
my_error(ER_NO_DB_ERROR, MYF(0));
4821
column_name.append(" (");
4822
column_name.append(Lex->wild->ptr());
4823
column_name.append(")");
4826
if (prepare_new_schema_table(YYSession, lex, "SHOW_TABLES"))
4829
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "TABLE_NAME");
4830
my_field->is_autogenerated_name= false;
4831
my_field->set_name(column_name.c_str(), column_name.length(), system_charset_info);
4833
if (session->add_item_to_list(my_field))
4836
| TEMPORARY_SYM TABLES show_wild
4839
Session *session= YYSession;
4841
lex->sql_command= SQLCOM_SELECT;
4843
statement::Select *select=
4844
new(std::nothrow) statement::Select(YYSession);
4846
lex->statement= select;
4848
if (lex->statement == NULL)
4852
if (prepare_new_schema_table(YYSession, lex, "SHOW_TEMPORARY_TABLES"))
4855
if (session->add_item_to_list( new Item_field(&session->lex->current_select->
4859
(session->lex->current_select->with_wild)++;
4706
lex->sql_command= SQLCOM_SHOW_DATABASES;
4708
new(std::nothrow) statement::Select(SQLCOM_SHOW_DATABASES,
4710
if (lex->statement == NULL)
4712
if (prepare_schema_table(YYSession, lex, 0, "SCHEMATA"))
4715
| opt_full TABLES opt_db show_wild
4718
lex->sql_command= SQLCOM_SHOW_TABLES;
4720
new(std::nothrow) statement::Select(SQLCOM_SHOW_TABLES,
4722
if (lex->statement == NULL)
4724
lex->select_lex.db= $3;
4725
if (prepare_schema_table(YYSession, lex, 0, "TABLE_NAMES"))
4862
4728
| TABLE_SYM STATUS_SYM opt_db show_wild
4865
lex->sql_command= SQLCOM_SELECT;
4866
statement::Select *select=
4867
new(std::nothrow) statement::Select(YYSession);
4869
lex->statement= select;
4731
lex->sql_command= SQLCOM_SHOW_TABLE_STATUS;
4733
new(std::nothrow) statement::Select(SQLCOM_SHOW_TABLE_STATUS,
4871
4735
if (lex->statement == NULL)
4872
4736
DRIZZLE_YYABORT;
4874
Session *session= YYSession;
4876
std::string column_name= "Tables_in_";
4880
lex->select_lex.db= $3;
4882
SchemaIdentifier identifier($3);
4883
if (not plugin::StorageEngine::doesSchemaExist(identifier))
4885
my_error(ER_BAD_DB_ERROR, MYF(0), $3);
4888
select->setShowPredicate($3, "");
4892
select->setShowPredicate(session->db, "");
4895
if (prepare_new_schema_table(session, lex, "SHOW_TABLE_STATUS"))
4898
if (session->add_item_to_list( new Item_field(&session->lex->current_select->
4902
(session->lex->current_select->with_wild)++;
4737
lex->select_lex.db= $3;
4738
if (prepare_schema_table(YYSession, lex, 0, "TABLES"))
4904
| COLUMNS from_or_in table_ident opt_db show_wild
4907
Session *session= YYSession;
4908
statement::Select *select;
4910
lex->sql_command= SQLCOM_SELECT;
4912
select= new(std::nothrow) statement::Select(session);
4914
lex->statement= select;
4916
if (lex->statement == NULL)
4920
select->setShowPredicate($4, $3->table.str);
4921
else if ($3->db.str)
4922
select->setShowPredicate($3->db.str, $3->table.str);
4924
select->setShowPredicate(session->db, $3->table.str);
4927
drizzled::TableIdentifier identifier(select->getShowSchema().c_str(), $3->table.str);
4928
if (not plugin::StorageEngine::doesTableExist(*session, identifier))
4930
my_error(ER_NO_SUCH_TABLE, MYF(0),
4931
select->getShowSchema().c_str(),
4936
if (prepare_new_schema_table(session, lex, "SHOW_COLUMNS"))
4939
if (session->add_item_to_list( new Item_field(&session->lex->current_select->
4943
(session->lex->current_select->with_wild)++;
4741
| OPEN_SYM TABLES opt_db show_wild
4744
lex->sql_command= SQLCOM_SHOW_OPEN_TABLES;
4746
new(std::nothrow) statement::Select(SQLCOM_SHOW_OPEN_TABLES,
4748
if (lex->statement == NULL)
4750
lex->select_lex.db= $3;
4751
if (prepare_schema_table(YYSession, lex, 0, "OPEN_TABLES"))
4754
| ENGINE_SYM known_storage_engines STATUS_SYM /* This should either go... well it should go */
4756
Lex->show_engine= $2;
4757
Lex->sql_command= SQLCOM_SHOW_ENGINE_STATUS;
4759
new(std::nothrow) statement::ShowEngineStatus(YYSession);
4760
if (Lex->statement == NULL)
4763
| opt_full COLUMNS from_or_in table_ident opt_db show_wild
4766
lex->sql_command= SQLCOM_SHOW_FIELDS;
4768
new(std::nothrow) statement::Select(SQLCOM_SHOW_FIELDS, YYSession);
4769
if (lex->statement == NULL)
4773
if (prepare_schema_table(YYSession, lex, $4, "COLUMNS"))
4946
4776
| keys_or_index from_or_in table_ident opt_db where_clause
4949
Session *session= YYSession;
4950
statement::Select *select;
4952
lex->sql_command= SQLCOM_SELECT;
4954
select= new(std::nothrow) statement::Select(session);
4956
lex->statement= select;
4958
if (lex->statement == NULL)
4962
select->setShowPredicate($4, $3->table.str);
4963
else if ($3->db.str)
4964
select->setShowPredicate($3->db.str, $3->table.str);
4966
select->setShowPredicate(session->db, $3->table.str);
4969
drizzled::TableIdentifier identifier(select->getShowSchema().c_str(), $3->table.str);
4970
if (not plugin::StorageEngine::doesTableExist(*session, identifier))
4972
my_error(ER_NO_SUCH_TABLE, MYF(0),
4973
select->getShowSchema().c_str(),
4978
if (prepare_new_schema_table(session, lex, "SHOW_INDEXES"))
4981
if (session->add_item_to_list( new Item_field(&session->lex->current_select->
4985
(session->lex->current_select->with_wild)++;
4779
lex->sql_command= SQLCOM_SHOW_KEYS;
4780
lex->statement= new(std::nothrow) statement::Select(SQLCOM_SHOW_KEYS,
4782
if (lex->statement == NULL)
4786
if (prepare_schema_table(YYSession, lex, $3, "STATISTICS"))
4987
4789
| COUNT_SYM '(' '*' ')' WARNINGS
4989
(void) create_select_for_variable("warning_count");
4791
(void) create_select_for_variable("warning_count");
4991
lex->statement= new(std::nothrow) statement::Select(YYSession);
4793
lex->statement= new(std::nothrow) statement::Select(SQLCOM_SELECT,
4992
4795
if (lex->statement == NULL)
4993
4796
DRIZZLE_YYABORT;
4995
4798
| COUNT_SYM '(' '*' ')' ERRORS
4997
(void) create_select_for_variable("error_count");
4800
(void) create_select_for_variable("error_count");
4999
lex->statement= new(std::nothrow) statement::Select(YYSession);
4802
lex->statement= new(std::nothrow) statement::Select(SQLCOM_SELECT,
5000
4804
if (lex->statement == NULL)
5001
4805
DRIZZLE_YYABORT;
5003
4807
| WARNINGS opt_limit_clause_init
5005
4809
Lex->sql_command = SQLCOM_SHOW_WARNS;
5006
4810
Lex->statement= new(std::nothrow) statement::ShowWarnings(YYSession);
5007
4811
if (Lex->statement == NULL)
5008
4812
DRIZZLE_YYABORT;
5010
4814
| ERRORS opt_limit_clause_init
5012
4816
Lex->sql_command = SQLCOM_SHOW_ERRORS;
5013
4817
Lex->statement= new(std::nothrow) statement::ShowErrors(YYSession);
5014
4818
if (Lex->statement == NULL)
5015
4819
DRIZZLE_YYABORT;
5017
4821
| opt_var_type STATUS_SYM show_wild
5020
lex->sql_command= SQLCOM_SELECT;
5022
new(std::nothrow) statement::Select(YYSession);
5023
if (lex->statement == NULL)
5026
Session *session= YYSession;
5028
if ($1 == OPT_GLOBAL)
5030
if (prepare_new_schema_table(session, lex, "GLOBAL_STATUS"))
5035
if (prepare_new_schema_table(session, lex, "SESSION_STATUS"))
5039
std::string key("Variable_name");
5040
std::string value("Value");
5042
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "VARIABLE_NAME");
5043
my_field->is_autogenerated_name= false;
5044
my_field->set_name(key.c_str(), key.length(), system_charset_info);
5046
if (session->add_item_to_list(my_field))
5049
my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "VARIABLE_VALUE");
5050
my_field->is_autogenerated_name= false;
5051
my_field->set_name(value.c_str(), value.length(), system_charset_info);
5053
if (session->add_item_to_list(my_field))
5060
lex->sql_command= SQLCOM_SELECT;
5062
new(std::nothrow) statement::Select(YYSession);
5063
if (lex->statement == NULL)
5066
Session *session= YYSession;
5068
if (prepare_new_schema_table(session, lex, "PROCESSLIST"))
5071
if (session->add_item_to_list( new Item_field(&session->lex->current_select->
5075
(session->lex->current_select->with_wild)++;
4824
lex->sql_command= SQLCOM_SHOW_STATUS;
4826
new(std::nothrow) statement::ShowStatus(YYSession,
4828
if (lex->statement == NULL)
4830
lex->option_type= $1;
4831
if (prepare_schema_table(YYSession, lex, 0, "STATUS"))
4834
| opt_full PROCESSLIST_SYM
4836
Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;
4838
new(std::nothrow) statement::ShowProcesslist(YYSession);
4839
if (Lex->statement == NULL)
5078
4842
| opt_var_type VARIABLES show_wild
5081
lex->sql_command= SQLCOM_SELECT;
5083
new(std::nothrow) statement::Select(YYSession);
5084
if (lex->statement == NULL)
5087
Session *session= YYSession;
5089
if ($1 == OPT_GLOBAL)
5091
if (prepare_new_schema_table(session, lex, "GLOBAL_VARIABLES"))
5096
if (prepare_new_schema_table(session, lex, "SESSION_VARIABLES"))
5100
std::string key("Variable_name");
5101
std::string value("Value");
5103
Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "VARIABLE_NAME");
5104
my_field->is_autogenerated_name= false;
5105
my_field->set_name(key.c_str(), key.length(), system_charset_info);
5107
if (session->add_item_to_list(my_field))
5110
my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "VARIABLE_VALUE");
5111
my_field->is_autogenerated_name= false;
5112
my_field->set_name(value.c_str(), value.length(), system_charset_info);
5114
if (session->add_item_to_list(my_field))
4845
lex->sql_command= SQLCOM_SHOW_VARIABLES;
4847
new(std::nothrow) statement::Select(SQLCOM_SHOW_VARIABLES,
4849
if (lex->statement == NULL)
4851
lex->option_type= $1;
4852
if (prepare_schema_table(YYSession, lex, 0, "VARIABLES"))
5117
4855
| CREATE DATABASE opt_if_not_exists ident
5119
4857
Lex->sql_command=SQLCOM_SHOW_CREATE_DB;
5120
statement::ShowCreateSchema *statement= new(std::nothrow) statement::ShowCreateSchema(YYSession);
5121
Lex->statement= statement;
4858
Lex->statement= new(std::nothrow) statement::ShowCreateSchema(YYSession);
5122
4859
if (Lex->statement == NULL)
5123
4860
DRIZZLE_YYABORT;
5124
statement->is_if_not_exists= $3;
4861
Lex->create_info.options=$3;
5127
4864
| CREATE TABLE_SYM table_ident