87
87
#include <drizzled/function/get_system_var.h>
88
88
#include <mysys/thr_lock.h>
89
89
#include <drizzled/message/table.pb.h>
90
#include <drizzled/command.h>
91
#include <drizzled/command/checksum.h>
92
#include <drizzled/command/commit.h>
93
#include <drizzled/command/empty_query.h>
94
#include <drizzled/command/load.h>
95
#include <drizzled/command/rollback.h>
96
#include <drizzled/command/select.h>
97
#include <drizzled/command/show_create.h>
98
#include <drizzled/command/show_engine_status.h>
99
#include <drizzled/command/show_errors.h>
100
#include <drizzled/command/show_processlist.h>
101
#include <drizzled/command/show_status.h>
102
#include <drizzled/command/show_warnings.h>
90
#include <drizzled/statement.h>
91
#include <drizzled/statement/alter_schema.h>
92
#include <drizzled/statement/analyze.h>
93
#include <drizzled/statement/change_schema.h>
94
#include <drizzled/statement/check.h>
95
#include <drizzled/statement/checksum.h>
96
#include <drizzled/statement/commit.h>
97
#include <drizzled/statement/create_schema.h>
98
#include <drizzled/statement/delete.h>
99
#include <drizzled/statement/drop_schema.h>
100
#include <drizzled/statement/drop_table.h>
101
#include <drizzled/statement/empty_query.h>
102
#include <drizzled/statement/flush.h>
103
#include <drizzled/statement/kill.h>
104
#include <drizzled/statement/load.h>
105
#include <drizzled/statement/optimize.h>
106
#include <drizzled/statement/rollback.h>
107
#include <drizzled/statement/select.h>
108
#include <drizzled/statement/set_option.h>
109
#include <drizzled/statement/show_create.h>
110
#include <drizzled/statement/show_create_schema.h>
111
#include <drizzled/statement/show_engine_status.h>
112
#include <drizzled/statement/show_errors.h>
113
#include <drizzled/statement/show_processlist.h>
114
#include <drizzled/statement/show_status.h>
115
#include <drizzled/statement/show_warnings.h>
116
#include <drizzled/statement/truncate.h>
117
#include <drizzled/statement/unlock_tables.h>
118
#include <drizzled/statement/update.h>
104
120
using namespace drizzled;
520
535
%token DECIMAL_SYM /* SQL-2003-R */
521
536
%token DECLARE_SYM /* SQL-2003-R */
522
537
%token DEFAULT /* SQL-2003-R */
523
%token DELAY_KEY_WRITE_SYM
524
538
%token DELETE_SYM /* SQL-2003-R */
525
539
%token DESC /* SQL-2003-N */
526
540
%token DESCRIBE /* SQL-2003-R */
527
541
%token DETERMINISTIC_SYM /* SQL-2003-R */
529
542
%token DISABLE_SYM
531
544
%token DISTINCT /* SQL-2003-R */
1142
1148
lex->create_info.default_table_charset= NULL;
1143
1149
lex->name.str= 0;
1145
drizzled::message::Table *proto=
1146
lex->create_table_proto= new drizzled::message::Table();
1151
message::Table *proto=
1152
lex->create_table_proto= new(std::nothrow) message::Table();
1154
if (lex->create_table_proto == NULL)
1148
1157
proto->set_name($5->table.str);
1149
1158
if($2 & HA_LEX_CREATE_TMP_TABLE)
1150
proto->set_type(drizzled::message::Table::TEMPORARY);
1159
proto->set_type(message::Table::TEMPORARY);
1152
proto->set_type(drizzled::message::Table::STANDARD);
1161
proto->set_type(message::Table::STANDARD);
1155
drizzled::message::Table::StorageEngine *protoengine;
1164
message::Table::StorageEngine *protoengine;
1156
1165
protoengine= proto->mutable_engine();
1157
1166
StorageEngine *engine= ha_default_storage_engine(session);
1337
1351
Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE;
1340
drizzled::message::Table::StorageEngine *protoengine;
1354
message::Table::StorageEngine *protoengine;
1341
1355
protoengine= Lex->create_table_proto->mutable_engine();
1343
1357
protoengine->set_name($3->getName());
1346
| MAX_ROWS opt_equal ulonglong_num
1348
Lex->create_info.max_rows= $3;
1349
Lex->create_info.used_fields|= HA_CREATE_USED_MAX_ROWS;
1351
| MIN_ROWS opt_equal ulonglong_num
1353
Lex->create_info.min_rows= $3;
1354
Lex->create_info.used_fields|= HA_CREATE_USED_MIN_ROWS;
1356
| AVG_ROW_LENGTH opt_equal ulong_num
1358
Lex->create_info.avg_row_length=$3;
1359
Lex->create_info.used_fields|= HA_CREATE_USED_AVG_ROW_LENGTH;
1361
1360
| BLOCK_SIZE_SYM opt_equal ulong_num
1363
1362
Lex->create_info.block_size= $3;
1366
1365
| COMMENT_SYM opt_equal TEXT_STRING_sys
1368
Lex->create_info.comment=$3;
1369
Lex->create_info.used_fields|= HA_CREATE_USED_COMMENT;
1367
message::Table::TableOptions *tableopts;
1368
tableopts= Lex->create_table_proto->mutable_options();
1370
tableopts->set_comment($3.str);
1371
1372
| AUTO_INC opt_equal ulonglong_num
1373
1374
Lex->create_info.auto_increment_value=$3;
1374
1375
Lex->create_info.used_fields|= HA_CREATE_USED_AUTO;
1376
| PACK_KEYS_SYM opt_equal ulong_num
1380
Lex->create_info.table_options|= HA_OPTION_NO_PACK_KEYS;
1383
Lex->create_info.table_options|= HA_OPTION_PACK_KEYS;
1386
my_parse_error(ER(ER_SYNTAX_ERROR));
1389
Lex->create_info.used_fields|= HA_CREATE_USED_PACK_KEYS;
1391
| PACK_KEYS_SYM opt_equal DEFAULT
1393
Lex->create_info.table_options&=
1394
~(HA_OPTION_PACK_KEYS | HA_OPTION_NO_PACK_KEYS);
1395
Lex->create_info.used_fields|= HA_CREATE_USED_PACK_KEYS;
1397
| CHECKSUM_SYM opt_equal ulong_num
1399
Lex->create_info.table_options|= $3 ? HA_OPTION_CHECKSUM : HA_OPTION_NO_CHECKSUM;
1400
Lex->create_info.used_fields|= HA_CREATE_USED_CHECKSUM;
1402
| TABLE_CHECKSUM_SYM opt_equal ulong_num
1404
Lex->create_info.table_options|= $3 ? HA_OPTION_CHECKSUM : HA_OPTION_NO_CHECKSUM;
1405
Lex->create_info.used_fields|= HA_CREATE_USED_CHECKSUM;
1407
| PAGE_CHECKSUM_SYM opt_equal choice
1409
Lex->create_info.used_fields|= HA_CREATE_USED_PAGE_CHECKSUM;
1410
Lex->create_info.page_checksum= $3;
1412
| DELAY_KEY_WRITE_SYM opt_equal ulong_num
1414
Lex->create_info.table_options|= $3 ? HA_OPTION_DELAY_KEY_WRITE : HA_OPTION_NO_DELAY_KEY_WRITE;
1415
Lex->create_info.used_fields|= HA_CREATE_USED_DELAY_KEY_WRITE;
1417
1377
| ROW_FORMAT_SYM opt_equal row_types
1419
1379
Lex->create_info.row_type= $3;
1421
1381
Lex->alter_info.flags.set(ALTER_ROW_FORMAT);
1423
1383
| default_collation
1424
| DATA_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys
1426
Lex->create_info.data_file_name= $4.str;
1427
Lex->create_info.used_fields|= HA_CREATE_USED_DATADIR;
1429
| INDEX_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys
1431
Lex->create_info.index_file_name= $4.str;
1432
Lex->create_info.used_fields|= HA_CREATE_USED_INDEXDIR;
1434
| CONNECTION_SYM opt_equal TEXT_STRING_sys
1436
Lex->create_info.connect_string.str= $3.str;
1437
Lex->create_info.connect_string.length= $3.length;
1438
Lex->create_info.used_fields|= HA_CREATE_USED_CONNECTION;
1440
1384
| KEY_BLOCK_SIZE opt_equal ulong_num
1442
1386
Lex->create_info.used_fields|= HA_CREATE_USED_KEY_BLOCK_SIZE;
2378
2325
lex->sql_command = SQLCOM_CHECKSUM;
2379
lex->command= new(std::nothrow) command::Checksum(SQLCOM_CHECKSUM,
2381
if (lex->command == NULL)
2326
lex->statement= new(std::nothrow) statement::Checksum(YYSession);
2327
if (lex->statement == NULL)
2382
2328
DRIZZLE_YYABORT;
2384
2330
table_list opt_checksum_type
2483
2438
lex->sql_command= SQLCOM_SELECT;
2484
lex->command= new(std::nothrow) command::Select(SQLCOM_SELECT,
2439
lex->statement= new(std::nothrow) statement::Select(SQLCOM_SELECT,
2486
if (lex->command == NULL)
2441
if (lex->statement == NULL)
2487
2442
DRIZZLE_YYABORT;
3192
3147
function_call_generic:
3195
Function_builder *udf= 0;
3196
udf= find_udf($1.str, $1.length);
3150
plugin::Registry &plugins= plugin::Registry::singleton();
3151
const plugin::Function *udf= plugins.function.get($1.str, $1.length);
3198
/* Temporary placing the result of find_udf in $3 */
3153
/* Temporary placing the result of getFunction in $3 */
3201
3156
opt_udf_expr_list ')'
3223
/* Retrieving the result of find_udf */
3224
Function_builder *udf= $<udf>3;
3178
/* Retrieving the result of slot::Function::get */
3179
const plugin::Function *udf= $<udf>3;
3227
3182
item= Create_udf_func::s_singleton.create(session, udf, $4);
4366
4319
if (!lex->current_select->add_table_to_list(lex->session, $6, NULL,
4367
4320
TL_OPTION_UPDATING))
4368
4321
DRIZZLE_YYABORT;
4323
lex->create_table_proto= new message::Table();
4370
4325
| DROP DATABASE if_exists ident
4373
4328
lex->sql_command= SQLCOM_DROP_DB;
4329
lex->statement= new(std::nothrow) statement::DropSchema(YYSession);
4330
if (lex->statement == NULL)
4374
4332
lex->drop_if_exists=$3;
4562
4520
mysql_init_select(lex);
4563
4521
lex->sql_command= SQLCOM_UPDATE;
4522
lex->statement= new(std::nothrow) statement::Update(YYSession);
4523
if (lex->statement == NULL)
4564
4525
lex->lock_option= TL_UNLOCK; /* Will be set later */
4565
4526
lex->duplicates= DUP_ERROR;
4566
4527
if (!lex->select_lex.add_table_to_list(YYSession, $3, NULL,0))
4688
4655
lex->sql_command= SQLCOM_SHOW_DATABASES;
4690
new(std::nothrow) command::Select(SQLCOM_SHOW_DATABASES,
4657
new(std::nothrow) statement::Select(SQLCOM_SHOW_DATABASES,
4692
if (lex->command == NULL)
4659
if (lex->statement == NULL)
4693
4660
DRIZZLE_YYABORT;
4694
4661
if (prepare_schema_table(YYSession, lex, 0, "SCHEMATA"))
4695
4662
DRIZZLE_YYABORT;
4700
4667
lex->sql_command= SQLCOM_SHOW_TABLES;
4702
new(std::nothrow) command::Select(SQLCOM_SHOW_TABLES,
4669
new(std::nothrow) statement::Select(SQLCOM_SHOW_TABLES,
4704
if (lex->command == NULL)
4671
if (lex->statement == NULL)
4705
4672
DRIZZLE_YYABORT;
4706
4673
lex->select_lex.db= $3;
4707
4674
if (prepare_schema_table(YYSession, lex, 0, "TABLE_NAMES"))
4713
4680
lex->sql_command= SQLCOM_SHOW_TABLE_STATUS;
4715
new(std::nothrow) command::Select(SQLCOM_SHOW_TABLE_STATUS,
4682
new(std::nothrow) statement::Select(SQLCOM_SHOW_TABLE_STATUS,
4717
if (lex->command == NULL)
4684
if (lex->statement == NULL)
4718
4685
DRIZZLE_YYABORT;
4719
4686
lex->select_lex.db= $3;
4720
4687
if (prepare_schema_table(YYSession, lex, 0, "TABLES"))
4726
4693
lex->sql_command= SQLCOM_SHOW_OPEN_TABLES;
4728
new(std::nothrow) command::Select(SQLCOM_SHOW_OPEN_TABLES,
4695
new(std::nothrow) statement::Select(SQLCOM_SHOW_OPEN_TABLES,
4730
if (lex->command == NULL)
4697
if (lex->statement == NULL)
4731
4698
DRIZZLE_YYABORT;
4732
4699
lex->select_lex.db= $3;
4733
4700
if (prepare_schema_table(YYSession, lex, 0, "OPEN_TABLES"))
4738
4705
Lex->show_engine= $2;
4739
4706
Lex->sql_command= SQLCOM_SHOW_ENGINE_STATUS;
4741
new(std::nothrow) command::ShowEngineStatus(SQLCOM_SHOW_ENGINE_STATUS,
4743
if (Lex->command == NULL)
4708
new(std::nothrow) statement::ShowEngineStatus(YYSession);
4709
if (Lex->statement == NULL)
4744
4710
DRIZZLE_YYABORT;
4746
4712
| opt_full COLUMNS from_or_in table_ident opt_db show_wild
4749
4715
lex->sql_command= SQLCOM_SHOW_FIELDS;
4751
new(std::nothrow) command::Select(SQLCOM_SHOW_FIELDS, YYSession);
4752
if (lex->command == NULL)
4717
new(std::nothrow) statement::Select(SQLCOM_SHOW_FIELDS, YYSession);
4718
if (lex->statement == NULL)
4753
4719
DRIZZLE_YYABORT;
4755
4721
$4->change_db($5);
4762
4728
lex->sql_command= SQLCOM_SHOW_KEYS;
4763
lex->command= new(std::nothrow) command::Select(SQLCOM_SHOW_KEYS,
4729
lex->statement= new(std::nothrow) statement::Select(SQLCOM_SHOW_KEYS,
4765
if (lex->command == NULL)
4731
if (lex->statement == NULL)
4766
4732
DRIZZLE_YYABORT;
4768
4734
$3->change_db($4);
4774
4740
(void) create_select_for_variable("warning_count");
4776
lex->command= new(std::nothrow) command::Select(SQLCOM_SELECT,
4742
lex->statement= new(std::nothrow) statement::Select(SQLCOM_SELECT,
4778
if (lex->command == NULL)
4744
if (lex->statement == NULL)
4779
4745
DRIZZLE_YYABORT;
4781
4747
| COUNT_SYM '(' '*' ')' ERRORS
4783
4749
(void) create_select_for_variable("error_count");
4785
lex->command= new(std::nothrow) command::Select(SQLCOM_SELECT,
4751
lex->statement= new(std::nothrow) statement::Select(SQLCOM_SELECT,
4787
if (lex->command == NULL)
4753
if (lex->statement == NULL)
4788
4754
DRIZZLE_YYABORT;
4790
4756
| WARNINGS opt_limit_clause_init
4792
4758
Lex->sql_command = SQLCOM_SHOW_WARNS;
4793
Lex->command= new(std::nothrow) command::ShowWarnings(SQLCOM_SHOW_WARNS,
4795
if (Lex->command == NULL)
4759
Lex->statement= new(std::nothrow) statement::ShowWarnings(YYSession);
4760
if (Lex->statement == NULL)
4796
4761
DRIZZLE_YYABORT;
4798
4763
| ERRORS opt_limit_clause_init
4800
4765
Lex->sql_command = SQLCOM_SHOW_ERRORS;
4801
Lex->command= new(std::nothrow) command::ShowErrors(SQLCOM_SHOW_ERRORS,
4803
if (Lex->command == NULL)
4766
Lex->statement= new(std::nothrow) statement::ShowErrors(YYSession);
4767
if (Lex->statement == NULL)
4804
4768
DRIZZLE_YYABORT;
4806
4770
| opt_var_type STATUS_SYM show_wild
4809
4773
lex->sql_command= SQLCOM_SHOW_STATUS;
4811
new(std::nothrow) command::ShowStatus(SQLCOM_SHOW_STATUS,
4775
new(std::nothrow) statement::ShowStatus(YYSession,
4814
if (lex->command == NULL)
4777
if (lex->statement == NULL)
4815
4778
DRIZZLE_YYABORT;
4816
4779
lex->option_type= $1;
4817
4780
if (prepare_schema_table(YYSession, lex, 0, "STATUS"))
4820
4783
| opt_full PROCESSLIST_SYM
4822
4785
Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;
4824
new(std::nothrow) command::ShowProcesslist(SQLCOM_SHOW_PROCESSLIST,
4826
if (Lex->command == NULL)
4787
new(std::nothrow) statement::ShowProcesslist(YYSession);
4788
if (Lex->statement == NULL)
4827
4789
DRIZZLE_YYABORT;
4829
4791
| opt_var_type VARIABLES show_wild
4832
4794
lex->sql_command= SQLCOM_SHOW_VARIABLES;
4834
new(std::nothrow) command::Select(SQLCOM_SHOW_VARIABLES,
4796
new(std::nothrow) statement::Select(SQLCOM_SHOW_VARIABLES,
4836
if (lex->command == NULL)
4798
if (lex->statement == NULL)
4837
4799
DRIZZLE_YYABORT;
4838
4800
lex->option_type= $1;
4839
4801
if (prepare_schema_table(YYSession, lex, 0, "VARIABLES"))
4851
4816
lex->sql_command = SQLCOM_SHOW_CREATE;
4852
lex->command= new(std::nothrow) command::ShowCreate(SQLCOM_SHOW_CREATE,
4854
if (lex->command == NULL)
4817
lex->statement= new(std::nothrow) statement::ShowCreate(YYSession);
4818
if (lex->statement == NULL)
4855
4819
DRIZZLE_YYABORT;
4856
4820
if (!lex->select_lex.add_table_to_list(YYSession, $3, NULL,0))
4857
4821
DRIZZLE_YYABORT;
4898
4862
mysql_init_select(lex);
4899
4863
lex->current_select->parsing_place= SELECT_LIST;
4900
4864
lex->sql_command= SQLCOM_SHOW_FIELDS;
4901
lex->command= new(std::nothrow) command::Select(SQLCOM_SHOW_FIELDS,
4865
lex->statement= new(std::nothrow) statement::Select(SQLCOM_SHOW_FIELDS,
4903
if (lex->command == NULL)
4867
if (lex->statement == NULL)
4904
4868
DRIZZLE_YYABORT;
4905
4869
lex->select_lex.db= 0;
4906
4870
lex->verbose= 0;
5020
4993
lex->sql_command= SQLCOM_LOAD;
5021
lex->command= new(std::nothrow) command::Load(SQLCOM_LOAD,
5023
if (lex->command == NULL)
4994
lex->statement= new(std::nothrow) statement::Load(YYSession);
4995
if (lex->statement == NULL)
5024
4996
DRIZZLE_YYABORT;
5025
4997
lex->lock_option= $4;
5026
4998
lex->duplicates= DUP_ERROR;