1182
1181
lex->sql_command= SQLCOM_CREATE_INDEX;
1183
lex->statement= new(std::nothrow)
1184
statement::CreateIndex(YYSession);
1182
statement::CreateIndex *statement= new(std::nothrow) statement::CreateIndex(YYSession);
1183
lex->statement= statement;
1185
1184
if (lex->statement == NULL)
1186
1185
DRIZZLE_YYABORT;
1187
1186
if (!lex->current_select->add_table_to_list(lex->session, $8,
1189
1188
TL_OPTION_UPDATING))
1190
1189
DRIZZLE_YYABORT;
1191
lex->alter_info.reset();
1192
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1193
lex->alter_info.build_method= $2;
1190
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1191
statement->alter_info.build_method= $2;
1194
1192
lex->col_list.empty();
1195
1193
lex->change=NULL;
1197
1195
'(' key_list ')' key_options
1198
statement::CreateIndex *statement= (statement::CreateIndex *)Lex->statement;
1201
1200
key= new Key($3, $5, &lex->key_create_info, 0,
1202
1201
lex->col_list);
1203
lex->alter_info.key_list.push_back(key);
1202
statement->alter_info.key_list.push_back(key);
1204
1203
lex->col_list.empty();
1206
1205
| CREATE DATABASE opt_if_not_exists ident
1529
1528
key_type opt_ident key_alg '(' key_list ')' key_options
1531
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1532
1532
Key *key= new Key($1, $2, &lex->key_create_info, 0,
1533
1533
lex->col_list);
1534
lex->alter_info.key_list.push_back(key);
1534
statement->alter_info.key_list.push_back(key);
1535
1535
lex->col_list.empty(); /* Alloced by sql_alloc */
1537
1537
| opt_constraint constraint_key_type opt_ident key_alg
1538
1538
'(' key_list ')' key_options
1541
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1541
1542
Key *key= new Key($2, $3.str ? $3 : $1, &lex->key_create_info, 0,
1542
1543
lex->col_list);
1543
lex->alter_info.key_list.push_back(key);
1544
statement->alter_info.key_list.push_back(key);
1544
1545
lex->col_list.empty(); /* Alloced by sql_alloc */
1546
1547
| opt_constraint FOREIGN KEY_SYM opt_ident '(' key_list ')' references
1550
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1549
1551
Key *key= new Foreign_key($4.str ? $4 : $1, lex->col_list,
1552
1554
lex->fk_delete_opt,
1553
1555
lex->fk_update_opt,
1554
1556
lex->fk_match_option);
1555
lex->alter_info.key_list.push_back(key);
1557
statement->alter_info.key_list.push_back(key);
1556
1558
key= new Key(Key::MULTIPLE, $1.str ? $1 : $4,
1557
1559
&default_key_create_info, 1,
1558
1560
lex->col_list);
1559
lex->alter_info.key_list.push_back(key);
1561
statement->alter_info.key_list.push_back(key);
1560
1562
lex->col_list.empty(); /* Alloced by sql_alloc */
1561
1563
/* Only used for ALTER TABLE. Ignored otherwise. */
1562
lex->alter_info.flags.set(ALTER_FOREIGN_KEY);
1564
statement->alter_info.flags.set(ALTER_FOREIGN_KEY);
1564
1566
| constraint opt_check_constraint
1745
1747
NULL_SYM { Lex->type&= ~ NOT_NULL_FLAG; }
1746
1748
| COLUMN_FORMAT_SYM column_format_types
1750
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1748
1752
Lex->column_format= $2;
1749
Lex->alter_info.flags.set(ALTER_COLUMN_FORMAT);
1753
statement->alter_info.flags.set(ALTER_COLUMN_FORMAT);
1751
1755
| not NULL_SYM { Lex->type|= NOT_NULL_FLAG; }
1752
1756
| DEFAULT now_or_signed_literal
1758
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1754
1760
Lex->default_value=$2;
1755
Lex->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1761
statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1757
1763
| ON UPDATE_SYM NOW_SYM optional_braces
1758
1764
{ Lex->on_update_value= new Item_func_now_local(); }
1760
1766
| SERIAL_SYM DEFAULT VALUE_SYM
1769
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1763
1771
lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_FLAG;
1764
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1772
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1766
1774
| opt_primary KEY_SYM
1777
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1769
1779
lex->type|= PRI_KEY_FLAG | NOT_NULL_FLAG;
1770
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1780
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1785
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1775
1787
lex->type|= UNIQUE_FLAG;
1776
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1788
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1778
1790
| UNIQUE_SYM KEY_SYM
1793
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1781
1795
lex->type|= UNIQUE_KEY_FLAG;
1782
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1796
statement->alter_info.flags.set(ALTER_ADD_INDEX);
1784
1798
| COMMENT_SYM TEXT_STRING_sys { Lex->comment= $2; }
1785
1799
| COLLATE_SYM collation_name
2189
2210
add_column column_def opt_place { }
2192
Lex->alter_info.flags.set(ALTER_ADD_INDEX);
2213
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2214
statement->alter_info.flags.set(ALTER_ADD_INDEX);
2194
2216
| add_column '(' field_list ')'
2196
Lex->alter_info.flags.set(ALTER_ADD_COLUMN);
2197
Lex->alter_info.flags.set(ALTER_ADD_INDEX);
2218
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2220
statement->alter_info.flags.set(ALTER_ADD_COLUMN);
2221
statement->alter_info.flags.set(ALTER_ADD_INDEX);
2199
2223
| CHANGE opt_column field_ident
2226
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2202
2227
lex->change= $3.str;
2203
lex->alter_info.flags.set(ALTER_CHANGE_COLUMN);
2228
statement->alter_info.flags.set(ALTER_CHANGE_COLUMN);
2205
2230
field_spec opt_place
2206
2231
| MODIFY_SYM opt_column field_ident
2234
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2209
2235
lex->length=lex->dec=0; lex->type=0;
2210
2236
lex->default_value= lex->on_update_value= 0;
2211
2237
lex->comment=null_lex_str;
2212
2238
lex->charset= NULL;
2213
lex->alter_info.flags.set(ALTER_CHANGE_COLUMN);
2239
statement->alter_info.flags.set(ALTER_CHANGE_COLUMN);
2214
2240
lex->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
2229
2255
| DROP opt_column field_ident
2232
lex->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::COLUMN,
2234
lex->alter_info.flags.set(ALTER_DROP_COLUMN);
2257
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2259
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::COLUMN,
2261
statement->alter_info.flags.set(ALTER_DROP_COLUMN);
2236
2263
| DROP FOREIGN KEY_SYM opt_ident
2238
Lex->alter_info.flags.set(ALTER_DROP_INDEX);
2239
Lex->alter_info.flags.set(ALTER_FOREIGN_KEY);
2265
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2267
statement->alter_info.flags.set(ALTER_DROP_INDEX);
2268
statement->alter_info.flags.set(ALTER_FOREIGN_KEY);
2241
2270
| DROP PRIMARY_SYM KEY_SYM
2244
lex->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY,
2272
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2274
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY,
2246
lex->alter_info.flags.set(ALTER_DROP_INDEX);
2276
statement->alter_info.flags.set(ALTER_DROP_INDEX);
2248
2278
| DROP key_or_index field_ident
2251
lex->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY,
2253
lex->alter_info.flags.set(ALTER_DROP_INDEX);
2280
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2282
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY,
2284
statement->alter_info.flags.set(ALTER_DROP_INDEX);
2255
2286
| DISABLE_SYM KEYS
2258
lex->alter_info.keys_onoff= DISABLE;
2259
lex->alter_info.flags.set(ALTER_KEYS_ONOFF);
2288
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2290
statement->alter_info.keys_onoff= DISABLE;
2291
statement->alter_info.flags.set(ALTER_KEYS_ONOFF);
2261
2293
| ENABLE_SYM KEYS
2264
lex->alter_info.keys_onoff= ENABLE;
2265
lex->alter_info.flags.set(ALTER_KEYS_ONOFF);
2295
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2297
statement->alter_info.keys_onoff= ENABLE;
2298
statement->alter_info.flags.set(ALTER_KEYS_ONOFF);
2267
2300
| ALTER opt_column field_ident SET DEFAULT signed_literal
2270
lex->alter_info.alter_list.push_back(new AlterColumn($3.str,$6));
2271
lex->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
2302
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2304
statement->alter_info.alter_list.push_back(new AlterColumn($3.str,$6));
2305
statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
2273
2307
| ALTER opt_column field_ident DROP DEFAULT
2276
lex->alter_info.alter_list.push_back(new AlterColumn($3.str,
2278
lex->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
2309
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2311
statement->alter_info.alter_list.push_back(new AlterColumn($3.str, (Item*) 0));
2312
statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
2280
2314
| RENAME opt_to table_ident
2317
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2284
2320
lex->select_lex.db=$3->db.str;
2285
2321
if (lex->select_lex.db == NULL &&
2286
2322
lex->copy_db_to(&lex->select_lex.db, &dummy))
2293
2329
DRIZZLE_YYABORT;
2295
2331
lex->name= $3->table;
2296
lex->alter_info.flags.set(ALTER_RENAME);
2332
statement->alter_info.flags.set(ALTER_RENAME);
2298
2334
| CONVERT_SYM TO_SYM collation_name_or_default
2301
2336
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2303
2338
statement->create_info.table_charset=
2304
2339
statement->create_info.default_table_charset= $3;
2305
2340
statement->create_info.used_fields|= (HA_CREATE_USED_CHARSET |
2306
2341
HA_CREATE_USED_DEFAULT_CHARSET);
2307
lex->alter_info.flags.set(ALTER_CONVERT);
2342
statement->alter_info.flags.set(ALTER_CONVERT);
2309
2344
| create_table_options_space_separated
2312
lex->alter_info.flags.set(ALTER_OPTIONS);
2346
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2348
statement->alter_info.flags.set(ALTER_OPTIONS);
2316
Lex->alter_info.flags.set(ALTER_FORCE);
2352
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2354
statement->alter_info.flags.set(ALTER_FORCE);
2318
2356
| alter_order_clause
2321
lex->alter_info.flags.set(ALTER_ORDER);
2358
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2360
statement->alter_info.flags.set(ALTER_ORDER);
2337
2376
| AFTER_SYM ident
2378
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2339
2380
store_position_for_column($2.str);
2340
Lex->alter_info.flags.set(ALTER_COLUMN_ORDER);
2381
statement->alter_info.flags.set(ALTER_COLUMN_ORDER);
2385
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2344
2387
store_position_for_column(first_keyword);
2345
Lex->alter_info.flags.set(ALTER_COLUMN_ORDER);
2388
statement->alter_info.flags.set(ALTER_COLUMN_ORDER);
4370
4413
lex->sql_command= SQLCOM_DROP_INDEX;
4371
lex->statement= new(std::nothrow)
4372
statement::DropIndex(YYSession);
4414
statement::DropIndex *statement= new(std::nothrow) statement::DropIndex(YYSession);
4415
lex->statement= statement;
4373
4416
if (lex->statement == NULL)
4374
4417
DRIZZLE_YYABORT;
4375
lex->alter_info.reset();
4376
lex->alter_info.flags.set(ALTER_DROP_INDEX);
4377
lex->alter_info.build_method= $2;
4378
lex->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY,
4418
statement->alter_info.flags.set(ALTER_DROP_INDEX);
4419
statement->alter_info.build_method= $2;
4420
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY, $4.str));
4380
4421
if (!lex->current_select->add_table_to_list(lex->session, $6, NULL,
4381
4422
TL_OPTION_UPDATING))
4382
4423
DRIZZLE_YYABORT;