88
87
#include <drizzled/function/get_system_var.h>
89
88
#include <mysys/thr_lock.h>
90
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;
92
135
class Table_ident;
998
1010
query verb_clause create select drop insert replace insert2
999
1011
insert_values update delete truncate rename
1000
show describe load alter optimize keycache flush
1012
show describe load alter optimize flush
1001
1013
begin commit rollback savepoint release
1002
repair analyze check start checksum
1014
analyze check start checksum
1003
1015
field_list field_list_item field_spec kill column_def key_def
1004
keycache_list assign_to_keycache
1005
1016
select_item_list select_item values_list no_braces
1006
1017
opt_limit_clause delete_limit_clause fields opt_values values
1007
1018
opt_precision opt_ignore opt_column
1008
set lock unlock string_list
1009
opt_binary table_lock_list table_lock
1019
set unlock string_list
1010
1021
ref_list opt_match_clause opt_on_update_delete use
1011
1022
opt_delete_options opt_delete_option varchar
1012
opt_outer table_list table_name table_alias_ref_list table_alias_ref
1023
opt_outer table_list table_name
1013
1024
opt_option opt_place
1014
1025
opt_attribute opt_attribute_list attribute
1015
1026
flush_options flush_option
1016
1027
equal optional_braces
1017
1028
opt_mi_check_type opt_to mi_check_types normal_join
1018
1029
table_to_table_list table_to_table opt_table_list opt_as
1019
single_multi table_wild_list table_wild_one opt_wild
1020
1031
union_clause union_list
1021
1032
precision subselect_start
1022
1033
subselect_end select_var_list select_var_list_init opt_len
1121
1133
Session *session= YYSession;
1122
1134
LEX *lex= session->lex;
1123
1135
lex->sql_command= SQLCOM_CREATE_TABLE;
1136
statement::CreateTable *statement= new(std::nothrow) statement::CreateTable(YYSession);
1137
lex->statement= statement;
1138
if (lex->statement == NULL)
1124
1140
if (!lex->select_lex.add_table_to_list(session, $5, NULL,
1125
1141
TL_OPTION_UPDATING,
1127
1143
DRIZZLE_YYABORT;
1128
lex->alter_info.reset();
1129
1144
lex->col_list.empty();
1131
memset(&lex->create_info, 0, sizeof(lex->create_info));
1132
lex->create_info.options=$2 | $4;
1133
lex->create_info.db_type= ha_default_storage_engine(session);
1134
lex->create_info.default_table_charset= NULL;
1145
statement->change=NULL;
1146
statement->create_info.options=$2 | $4;
1147
statement->create_info.db_type= NULL;
1148
statement->create_info.default_table_charset= NULL;
1135
1149
lex->name.str= 0;
1137
drizzled::message::Table *proto=
1138
lex->create_table_proto= new drizzled::message::Table();
1151
message::Table *proto= &statement->create_table_proto;
1140
1153
proto->set_name($5->table.str);
1141
1154
if($2 & HA_LEX_CREATE_TMP_TABLE)
1142
proto->set_type(drizzled::message::Table::TEMPORARY);
1155
proto->set_type(message::Table::TEMPORARY);
1144
proto->set_type(drizzled::message::Table::STANDARD);
1157
proto->set_type(message::Table::STANDARD);
1149
1161
LEX *lex= YYSession->lex;
1150
1162
lex->current_select= &lex->select_lex;
1151
assert(lex->create_info.db_type);
1153
| CREATE build_method opt_unique INDEX_SYM ident key_alg
1164
| CREATE build_method
1157
1167
lex->sql_command= SQLCOM_CREATE_INDEX;
1158
if (!lex->current_select->add_table_to_list(lex->session, $8,
1168
statement::CreateIndex *statement= new(std::nothrow) statement::CreateIndex(YYSession);
1169
lex->statement= statement;
1170
if (lex->statement == NULL)
1172
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1173
statement->alter_info.build_method= $2;
1174
lex->col_list.empty();
1175
statement->change=NULL;
1177
opt_unique INDEX_SYM ident key_alg ON table_ident '(' key_list ')' key_options
1180
statement::CreateIndex *statement= (statement::CreateIndex *)Lex->statement;
1182
if (!lex->current_select->add_table_to_list(lex->session, $9,
1160
1184
TL_OPTION_UPDATING))
1161
1185
DRIZZLE_YYABORT;
1162
lex->alter_info.reset();
1163
lex->alter_info.flags= ALTER_ADD_INDEX;
1164
lex->alter_info.build_method= $2;
1165
lex->col_list.empty();
1168
'(' key_list ')' key_options
1172
key= new Key($3, $5, &lex->key_create_info, 0,
1174
lex->alter_info.key_list.push_back(key);
1187
key= new Key($4, $6, &statement->key_create_info, 0, lex->col_list);
1188
statement->alter_info.key_list.push_back(key);
1175
1189
lex->col_list.empty();
1177
1191
| CREATE DATABASE opt_if_not_exists ident
1179
Lex->create_info.default_table_charset= NULL;
1180
Lex->create_info.used_fields= 0;
1195
lex->sql_command=SQLCOM_CREATE_DB;
1196
statement::CreateSchema *statement= new(std::nothrow) statement::CreateSchema(YYSession);
1197
lex->statement= statement;
1198
if (lex->statement == NULL)
1200
statement->create_info.options=$3;
1182
1202
opt_create_database_options
1185
lex->sql_command=SQLCOM_CREATE_DB;
1187
lex->create_info.options=$3;
1318
1342
create_table_option:
1319
ENGINE_SYM opt_equal storage_engines
1321
Lex->create_info.db_type= $3;
1322
Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE;
1324
| MAX_ROWS opt_equal ulonglong_num
1326
Lex->create_info.max_rows= $3;
1327
Lex->create_info.used_fields|= HA_CREATE_USED_MAX_ROWS;
1329
| MIN_ROWS opt_equal ulonglong_num
1331
Lex->create_info.min_rows= $3;
1332
Lex->create_info.used_fields|= HA_CREATE_USED_MIN_ROWS;
1334
| AVG_ROW_LENGTH opt_equal ulong_num
1336
Lex->create_info.avg_row_length=$3;
1337
Lex->create_info.used_fields|= HA_CREATE_USED_AVG_ROW_LENGTH;
1343
ENGINE_SYM opt_equal ident_or_text
1345
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1347
statement->create_info.db_type= NULL;
1348
statement->create_info.used_fields|= HA_CREATE_USED_ENGINE;
1351
message::Table::StorageEngine *protoengine;
1352
protoengine= ((statement::CreateTable *)Lex->statement)->create_table_proto.mutable_engine();
1354
protoengine->set_name($3.str);
1339
1357
| BLOCK_SIZE_SYM opt_equal ulong_num
1341
Lex->create_info.block_size= $3;
1342
Lex->create_info.used_fields|= HA_CREATE_USED_BLOCK_SIZE;
1359
message::Table::TableOptions *tableopts;
1360
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1361
tableopts= ((statement::CreateTable *)Lex->statement)->create_table_proto.mutable_options();
1363
tableopts->set_block_size($3);
1364
statement->create_info.used_fields|= HA_CREATE_USED_BLOCK_SIZE;
1344
1366
| COMMENT_SYM opt_equal TEXT_STRING_sys
1346
Lex->create_info.comment=$3;
1347
Lex->create_info.used_fields|= HA_CREATE_USED_COMMENT;
1368
message::Table::TableOptions *tableopts;
1369
tableopts= ((statement::CreateTable *)Lex->statement)->create_table_proto.mutable_options();
1371
tableopts->set_comment($3.str);
1349
1373
| AUTO_INC opt_equal ulonglong_num
1351
Lex->create_info.auto_increment_value=$3;
1352
Lex->create_info.used_fields|= HA_CREATE_USED_AUTO;
1354
| PACK_KEYS_SYM opt_equal ulong_num
1358
Lex->create_info.table_options|= HA_OPTION_NO_PACK_KEYS;
1361
Lex->create_info.table_options|= HA_OPTION_PACK_KEYS;
1364
my_parse_error(ER(ER_SYNTAX_ERROR));
1367
Lex->create_info.used_fields|= HA_CREATE_USED_PACK_KEYS;
1369
| PACK_KEYS_SYM opt_equal DEFAULT
1371
Lex->create_info.table_options&=
1372
~(HA_OPTION_PACK_KEYS | HA_OPTION_NO_PACK_KEYS);
1373
Lex->create_info.used_fields|= HA_CREATE_USED_PACK_KEYS;
1375
| CHECKSUM_SYM opt_equal ulong_num
1377
Lex->create_info.table_options|= $3 ? HA_OPTION_CHECKSUM : HA_OPTION_NO_CHECKSUM;
1378
Lex->create_info.used_fields|= HA_CREATE_USED_CHECKSUM;
1380
| TABLE_CHECKSUM_SYM opt_equal ulong_num
1382
Lex->create_info.table_options|= $3 ? HA_OPTION_CHECKSUM : HA_OPTION_NO_CHECKSUM;
1383
Lex->create_info.used_fields|= HA_CREATE_USED_CHECKSUM;
1385
| PAGE_CHECKSUM_SYM opt_equal choice
1387
Lex->create_info.used_fields|= HA_CREATE_USED_PAGE_CHECKSUM;
1388
Lex->create_info.page_checksum= $3;
1390
| DELAY_KEY_WRITE_SYM opt_equal ulong_num
1392
Lex->create_info.table_options|= $3 ? HA_OPTION_DELAY_KEY_WRITE : HA_OPTION_NO_DELAY_KEY_WRITE;
1393
Lex->create_info.used_fields|= HA_CREATE_USED_DELAY_KEY_WRITE;
1375
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1377
statement->create_info.auto_increment_value=$3;
1378
statement->create_info.used_fields|= HA_CREATE_USED_AUTO;
1395
1380
| ROW_FORMAT_SYM opt_equal row_types
1397
Lex->create_info.row_type= $3;
1398
Lex->create_info.used_fields|= HA_CREATE_USED_ROW_FORMAT;
1399
Lex->alter_info.flags|= ALTER_ROW_FORMAT;
1382
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1384
statement->create_info.row_type= $3;
1385
statement->create_info.used_fields|= HA_CREATE_USED_ROW_FORMAT;
1386
statement->alter_info.flags.set(ALTER_ROW_FORMAT);
1401
1388
| default_collation
1402
| DATA_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys
1404
Lex->create_info.data_file_name= $4.str;
1405
Lex->create_info.used_fields|= HA_CREATE_USED_DATADIR;
1407
| INDEX_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys
1409
Lex->create_info.index_file_name= $4.str;
1410
Lex->create_info.used_fields|= HA_CREATE_USED_INDEXDIR;
1412
| CONNECTION_SYM opt_equal TEXT_STRING_sys
1414
Lex->create_info.connect_string.str= $3.str;
1415
Lex->create_info.connect_string.length= $3.length;
1416
Lex->create_info.used_fields|= HA_CREATE_USED_CONNECTION;
1418
1389
| KEY_BLOCK_SIZE opt_equal ulong_num
1420
Lex->create_info.used_fields|= HA_CREATE_USED_KEY_BLOCK_SIZE;
1421
Lex->create_info.key_block_size= $3;
1391
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1393
statement->create_info.used_fields|= HA_CREATE_USED_KEY_BLOCK_SIZE;
1394
statement->create_info.key_block_size= $3;
1425
1398
default_collation:
1426
1399
opt_default COLLATE_SYM opt_equal collation_name_or_default
1428
HA_CREATE_INFO *cinfo= &Lex->create_info;
1401
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1403
HA_CREATE_INFO *cinfo= &statement->create_info;
1429
1404
if ((cinfo->used_fields & HA_CREATE_USED_DEFAULT_CHARSET) &&
1430
1405
cinfo->default_table_charset && $4 &&
1431
1406
!my_charset_same(cinfo->default_table_charset,$4))
1510
1466
key_type opt_ident key_alg '(' key_list ')' key_options
1513
Key *key= new Key($1, $2, &lex->key_create_info, 0,
1469
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1470
Key *key= new Key($1, $2, &statement->key_create_info, 0,
1514
1471
lex->col_list);
1515
lex->alter_info.key_list.push_back(key);
1472
statement->alter_info.key_list.push_back(key);
1516
1473
lex->col_list.empty(); /* Alloced by sql_alloc */
1518
1475
| opt_constraint constraint_key_type opt_ident key_alg
1519
1476
'(' key_list ')' key_options
1522
Key *key= new Key($2, $3.str ? $3 : $1, &lex->key_create_info, 0,
1479
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1480
Key *key= new Key($2, $3.str ? $3 : $1, &statement->key_create_info, 0,
1523
1481
lex->col_list);
1524
lex->alter_info.key_list.push_back(key);
1482
statement->alter_info.key_list.push_back(key);
1525
1483
lex->col_list.empty(); /* Alloced by sql_alloc */
1527
1485
| opt_constraint FOREIGN KEY_SYM opt_ident '(' key_list ')' references
1488
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1530
1489
Key *key= new Foreign_key($4.str ? $4 : $1, lex->col_list,
1535
lex->fk_match_option);
1536
lex->alter_info.key_list.push_back(key);
1492
statement->fk_delete_opt,
1493
statement->fk_update_opt,
1494
statement->fk_match_option);
1495
statement->alter_info.key_list.push_back(key);
1537
1496
key= new Key(Key::MULTIPLE, $1.str ? $1 : $4,
1538
1497
&default_key_create_info, 1,
1539
1498
lex->col_list);
1540
lex->alter_info.key_list.push_back(key);
1499
statement->alter_info.key_list.push_back(key);
1541
1500
lex->col_list.empty(); /* Alloced by sql_alloc */
1542
1501
/* Only used for ALTER TABLE. Ignored otherwise. */
1543
lex->alter_info.flags|= ALTER_FOREIGN_KEY;
1502
statement->alter_info.flags.set(ALTER_FOREIGN_KEY);
1545
1504
| constraint opt_check_constraint
1536
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1577
1537
lex->length=lex->dec=0;
1579
lex->default_value= lex->on_update_value= 0;
1580
lex->comment=null_lex_str;
1539
statement->default_value= statement->on_update_value= 0;
1540
statement->comment= null_lex_str;
1581
1541
lex->charset=NULL;
1582
lex->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
1542
statement->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
1547
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1587
1548
if (add_field_to_list(lex->session, &$1, (enum enum_field_types) $3,
1588
1549
lex->length,lex->dec,lex->type,
1590
lex->default_value, lex->on_update_value,
1592
lex->change,&lex->interval_list,lex->charset))
1550
statement->column_format,
1551
statement->default_value, statement->on_update_value,
1552
&statement->comment,
1553
statement->change, &lex->interval_list, lex->charset))
1593
1554
DRIZZLE_YYABORT;
1726
1687
NULL_SYM { Lex->type&= ~ NOT_NULL_FLAG; }
1727
1688
| COLUMN_FORMAT_SYM column_format_types
1729
Lex->column_format= $2;
1730
Lex->alter_info.flags|= ALTER_COLUMN_FORMAT;
1690
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1692
statement->column_format= $2;
1693
statement->alter_info.flags.set(ALTER_COLUMN_FORMAT);
1732
1695
| not NULL_SYM { Lex->type|= NOT_NULL_FLAG; }
1733
1696
| DEFAULT now_or_signed_literal
1735
Lex->default_value=$2;
1736
Lex->alter_info.flags|= ALTER_COLUMN_DEFAULT;
1698
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1700
statement->default_value=$2;
1701
statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1738
1703
| ON UPDATE_SYM NOW_SYM optional_braces
1739
{ Lex->on_update_value= new Item_func_now_local(); }
1704
{ ((statement::AlterTable *)Lex->statement)->on_update_value= new Item_func_now_local(); }
1740
1705
| AUTO_INC { Lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG; }
1741
1706
| SERIAL_SYM DEFAULT VALUE_SYM
1709
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1744
1711
lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_FLAG;
1745
lex->alter_info.flags|= ALTER_ADD_INDEX;
1712
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1747
1714
| opt_primary KEY_SYM
1717
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1750
1719
lex->type|= PRI_KEY_FLAG | NOT_NULL_FLAG;
1751
lex->alter_info.flags|= ALTER_ADD_INDEX;
1720
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1725
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1756
1727
lex->type|= UNIQUE_FLAG;
1757
lex->alter_info.flags|= ALTER_ADD_INDEX;
1728
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1759
1730
| UNIQUE_SYM KEY_SYM
1733
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1762
1735
lex->type|= UNIQUE_KEY_FLAG;
1763
lex->alter_info.flags|= ALTER_ADD_INDEX;
1736
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1765
| COMMENT_SYM TEXT_STRING_sys { Lex->comment= $2; }
1738
| COMMENT_SYM TEXT_STRING_sys { ((statement::AlterTable *)Lex->statement)->comment= $2; }
1766
1739
| COLLATE_SYM collation_name
1768
1741
if (Lex->charset && !my_charset_same(Lex->charset,$2))
1916
1889
opt_match_clause:
1918
{ Lex->fk_match_option= Foreign_key::FK_MATCH_UNDEF; }
1891
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= Foreign_key::FK_MATCH_UNDEF; }
1920
{ Lex->fk_match_option= Foreign_key::FK_MATCH_FULL; }
1893
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= Foreign_key::FK_MATCH_FULL; }
1921
1894
| MATCH PARTIAL
1922
{ Lex->fk_match_option= Foreign_key::FK_MATCH_PARTIAL; }
1895
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= Foreign_key::FK_MATCH_PARTIAL; }
1923
1896
| MATCH SIMPLE_SYM
1924
{ Lex->fk_match_option= Foreign_key::FK_MATCH_SIMPLE; }
1897
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= Foreign_key::FK_MATCH_SIMPLE; }
1927
1900
opt_on_update_delete:
1931
lex->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
1932
lex->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
1903
((statement::CreateTable *)Lex->statement)->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
1904
((statement::CreateTable *)Lex->statement)->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
1934
1906
| ON UPDATE_SYM delete_option
1937
lex->fk_update_opt= $3;
1938
lex->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
1908
((statement::CreateTable *)Lex->statement)->fk_update_opt= $3;
1909
((statement::CreateTable *)Lex->statement)->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
1940
1911
| ON DELETE_SYM delete_option
1943
lex->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
1944
lex->fk_delete_opt= $3;
1913
((statement::CreateTable *)Lex->statement)->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
1914
((statement::CreateTable *)Lex->statement)->fk_delete_opt= $3;
1946
1916
| ON UPDATE_SYM delete_option
1947
1917
ON DELETE_SYM delete_option
1950
lex->fk_update_opt= $3;
1951
lex->fk_delete_opt= $6;
1919
((statement::CreateTable *)Lex->statement)->fk_update_opt= $3;
1920
((statement::CreateTable *)Lex->statement)->fk_delete_opt= $6;
1953
1922
| ON DELETE_SYM delete_option
1954
1923
ON UPDATE_SYM delete_option
1957
lex->fk_update_opt= $6;
1958
lex->fk_delete_opt= $3;
1925
((statement::CreateTable *)Lex->statement)->fk_update_opt= $6;
1926
((statement::CreateTable *)Lex->statement)->fk_delete_opt= $3;
2086
2054
lex->name.str= 0;
2087
2055
lex->name.length= 0;
2088
2056
lex->sql_command= SQLCOM_ALTER_TABLE;
2057
statement::AlterTable *statement= new(std::nothrow) statement::AlterTable(YYSession);
2058
lex->statement= statement;
2059
if (lex->statement == NULL)
2089
2061
lex->duplicates= DUP_ERROR;
2090
2062
if (!lex->select_lex.add_table_to_list(session, $5, NULL,
2091
2063
TL_OPTION_UPDATING))
2092
2064
DRIZZLE_YYABORT;
2093
lex->alter_info.reset();
2094
2065
lex->col_list.empty();
2095
2066
lex->select_lex.init_order();
2096
2067
lex->select_lex.db=
2097
2068
((TableList*) lex->select_lex.table_list.first)->db;
2098
memset(&lex->create_info, 0, sizeof(lex->create_info));
2099
lex->create_info.db_type= 0;
2100
lex->create_info.default_table_charset= NULL;
2101
lex->create_info.row_type= ROW_TYPE_NOT_USED;
2102
lex->alter_info.reset();
2103
lex->alter_info.build_method= $2;
2069
statement->create_info.db_type= 0;
2070
statement->create_info.default_table_charset= NULL;
2071
statement->create_info.row_type= ROW_TYPE_NOT_USED;
2072
statement->alter_info.build_method= $2;
2107
2076
| ALTER DATABASE ident_or_empty
2109
Lex->create_info.default_table_charset= NULL;
2110
Lex->create_info.used_fields= 0;
2112
create_database_options
2115
2079
lex->sql_command=SQLCOM_ALTER_DB;
2080
lex->statement= new(std::nothrow) statement::AlterSchema(YYSession);
2081
if (lex->statement == NULL)
2084
default_collation_schema
2117
2088
if (lex->name.str == NULL &&
2118
2089
lex->copy_db_to(&lex->name.str, &lex->name.length))
2165
2145
add_column column_def opt_place { }
2168
Lex->alter_info.flags|= ALTER_ADD_INDEX;
2148
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2150
statement->alter_info.flags.set(ALTER_ADD_INDEX);
2170
2152
| add_column '(' field_list ')'
2172
Lex->alter_info.flags|= ALTER_ADD_COLUMN | ALTER_ADD_INDEX;
2154
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2156
statement->alter_info.flags.set(ALTER_ADD_COLUMN);
2157
statement->alter_info.flags.set(ALTER_ADD_INDEX);
2174
2159
| CHANGE opt_column field_ident
2177
lex->change= $3.str;
2178
lex->alter_info.flags|= ALTER_CHANGE_COLUMN;
2161
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2162
statement->change= $3.str;
2163
statement->alter_info.flags.set(ALTER_CHANGE_COLUMN);
2180
2165
field_spec opt_place
2181
2166
| MODIFY_SYM opt_column field_ident
2169
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2184
2170
lex->length=lex->dec=0; lex->type=0;
2185
lex->default_value= lex->on_update_value= 0;
2186
lex->comment=null_lex_str;
2171
statement->default_value= statement->on_update_value= 0;
2172
statement->comment= null_lex_str;
2187
2173
lex->charset= NULL;
2188
lex->alter_info.flags|= ALTER_CHANGE_COLUMN;
2189
lex->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
2174
statement->alter_info.flags.set(ALTER_CHANGE_COLUMN);
2175
statement->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
2180
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2194
2182
if (add_field_to_list(lex->session,&$3,
2195
2183
(enum enum_field_types) $5,
2196
lex->length,lex->dec,lex->type,
2198
lex->default_value, lex->on_update_value,
2184
lex->length, lex->dec, lex->type,
2185
statement->column_format,
2186
statement->default_value,
2187
statement->on_update_value,
2188
&statement->comment,
2200
2189
$3.str, &lex->interval_list, lex->charset))
2201
2190
DRIZZLE_YYABORT;
2204
2193
| DROP opt_column field_ident
2207
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::COLUMN,
2209
lex->alter_info.flags|= ALTER_DROP_COLUMN;
2195
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2197
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::COLUMN, $3.str));
2198
statement->alter_info.flags.set(ALTER_DROP_COLUMN);
2211
2200
| DROP FOREIGN KEY_SYM opt_ident
2213
Lex->alter_info.flags|= ALTER_DROP_INDEX | ALTER_FOREIGN_KEY;
2202
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2204
statement->alter_info.flags.set(ALTER_DROP_INDEX);
2205
statement->alter_info.flags.set(ALTER_FOREIGN_KEY);
2215
2207
| DROP PRIMARY_SYM KEY_SYM
2218
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::KEY,
2209
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2211
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY,
2220
lex->alter_info.flags|= ALTER_DROP_INDEX;
2213
statement->alter_info.flags.set(ALTER_DROP_INDEX);
2222
2215
| DROP key_or_index field_ident
2225
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::KEY,
2227
lex->alter_info.flags|= ALTER_DROP_INDEX;
2217
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2219
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY,
2221
statement->alter_info.flags.set(ALTER_DROP_INDEX);
2229
2223
| DISABLE_SYM KEYS
2232
lex->alter_info.keys_onoff= DISABLE;
2233
lex->alter_info.flags|= ALTER_KEYS_ONOFF;
2225
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2227
statement->alter_info.keys_onoff= DISABLE;
2228
statement->alter_info.flags.set(ALTER_KEYS_ONOFF);
2235
2230
| ENABLE_SYM KEYS
2238
lex->alter_info.keys_onoff= ENABLE;
2239
lex->alter_info.flags|= ALTER_KEYS_ONOFF;
2232
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2234
statement->alter_info.keys_onoff= ENABLE;
2235
statement->alter_info.flags.set(ALTER_KEYS_ONOFF);
2241
2237
| ALTER opt_column field_ident SET DEFAULT signed_literal
2244
lex->alter_info.alter_list.push_back(new Alter_column($3.str,$6));
2245
lex->alter_info.flags|= ALTER_COLUMN_DEFAULT;
2239
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2241
statement->alter_info.alter_list.push_back(new AlterColumn($3.str,$6));
2242
statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
2247
2244
| ALTER opt_column field_ident DROP DEFAULT
2250
lex->alter_info.alter_list.push_back(new Alter_column($3.str,
2252
lex->alter_info.flags|= ALTER_COLUMN_DEFAULT;
2246
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2248
statement->alter_info.alter_list.push_back(new AlterColumn($3.str, (Item*) 0));
2249
statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
2254
2251
| RENAME opt_to table_ident
2254
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2258
2257
lex->select_lex.db=$3->db.str;
2259
2258
if (lex->select_lex.db == NULL &&
2260
2259
lex->copy_db_to(&lex->select_lex.db, &dummy))
2267
2266
DRIZZLE_YYABORT;
2269
2268
lex->name= $3->table;
2270
lex->alter_info.flags|= ALTER_RENAME;
2269
statement->alter_info.flags.set(ALTER_RENAME);
2272
2271
| CONVERT_SYM TO_SYM collation_name_or_default
2275
lex->create_info.table_charset=
2276
lex->create_info.default_table_charset= $3;
2277
lex->create_info.used_fields|= (HA_CREATE_USED_CHARSET |
2273
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2275
statement->create_info.table_charset=
2276
statement->create_info.default_table_charset= $3;
2277
statement->create_info.used_fields|= (HA_CREATE_USED_CHARSET |
2278
2278
HA_CREATE_USED_DEFAULT_CHARSET);
2279
lex->alter_info.flags|= ALTER_CONVERT;
2279
statement->alter_info.flags.set(ALTER_CONVERT);
2281
2281
| create_table_options_space_separated
2284
lex->alter_info.flags|= ALTER_OPTIONS;
2283
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2285
statement->alter_info.flags.set(ALTER_OPTIONS);
2288
Lex->alter_info.flags|= ALTER_FORCE;
2289
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2291
statement->alter_info.flags.set(ALTER_FORCE);
2290
2293
| alter_order_clause
2293
lex->alter_info.flags|= ALTER_ORDER;
2295
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2297
statement->alter_info.flags.set(ALTER_ORDER);
2350
2361
lex->sql_command = SQLCOM_CHECKSUM;
2362
lex->statement= new(std::nothrow) statement::Checksum(YYSession);
2363
if (lex->statement == NULL)
2352
2366
table_list opt_checksum_type
2356
2370
opt_checksum_type:
2357
/* nothing */ { Lex->check_opt.flags= 0; }
2358
| QUICK { Lex->check_opt.flags= T_QUICK; }
2359
| EXTENDED_SYM { Lex->check_opt.flags= T_EXTEND; }
2363
REPAIR table_or_tables
2366
lex->sql_command = SQLCOM_REPAIR;
2367
lex->check_opt.init();
2369
table_list opt_mi_repair_type
2374
/* empty */ { Lex->check_opt.flags = T_MEDIUM; }
2375
| mi_repair_types {}
2380
| mi_repair_type mi_repair_types {}
2384
QUICK { Lex->check_opt.flags|= T_QUICK; }
2385
| EXTENDED_SYM { Lex->check_opt.flags|= T_EXTEND; }
2386
| USE_FRM { Lex->check_opt.use_frm= true; }
2371
/* nothing */ { ((statement::Checksum *)Lex->statement)->check_opt.flags= 0; }
2372
| QUICK { ((statement::Checksum *)Lex->statement)->check_opt.flags= T_QUICK; }
2373
| EXTENDED_SYM { ((statement::Checksum *)Lex->statement)->check_opt.flags= T_EXTEND; }
2390
2378
ANALYZE_SYM table_or_tables
2393
2381
lex->sql_command = SQLCOM_ANALYZE;
2394
lex->check_opt.init();
2382
lex->statement= new(std::nothrow) statement::Analyze(YYSession);
2383
if (lex->statement == NULL)
4385
4338
lex->sql_command = SQLCOM_DROP_TABLE;
4386
lex->drop_temporary= $2;
4387
lex->drop_if_exists= $4;
4339
statement::DropTable *statement= new(std::nothrow) statement::DropTable(YYSession);
4340
lex->statement= statement;
4341
if (lex->statement == NULL)
4343
statement->drop_temporary= $2;
4344
statement->drop_if_exists= $4;
4389
4346
| DROP build_method INDEX_SYM ident ON table_ident {}
4392
4349
lex->sql_command= SQLCOM_DROP_INDEX;
4393
lex->alter_info.reset();
4394
lex->alter_info.flags= ALTER_DROP_INDEX;
4395
lex->alter_info.build_method= $2;
4396
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::KEY,
4350
statement::DropIndex *statement= new(std::nothrow) statement::DropIndex(YYSession);
4351
lex->statement= statement;
4352
if (lex->statement == NULL)
4354
statement->alter_info.flags.set(ALTER_DROP_INDEX);
4355
statement->alter_info.build_method= $2;
4356
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY, $4.str));
4398
4357
if (!lex->current_select->add_table_to_list(lex->session, $6, NULL,
4399
4358
TL_OPTION_UPDATING))
4400
4359
DRIZZLE_YYABORT;
4681
4640
FROM table_ident
4683
if (!Select->add_table_to_list(YYSession, $2, NULL, TL_OPTION_UPDATING,
4642
if (!Lex->current_select->add_table_to_list(YYSession, $2, NULL, TL_OPTION_UPDATING,
4684
4643
Lex->lock_option))
4685
4644
DRIZZLE_YYABORT;
4687
4646
where_clause opt_order_clause
4688
4647
delete_limit_clause {}
4690
{ mysql_init_multi_delete(Lex); }
4691
FROM join_table_list where_clause
4693
if (multi_delete_set_locks_and_link_aux_tables(Lex))
4696
| FROM table_alias_ref_list
4697
{ mysql_init_multi_delete(Lex); }
4698
USING join_table_list where_clause
4700
if (multi_delete_set_locks_and_link_aux_tables(Lex))
4707
| table_wild_list ',' table_wild_one
4713
if (!Select->add_table_to_list(YYSession, new Table_ident($1),
4715
TL_OPTION_UPDATING | TL_OPTION_ALIAS,
4719
| ident '.' ident opt_wild
4721
if (!Select->add_table_to_list(YYSession,
4722
new Table_ident(YYSession, $1, $3, 0),
4724
TL_OPTION_UPDATING | TL_OPTION_ALIAS,
4735
4650
opt_delete_options:
4780
4697
lex->sql_command= SQLCOM_SHOW_DATABASES;
4781
if (prepare_schema_table(YYSession, lex, 0, SCH_SCHEMATA))
4699
new(std::nothrow) statement::Select(YYSession);
4700
if (lex->statement == NULL)
4702
if (prepare_schema_table(YYSession, lex, 0, "SCHEMATA"))
4782
4703
DRIZZLE_YYABORT;
4784
4705
| opt_full TABLES opt_db show_wild
4787
4708
lex->sql_command= SQLCOM_SHOW_TABLES;
4710
new(std::nothrow) statement::Select(YYSession);
4711
if (lex->statement == NULL)
4788
4713
lex->select_lex.db= $3;
4789
if (prepare_schema_table(YYSession, lex, 0, SCH_TABLE_NAMES))
4714
if (prepare_schema_table(YYSession, lex, 0, "TABLE_NAMES"))
4790
4715
DRIZZLE_YYABORT;
4792
4717
| TABLE_SYM STATUS_SYM opt_db show_wild
4795
4720
lex->sql_command= SQLCOM_SHOW_TABLE_STATUS;
4722
new(std::nothrow) statement::Select(YYSession);
4723
if (lex->statement == NULL)
4796
4725
lex->select_lex.db= $3;
4797
if (prepare_schema_table(YYSession, lex, 0, SCH_TABLES))
4726
if (prepare_schema_table(YYSession, lex, 0, "TABLES"))
4798
4727
DRIZZLE_YYABORT;
4800
4729
| OPEN_SYM TABLES opt_db show_wild
4803
4732
lex->sql_command= SQLCOM_SHOW_OPEN_TABLES;
4734
new(std::nothrow) statement::Select(YYSession);
4735
if (lex->statement == NULL)
4804
4737
lex->select_lex.db= $3;
4805
if (prepare_schema_table(YYSession, lex, 0, SCH_OPEN_TABLES))
4738
if (prepare_schema_table(YYSession, lex, 0, "OPEN_TABLES"))
4806
4739
DRIZZLE_YYABORT;
4808
| ENGINE_SYM known_storage_engines STATUS_SYM /* This should either go... well it should go */
4741
| ENGINE_SYM ident_or_text STATUS_SYM /* This should either go... well it should go */
4810
Lex->create_info.db_type= $2;
4811
4743
Lex->sql_command= SQLCOM_SHOW_ENGINE_STATUS;
4745
new(std::nothrow) statement::ShowEngineStatus(YYSession, $2.str);
4746
if (Lex->statement == NULL)
4813
4749
| opt_full COLUMNS from_or_in table_ident opt_db show_wild
4816
4752
lex->sql_command= SQLCOM_SHOW_FIELDS;
4754
new(std::nothrow) statement::Select(YYSession);
4755
if (lex->statement == NULL)
4818
4758
$4->change_db($5);
4819
if (prepare_schema_table(YYSession, lex, $4, SCH_COLUMNS))
4759
if (prepare_schema_table(YYSession, lex, $4, "COLUMNS"))
4820
4760
DRIZZLE_YYABORT;
4822
4762
| keys_or_index from_or_in table_ident opt_db where_clause
4825
4765
lex->sql_command= SQLCOM_SHOW_KEYS;
4766
lex->statement= new(std::nothrow) statement::Select(YYSession);
4767
if (lex->statement == NULL)
4827
4770
$3->change_db($4);
4828
if (prepare_schema_table(YYSession, lex, $3, SCH_STATISTICS))
4771
if (prepare_schema_table(YYSession, lex, $3, "STATISTICS"))
4829
4772
DRIZZLE_YYABORT;
4831
4774
| COUNT_SYM '(' '*' ')' WARNINGS
4832
{ (void) create_select_for_variable("warning_count"); }
4776
(void) create_select_for_variable("warning_count");
4778
lex->statement= new(std::nothrow) statement::Select(YYSession);
4779
if (lex->statement == NULL)
4833
4782
| COUNT_SYM '(' '*' ')' ERRORS
4834
{ (void) create_select_for_variable("error_count"); }
4784
(void) create_select_for_variable("error_count");
4786
lex->statement= new(std::nothrow) statement::Select(YYSession);
4787
if (lex->statement == NULL)
4835
4790
| WARNINGS opt_limit_clause_init
4836
{ Lex->sql_command = SQLCOM_SHOW_WARNS;}
4792
Lex->sql_command = SQLCOM_SHOW_WARNS;
4793
Lex->statement= new(std::nothrow) statement::ShowWarnings(YYSession);
4794
if (Lex->statement == NULL)
4837
4797
| ERRORS opt_limit_clause_init
4838
{ Lex->sql_command = SQLCOM_SHOW_ERRORS;}
4799
Lex->sql_command = SQLCOM_SHOW_ERRORS;
4800
Lex->statement= new(std::nothrow) statement::ShowErrors(YYSession);
4801
if (Lex->statement == NULL)
4839
4804
| opt_var_type STATUS_SYM show_wild
4842
4807
lex->sql_command= SQLCOM_SHOW_STATUS;
4809
new(std::nothrow) statement::ShowStatus(YYSession,
4811
if (lex->statement == NULL)
4843
4813
lex->option_type= $1;
4844
if (prepare_schema_table(YYSession, lex, 0, SCH_STATUS))
4814
if (prepare_schema_table(YYSession, lex, 0, "STATUS"))
4845
4815
DRIZZLE_YYABORT;
4847
4817
| opt_full PROCESSLIST_SYM
4848
{ Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;}
4819
Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;
4821
new(std::nothrow) statement::ShowProcesslist(YYSession);
4822
if (Lex->statement == NULL)
4849
4825
| opt_var_type VARIABLES show_wild
4852
4828
lex->sql_command= SQLCOM_SHOW_VARIABLES;
4830
new(std::nothrow) statement::Select(YYSession);
4831
if (lex->statement == NULL)
4853
4833
lex->option_type= $1;
4854
if (prepare_schema_table(YYSession, lex, 0, SCH_VARIABLES))
4834
if (prepare_schema_table(YYSession, lex, 0, "VARIABLES"))
4855
4835
DRIZZLE_YYABORT;
4857
4837
| CREATE DATABASE opt_if_not_exists ident
4859
4839
Lex->sql_command=SQLCOM_SHOW_CREATE_DB;
4860
Lex->create_info.options=$3;
4840
statement::ShowCreateSchema *statement= new(std::nothrow) statement::ShowCreateSchema(YYSession);
4841
Lex->statement= statement;
4842
if (Lex->statement == NULL)
4844
statement->create_info.options=$3;
4863
4847
| CREATE TABLE_SYM table_ident
4866
4850
lex->sql_command = SQLCOM_SHOW_CREATE;
4851
lex->statement= new(std::nothrow) statement::ShowCreate(YYSession);
4852
if (lex->statement == NULL)
4867
4854
if (!lex->select_lex.add_table_to_list(YYSession, $3, NULL,0))
4868
4855
DRIZZLE_YYABORT;
5867
5833
| BINARY { $$=new Item_string("binary", 6, system_charset_info); }
5876
Transactional locks can be taken only if all requested locks
5877
are transactional. Initialize lex->lock_transactional as
5878
TRUE. Any non-transactional lock request turns this to FALSE.
5879
Table specific variables keep track of the locking method
5880
requested for the table. This is used to warn about a
5881
changed locking method later.
5883
Lex->lock_transactional= true;
5888
lex->sql_command= SQLCOM_LOCK_TABLES;
5894
5836
table_or_tables:
5901
| table_lock_list ',' table_lock
5905
table_ident opt_table_alias table_lock_info
5908
if (!(tlist= Select->add_table_to_list(YYSession, $1, $2, 0,
5910
DRIZZLE_YYABORT; /* purecov: inspected */
5911
tlist->lock_timeout= $3.lock_timeout;
5912
/* Store the requested lock method for later warning. */
5913
tlist->lock_transactional= $3.lock_transactional;
5914
/* Compute the resulting lock method for all tables. */
5915
if (!$3.lock_transactional)
5916
Lex->lock_transactional= false;
5923
$$.lock_type= TL_READ_NO_INSERT;
5924
$$.lock_timeout= -1;
5925
$$.lock_transactional= false;
5929
$$.lock_type= TL_WRITE_DEFAULT;
5930
$$.lock_timeout= -1;
5931
$$.lock_transactional= false;
5933
| READ_SYM LOCAL_SYM
5935
$$.lock_type= TL_READ;
5936
$$.lock_timeout= -1;
5937
$$.lock_transactional= false;
5942
We have a timeout resolution of milliseconds. The WAIT argument is in
5943
seconds with decimal fragments for sub-second resolution. E.g. 22.5, 0.015
5945
/* opt_lock_timeout_value: */
5946
/* empty { $$= -1; } */
5947
/* | NUM { $$= (int) (atof($1.str) * 1000.0 + 0.5); } */
5953
5845
lex->sql_command= SQLCOM_UNLOCK_TABLES;
5846
lex->statement= new(std::nothrow) statement::UnlockTables(YYSession);
5847
if (lex->statement == NULL)
5955
5850
table_or_tables