~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_yacc.yy

  • Committer: Brian Aker
  • Date: 2009-09-24 06:23:51 UTC
  • mfrom: (1128.2.12 merge)
  • Revision ID: brian@gaz-20090924062351-nuf8tv8ftg7oc9ad
Merge of Lex -> Statement refactoring

Show diffs side-by-side

added added

removed removed

Lines of Context:
1136
1136
            Session *session= YYSession;
1137
1137
            LEX *lex= session->lex;
1138
1138
            lex->sql_command= SQLCOM_CREATE_TABLE;
1139
 
            lex->statement= new(std::nothrow) statement::CreateTable(YYSession);
 
1139
            statement::CreateTable *statement= new(std::nothrow) statement::CreateTable(YYSession);
 
1140
            lex->statement= statement;
1140
1141
            if (lex->statement == NULL)
1141
1142
              DRIZZLE_YYABORT;
1142
1143
            if (!lex->select_lex.add_table_to_list(session, $5, NULL,
1143
1144
                                                   TL_OPTION_UPDATING,
1144
1145
                                                   TL_WRITE))
1145
1146
              DRIZZLE_YYABORT;
1146
 
            lex->alter_info.reset();
1147
1147
            lex->col_list.empty();
1148
 
            lex->change=NULL;
1149
 
            memset(&lex->create_info, 0, sizeof(lex->create_info));
1150
 
            lex->create_info.options=$2 | $4;
1151
 
            lex->create_info.db_type= ha_default_storage_engine(session);
1152
 
            lex->create_info.default_table_charset= NULL;
 
1148
            statement->change=NULL;
 
1149
            statement->create_info.options=$2 | $4;
 
1150
            statement->create_info.db_type= ha_default_storage_engine(session);
 
1151
            statement->create_info.default_table_charset= NULL;
1153
1152
            lex->name.str= 0;
1154
1153
 
1155
 
            message::Table *proto=
1156
 
              lex->create_table_proto= new(std::nothrow) message::Table();
1157
 
 
1158
 
            if (lex->create_table_proto == NULL)
1159
 
              DRIZZLE_YYABORT;
 
1154
            message::Table *proto= &statement->create_table_proto;
1160
1155
            
1161
1156
            proto->set_name($5->table.str);
1162
1157
            if($2 & HA_LEX_CREATE_TMP_TABLE)
1175
1170
          create2
1176
1171
          {
1177
1172
            LEX *lex= YYSession->lex;
 
1173
            statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1178
1174
            lex->current_select= &lex->select_lex; 
1179
 
            assert(lex->create_info.db_type);
 
1175
            assert(statement->create_info.db_type);
1180
1176
          }
1181
 
        | CREATE build_method opt_unique INDEX_SYM ident key_alg 
1182
 
          ON table_ident
 
1177
        | CREATE build_method
1183
1178
          {
1184
1179
            LEX *lex=Lex;
1185
1180
            lex->sql_command= SQLCOM_CREATE_INDEX;
1186
 
            lex->statement= new(std::nothrow) 
1187
 
              statement::CreateIndex(YYSession);
 
1181
            statement::CreateIndex *statement= new(std::nothrow) statement::CreateIndex(YYSession);
 
1182
            lex->statement= statement;
1188
1183
            if (lex->statement == NULL)
1189
1184
              DRIZZLE_YYABORT;
1190
 
            if (!lex->current_select->add_table_to_list(lex->session, $8,
 
1185
            statement->alter_info.flags.set(ALTER_ADD_INDEX);
 
1186
            statement->alter_info.build_method= $2;
 
1187
            lex->col_list.empty();
 
1188
            statement->change=NULL;
 
1189
          }
 
1190
          opt_unique INDEX_SYM ident key_alg ON table_ident '(' key_list ')' key_options
 
1191
          {
 
1192
            LEX *lex=Lex;
 
1193
            statement::CreateIndex *statement= (statement::CreateIndex *)Lex->statement;
 
1194
 
 
1195
            if (!lex->current_select->add_table_to_list(lex->session, $9,
1191
1196
                                                        NULL,
1192
1197
                                                        TL_OPTION_UPDATING))
1193
1198
              DRIZZLE_YYABORT;
1194
 
            lex->alter_info.reset();
1195
 
            lex->alter_info.flags.set(ALTER_ADD_INDEX);
1196
 
            lex->alter_info.build_method= $2;
1197
 
            lex->col_list.empty();
1198
 
            lex->change=NULL;
1199
 
 
1200
 
            lex->create_table_proto= new message::Table();
1201
 
          }
1202
 
          '(' key_list ')' key_options
1203
 
          {
1204
 
            LEX *lex=Lex;
1205
1199
            Key *key;
1206
 
            key= new Key($3, $5, &lex->key_create_info, 0,
1207
 
                         lex->col_list);
1208
 
            lex->alter_info.key_list.push_back(key);
 
1200
            key= new Key($4, $6, &statement->key_create_info, 0, lex->col_list);
 
1201
            statement->alter_info.key_list.push_back(key);
1209
1202
            lex->col_list.empty();
1210
1203
          }
1211
1204
        | CREATE DATABASE opt_if_not_exists ident
1212
1205
          {
1213
 
            Lex->create_info.default_table_charset= NULL;
1214
 
            Lex->create_info.used_fields= 0;
 
1206
            LEX *lex=Lex;
 
1207
 
 
1208
            lex->sql_command=SQLCOM_CREATE_DB;
 
1209
            statement::CreateSchema *statement= new(std::nothrow) statement::CreateSchema(YYSession);
 
1210
            lex->statement= statement;
 
1211
            if (lex->statement == NULL)
 
1212
              DRIZZLE_YYABORT;
 
1213
            statement->create_info.options=$3;
1215
1214
          }
1216
1215
          opt_create_database_options
1217
1216
          {
1218
 
            LEX *lex=Lex;
1219
 
            lex->sql_command=SQLCOM_CREATE_DB;
1220
 
            lex->statement= new(std::nothrow) statement::CreateSchema(YYSession);
1221
 
            if (lex->statement == NULL)
1222
 
              DRIZZLE_YYABORT;
1223
 
            lex->name= $4;
1224
 
            lex->create_info.options=$3;
 
1217
            Lex->name= $4;
1225
1218
          }
1226
1219
        ;
1227
1220
 
1233
1226
          {
1234
1227
            Session *session= YYSession;
1235
1228
            LEX *lex= session->lex;
 
1229
            statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1236
1230
 
1237
 
            lex->create_info.options|= HA_LEX_CREATE_TABLE_LIKE;
 
1231
            statement->create_info.options|= HA_LEX_CREATE_TABLE_LIKE;
1238
1232
            if (!lex->select_lex.add_table_to_list(session, $2, NULL, 0, TL_READ))
1239
1233
              DRIZZLE_YYABORT;
1240
1234
          }
1242
1236
          {
1243
1237
            Session *session= YYSession;
1244
1238
            LEX *lex= session->lex;
 
1239
            statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1245
1240
 
1246
 
            lex->create_info.options|= HA_LEX_CREATE_TABLE_LIKE;
 
1241
            statement->create_info.options|= HA_LEX_CREATE_TABLE_LIKE;
1247
1242
            if (!lex->select_lex.add_table_to_list(session, $3, NULL, 0, TL_READ))
1248
1243
              DRIZZLE_YYABORT;
1249
1244
          }
1317
1312
 
1318
1313
opt_create_database_options:
1319
1314
          /* empty */ {}
1320
 
        | create_database_options {}
1321
 
        ;
1322
 
 
1323
 
create_database_options:
1324
 
          create_database_option {}
1325
 
        | create_database_options create_database_option {}
1326
 
        ;
1327
 
 
1328
 
create_database_option:
1329
 
          default_collation {}
 
1315
        | default_collation_schema {}
1330
1316
        ;
1331
1317
 
1332
1318
opt_table_options:
1367
1353
create_table_option:
1368
1354
          ENGINE_SYM opt_equal storage_engines
1369
1355
          {
1370
 
            Lex->create_info.db_type= $3;
1371
 
            Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE;
 
1356
            statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
 
1357
 
 
1358
            statement->create_info.db_type= $3;
 
1359
            statement->create_info.used_fields|= HA_CREATE_USED_ENGINE;
1372
1360
 
1373
1361
            {
1374
1362
              message::Table::StorageEngine *protoengine;
1375
 
              protoengine= Lex->create_table_proto->mutable_engine();
 
1363
              protoengine= ((statement::CreateTable *)Lex->statement)->create_table_proto.mutable_engine();
1376
1364
 
1377
1365
              protoengine->set_name($3->getName());
1378
1366
            }
1380
1368
        | BLOCK_SIZE_SYM opt_equal ulong_num    
1381
1369
          { 
1382
1370
            message::Table::TableOptions *tableopts;
1383
 
            tableopts= Lex->create_table_proto->mutable_options();
 
1371
            statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
 
1372
            tableopts= ((statement::CreateTable *)Lex->statement)->create_table_proto.mutable_options();
1384
1373
 
1385
1374
            tableopts->set_block_size($3);
1386
 
            Lex->create_info.used_fields|= HA_CREATE_USED_BLOCK_SIZE;
 
1375
            statement->create_info.used_fields|= HA_CREATE_USED_BLOCK_SIZE;
1387
1376
          }
1388
1377
        | COMMENT_SYM opt_equal TEXT_STRING_sys
1389
1378
          {
1390
1379
            message::Table::TableOptions *tableopts;
1391
 
            tableopts= Lex->create_table_proto->mutable_options();
 
1380
            tableopts= ((statement::CreateTable *)Lex->statement)->create_table_proto.mutable_options();
1392
1381
 
1393
1382
            tableopts->set_comment($3.str);
1394
1383
          }
1395
1384
        | AUTO_INC opt_equal ulonglong_num
1396
1385
          {
1397
 
            Lex->create_info.auto_increment_value=$3;
1398
 
            Lex->create_info.used_fields|= HA_CREATE_USED_AUTO;
 
1386
            statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
 
1387
 
 
1388
            statement->create_info.auto_increment_value=$3;
 
1389
            statement->create_info.used_fields|= HA_CREATE_USED_AUTO;
1399
1390
          }
1400
1391
        | ROW_FORMAT_SYM opt_equal row_types
1401
1392
          {
1402
 
            Lex->create_info.row_type= $3;
1403
 
            Lex->create_info.used_fields|= HA_CREATE_USED_ROW_FORMAT;
1404
 
            Lex->alter_info.flags.set(ALTER_ROW_FORMAT);
 
1393
            statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
 
1394
 
 
1395
            statement->create_info.row_type= $3;
 
1396
            statement->create_info.used_fields|= HA_CREATE_USED_ROW_FORMAT;
 
1397
            statement->alter_info.flags.set(ALTER_ROW_FORMAT);
1405
1398
          }
1406
1399
        | default_collation
1407
1400
        | KEY_BLOCK_SIZE opt_equal ulong_num
1408
1401
          {
1409
 
            Lex->create_info.used_fields|= HA_CREATE_USED_KEY_BLOCK_SIZE;
1410
 
            Lex->create_info.key_block_size= $3;
 
1402
            statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
 
1403
 
 
1404
            statement->create_info.used_fields|= HA_CREATE_USED_KEY_BLOCK_SIZE;
 
1405
            statement->create_info.key_block_size= $3;
1411
1406
          }
1412
1407
        ;
1413
1408
 
1414
1409
default_collation:
1415
1410
          opt_default COLLATE_SYM opt_equal collation_name_or_default
1416
1411
          {
1417
 
            HA_CREATE_INFO *cinfo= &Lex->create_info;
 
1412
            statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
 
1413
 
 
1414
            HA_CREATE_INFO *cinfo= &statement->create_info;
1418
1415
            if ((cinfo->used_fields & HA_CREATE_USED_DEFAULT_CHARSET) &&
1419
1416
                 cinfo->default_table_charset && $4 &&
1420
1417
                 !my_charset_same(cinfo->default_table_charset,$4))
1423
1420
                         $4->name, cinfo->default_table_charset->csname);
1424
1421
                DRIZZLE_YYABORT;
1425
1422
              }
1426
 
              Lex->create_info.default_table_charset= $4;
1427
 
              Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET;
 
1423
              statement->create_info.default_table_charset= $4;
 
1424
              statement->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET;
 
1425
          }
 
1426
        ;
 
1427
 
 
1428
default_collation_schema:
 
1429
          opt_default COLLATE_SYM opt_equal collation_name_or_default
 
1430
          {
 
1431
            statement::CreateSchema *statement= (statement::CreateSchema *)Lex->statement;
 
1432
 
 
1433
            statement->create_info.default_table_charset= $4;
 
1434
            statement->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET;
1428
1435
          }
1429
1436
        ;
1430
1437
 
1501
1508
          key_type opt_ident key_alg '(' key_list ')' key_options
1502
1509
          {
1503
1510
            LEX *lex=Lex;
1504
 
            Key *key= new Key($1, $2, &lex->key_create_info, 0,
 
1511
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1512
            Key *key= new Key($1, $2, &statement->key_create_info, 0,
1505
1513
                              lex->col_list);
1506
 
            lex->alter_info.key_list.push_back(key);
 
1514
            statement->alter_info.key_list.push_back(key);
1507
1515
            lex->col_list.empty(); /* Alloced by sql_alloc */
1508
1516
          }
1509
1517
        | opt_constraint constraint_key_type opt_ident key_alg
1510
1518
          '(' key_list ')' key_options
1511
1519
          {
1512
1520
            LEX *lex=Lex;
1513
 
            Key *key= new Key($2, $3.str ? $3 : $1, &lex->key_create_info, 0,
 
1521
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1522
            Key *key= new Key($2, $3.str ? $3 : $1, &statement->key_create_info, 0,
1514
1523
                              lex->col_list);
1515
 
            lex->alter_info.key_list.push_back(key);
 
1524
            statement->alter_info.key_list.push_back(key);
1516
1525
            lex->col_list.empty(); /* Alloced by sql_alloc */
1517
1526
          }
1518
1527
        | opt_constraint FOREIGN KEY_SYM opt_ident '(' key_list ')' references
1519
1528
          {
1520
1529
            LEX *lex=Lex;
 
1530
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1521
1531
            Key *key= new Foreign_key($4.str ? $4 : $1, lex->col_list,
1522
1532
                                      $8,
1523
1533
                                      lex->ref_list,
1524
 
                                      lex->fk_delete_opt,
1525
 
                                      lex->fk_update_opt,
1526
 
                                      lex->fk_match_option);
1527
 
            lex->alter_info.key_list.push_back(key);
 
1534
                                      statement->fk_delete_opt,
 
1535
                                      statement->fk_update_opt,
 
1536
                                      statement->fk_match_option);
 
1537
            statement->alter_info.key_list.push_back(key);
1528
1538
            key= new Key(Key::MULTIPLE, $1.str ? $1 : $4,
1529
1539
                         &default_key_create_info, 1,
1530
1540
                         lex->col_list);
1531
 
            lex->alter_info.key_list.push_back(key);
 
1541
            statement->alter_info.key_list.push_back(key);
1532
1542
            lex->col_list.empty(); /* Alloced by sql_alloc */
1533
1543
            /* Only used for ALTER TABLE. Ignored otherwise. */
1534
 
            lex->alter_info.flags.set(ALTER_FOREIGN_KEY);
 
1544
            statement->alter_info.flags.set(ALTER_FOREIGN_KEY);
1535
1545
          }
1536
1546
        | constraint opt_check_constraint
1537
1547
          {
1565
1575
          field_ident
1566
1576
          {
1567
1577
            LEX *lex=Lex;
 
1578
            statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1568
1579
            lex->length=lex->dec=0;
1569
1580
            lex->type=0;
1570
 
            lex->default_value= lex->on_update_value= 0;
1571
 
            lex->comment=null_lex_str;
 
1581
            statement->default_value= statement->on_update_value= 0;
 
1582
            statement->comment= null_lex_str;
1572
1583
            lex->charset=NULL;
1573
 
            lex->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
 
1584
            statement->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
1574
1585
          }
1575
1586
          field_def
1576
1587
          {
1577
1588
            LEX *lex=Lex;
 
1589
            statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1578
1590
            if (add_field_to_list(lex->session, &$1, (enum enum_field_types) $3,
1579
1591
                                  lex->length,lex->dec,lex->type,
1580
 
                                  lex->column_format,
1581
 
                                  lex->default_value, lex->on_update_value, 
1582
 
                                  &lex->comment,
1583
 
                                  lex->change,&lex->interval_list,lex->charset))
 
1592
                                  statement->column_format,
 
1593
                                  statement->default_value, statement->on_update_value, 
 
1594
                                  &statement->comment,
 
1595
                                  statement->change, &lex->interval_list, lex->charset))
1584
1596
              DRIZZLE_YYABORT;
1585
1597
          }
1586
1598
        ;
1717
1729
          NULL_SYM { Lex->type&= ~ NOT_NULL_FLAG; }
1718
1730
        | COLUMN_FORMAT_SYM column_format_types
1719
1731
          {
1720
 
            Lex->column_format= $2;
1721
 
            Lex->alter_info.flags.set(ALTER_COLUMN_FORMAT);
 
1732
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1733
 
 
1734
            statement->column_format= $2;
 
1735
            statement->alter_info.flags.set(ALTER_COLUMN_FORMAT);
1722
1736
          }
1723
1737
        | not NULL_SYM { Lex->type|= NOT_NULL_FLAG; }
1724
1738
        | DEFAULT now_or_signed_literal 
1725
1739
          { 
1726
 
            Lex->default_value=$2; 
1727
 
            Lex->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
 
1740
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1741
 
 
1742
            statement->default_value=$2; 
 
1743
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1728
1744
          }
1729
1745
        | ON UPDATE_SYM NOW_SYM optional_braces 
1730
 
          { Lex->on_update_value= new Item_func_now_local(); }
 
1746
          { ((statement::AlterTable *)Lex->statement)->on_update_value= new Item_func_now_local(); }
1731
1747
        | AUTO_INC { Lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG; }
1732
1748
        | SERIAL_SYM DEFAULT VALUE_SYM
1733
1749
          { 
1734
1750
            LEX *lex=Lex;
 
1751
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1752
 
1735
1753
            lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_FLAG;
1736
 
            lex->alter_info.flags.set(ALTER_ADD_INDEX);
 
1754
            statement->alter_info.flags.set(ALTER_ADD_INDEX);
1737
1755
          }
1738
1756
        | opt_primary KEY_SYM
1739
1757
          {
1740
1758
            LEX *lex=Lex;
 
1759
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1760
 
1741
1761
            lex->type|= PRI_KEY_FLAG | NOT_NULL_FLAG;
1742
 
            lex->alter_info.flags.set(ALTER_ADD_INDEX);
 
1762
            statement->alter_info.flags.set(ALTER_ADD_INDEX);
1743
1763
          }
1744
1764
        | UNIQUE_SYM
1745
1765
          {
1746
1766
            LEX *lex=Lex;
 
1767
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1768
 
1747
1769
            lex->type|= UNIQUE_FLAG; 
1748
 
            lex->alter_info.flags.set(ALTER_ADD_INDEX);
 
1770
            statement->alter_info.flags.set(ALTER_ADD_INDEX);
1749
1771
          }
1750
1772
        | UNIQUE_SYM KEY_SYM
1751
1773
          {
1752
1774
            LEX *lex=Lex;
 
1775
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
1776
 
1753
1777
            lex->type|= UNIQUE_KEY_FLAG; 
1754
 
            lex->alter_info.flags.set(ALTER_ADD_INDEX);
 
1778
            statement->alter_info.flags.set(ALTER_ADD_INDEX);
1755
1779
          }
1756
 
        | COMMENT_SYM TEXT_STRING_sys { Lex->comment= $2; }
 
1780
        | COMMENT_SYM TEXT_STRING_sys { ((statement::AlterTable *)Lex->statement)->comment= $2; }
1757
1781
        | COLLATE_SYM collation_name
1758
1782
          {
1759
1783
            if (Lex->charset && !my_charset_same(Lex->charset,$2))
1906
1930
 
1907
1931
opt_match_clause:
1908
1932
          /* empty */
1909
 
          { Lex->fk_match_option= Foreign_key::FK_MATCH_UNDEF; }
 
1933
          { ((statement::CreateTable *)Lex->statement)->fk_match_option= Foreign_key::FK_MATCH_UNDEF; }
1910
1934
        | MATCH FULL
1911
 
          { Lex->fk_match_option= Foreign_key::FK_MATCH_FULL; }
 
1935
          { ((statement::CreateTable *)Lex->statement)->fk_match_option= Foreign_key::FK_MATCH_FULL; }
1912
1936
        | MATCH PARTIAL
1913
 
          { Lex->fk_match_option= Foreign_key::FK_MATCH_PARTIAL; }
 
1937
          { ((statement::CreateTable *)Lex->statement)->fk_match_option= Foreign_key::FK_MATCH_PARTIAL; }
1914
1938
        | MATCH SIMPLE_SYM
1915
 
          { Lex->fk_match_option= Foreign_key::FK_MATCH_SIMPLE; }
 
1939
          { ((statement::CreateTable *)Lex->statement)->fk_match_option= Foreign_key::FK_MATCH_SIMPLE; }
1916
1940
        ;
1917
1941
 
1918
1942
opt_on_update_delete:
1919
1943
          /* empty */
1920
1944
          {
1921
 
            LEX *lex= Lex;
1922
 
            lex->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
1923
 
            lex->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
 
1945
            ((statement::CreateTable *)Lex->statement)->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
 
1946
            ((statement::CreateTable *)Lex->statement)->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
1924
1947
          }
1925
1948
        | ON UPDATE_SYM delete_option
1926
1949
          {
1927
 
            LEX *lex= Lex;
1928
 
            lex->fk_update_opt= $3;
1929
 
            lex->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
 
1950
            ((statement::CreateTable *)Lex->statement)->fk_update_opt= $3;
 
1951
            ((statement::CreateTable *)Lex->statement)->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
1930
1952
          }
1931
1953
        | ON DELETE_SYM delete_option
1932
1954
          {
1933
 
            LEX *lex= Lex;
1934
 
            lex->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
1935
 
            lex->fk_delete_opt= $3;
 
1955
            ((statement::CreateTable *)Lex->statement)->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
 
1956
            ((statement::CreateTable *)Lex->statement)->fk_delete_opt= $3;
1936
1957
          }
1937
1958
        | ON UPDATE_SYM delete_option
1938
1959
          ON DELETE_SYM delete_option
1939
1960
          {
1940
 
            LEX *lex= Lex;
1941
 
            lex->fk_update_opt= $3;
1942
 
            lex->fk_delete_opt= $6;
 
1961
            ((statement::CreateTable *)Lex->statement)->fk_update_opt= $3;
 
1962
            ((statement::CreateTable *)Lex->statement)->fk_delete_opt= $6;
1943
1963
          }
1944
1964
        | ON DELETE_SYM delete_option
1945
1965
          ON UPDATE_SYM delete_option
1946
1966
          {
1947
 
            LEX *lex= Lex;
1948
 
            lex->fk_update_opt= $6;
1949
 
            lex->fk_delete_opt= $3;
 
1967
            ((statement::CreateTable *)Lex->statement)->fk_update_opt= $6;
 
1968
            ((statement::CreateTable *)Lex->statement)->fk_delete_opt= $3;
1950
1969
          }
1951
1970
        ;
1952
1971
 
1990
2009
 
1991
2010
init_key_options:
1992
2011
          {
1993
 
            Lex->key_create_info= default_key_create_info;
 
2012
            ((statement::CreateTable *)Lex->statement)->key_create_info= default_key_create_info;
1994
2013
          }
1995
2014
        ;
1996
2015
 
2016
2035
        ;
2017
2036
 
2018
2037
key_using_alg:
2019
 
          USING btree_or_rtree     { Lex->key_create_info.algorithm= $2; }
2020
 
        | TYPE_SYM btree_or_rtree  { Lex->key_create_info.algorithm= $2; }
 
2038
          USING btree_or_rtree     { ((statement::CreateTable *)Lex->statement)->key_create_info.algorithm= $2; }
 
2039
        | TYPE_SYM btree_or_rtree  { ((statement::CreateTable *)Lex->statement)->key_create_info.algorithm= $2; }
2021
2040
        ;
2022
2041
 
2023
2042
key_opt:
2024
2043
          key_using_alg
2025
2044
        | KEY_BLOCK_SIZE opt_equal ulong_num
2026
 
          { Lex->key_create_info.block_size= $3; }
 
2045
          { ((statement::CreateTable *)Lex->statement)->key_create_info.block_size= $3; }
2027
2046
        | COMMENT_SYM TEXT_STRING_sys
2028
 
          { Lex->key_create_info.comment= $2; }
 
2047
          { ((statement::CreateTable *)Lex->statement)->key_create_info.comment= $2; }
2029
2048
        ;
2030
2049
 
2031
2050
btree_or_rtree:
2077
2096
            lex->name.str= 0;
2078
2097
            lex->name.length= 0;
2079
2098
            lex->sql_command= SQLCOM_ALTER_TABLE;
2080
 
            lex->statement= new(std::nothrow) statement::AlterTable(YYSession);
 
2099
            statement::AlterTable *statement= new(std::nothrow) statement::AlterTable(YYSession);
 
2100
            lex->statement= statement;
2081
2101
            if (lex->statement == NULL)
2082
2102
              DRIZZLE_YYABORT;
2083
2103
            lex->duplicates= DUP_ERROR; 
2084
2104
            if (!lex->select_lex.add_table_to_list(session, $5, NULL,
2085
2105
                                                   TL_OPTION_UPDATING))
2086
2106
              DRIZZLE_YYABORT;
2087
 
            lex->alter_info.reset();
2088
2107
            lex->col_list.empty();
2089
2108
            lex->select_lex.init_order();
2090
2109
            lex->select_lex.db=
2091
2110
              ((TableList*) lex->select_lex.table_list.first)->db;
2092
 
            memset(&lex->create_info, 0, sizeof(lex->create_info));
2093
 
            lex->create_info.db_type= 0;
2094
 
            lex->create_info.default_table_charset= NULL;
2095
 
            lex->create_info.row_type= ROW_TYPE_NOT_USED;
2096
 
            lex->alter_info.reset();
2097
 
            lex->alter_info.build_method= $2;
2098
 
 
2099
 
            lex->create_table_proto= new message::Table();
 
2111
            statement->create_info.db_type= 0;
 
2112
            statement->create_info.default_table_charset= NULL;
 
2113
            statement->create_info.row_type= ROW_TYPE_NOT_USED;
 
2114
            statement->alter_info.build_method= $2;
2100
2115
          }
2101
2116
          alter_commands
2102
2117
          {}
2103
2118
        | ALTER DATABASE ident_or_empty
2104
 
          {
2105
 
            Lex->create_info.default_table_charset= NULL;
2106
 
            Lex->create_info.used_fields= 0;
2107
 
          }
2108
 
          create_database_options
2109
 
          {
 
2119
          { 
2110
2120
            LEX *lex=Lex;
2111
2121
            lex->sql_command=SQLCOM_ALTER_DB;
2112
2122
            lex->statement= new(std::nothrow) statement::AlterSchema(YYSession);
2113
2123
            if (lex->statement == NULL)
2114
2124
              DRIZZLE_YYABORT;
 
2125
          }
 
2126
          default_collation_schema
 
2127
          {
 
2128
            LEX *lex=Lex;
2115
2129
            lex->name= $3;
2116
2130
            if (lex->name.str == NULL &&
2117
2131
                lex->copy_db_to(&lex->name.str, &lex->name.length))
2126
2140
 
2127
2141
alter_commands:
2128
2142
          /* empty */
2129
 
        | DISCARD TABLESPACE { Lex->alter_info.tablespace_op= DISCARD_TABLESPACE; }
2130
 
        | IMPORT TABLESPACE { Lex->alter_info.tablespace_op= IMPORT_TABLESPACE; }
 
2143
        | DISCARD TABLESPACE 
 
2144
          { 
 
2145
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
2146
            statement->alter_info.tablespace_op= DISCARD_TABLESPACE; 
 
2147
          }
 
2148
        | IMPORT TABLESPACE 
 
2149
          { 
 
2150
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
2151
            statement->alter_info.tablespace_op= IMPORT_TABLESPACE; 
 
2152
          }
2131
2153
        | alter_list
2132
2154
        ;
2133
2155
 
2154
2176
add_column:
2155
2177
          ADD opt_column
2156
2178
          {
2157
 
            LEX *lex=Lex;
2158
 
            lex->change=0;
2159
 
            lex->alter_info.flags.set(ALTER_ADD_COLUMN);
 
2179
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
2180
 
 
2181
            statement->change=0;
 
2182
            statement->alter_info.flags.set(ALTER_ADD_COLUMN);
2160
2183
          }
2161
2184
        ;
2162
2185
 
2164
2187
          add_column column_def opt_place { }
2165
2188
        | ADD key_def
2166
2189
          {
2167
 
            Lex->alter_info.flags.set(ALTER_ADD_INDEX);
 
2190
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
2191
 
 
2192
            statement->alter_info.flags.set(ALTER_ADD_INDEX);
2168
2193
          }
2169
2194
        | add_column '(' field_list ')'
2170
2195
          {
2171
 
            Lex->alter_info.flags.set(ALTER_ADD_COLUMN);
2172
 
            Lex->alter_info.flags.set(ALTER_ADD_INDEX);
 
2196
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
2197
 
 
2198
            statement->alter_info.flags.set(ALTER_ADD_COLUMN);
 
2199
            statement->alter_info.flags.set(ALTER_ADD_INDEX);
2173
2200
          }
2174
2201
        | CHANGE opt_column field_ident
2175
2202
          {
2176
 
            LEX *lex=Lex;
2177
 
            lex->change= $3.str;
2178
 
            lex->alter_info.flags.set(ALTER_CHANGE_COLUMN);
 
2203
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
2204
            statement->change= $3.str;
 
2205
            statement->alter_info.flags.set(ALTER_CHANGE_COLUMN);
2179
2206
          }
2180
2207
          field_spec opt_place
2181
2208
        | MODIFY_SYM opt_column field_ident
2182
2209
          {
2183
2210
            LEX *lex=Lex;
 
2211
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2184
2212
            lex->length=lex->dec=0; lex->type=0;
2185
 
            lex->default_value= lex->on_update_value= 0;
2186
 
            lex->comment=null_lex_str;
 
2213
            statement->default_value= statement->on_update_value= 0;
 
2214
            statement->comment= null_lex_str;
2187
2215
            lex->charset= NULL;
2188
 
            lex->alter_info.flags.set(ALTER_CHANGE_COLUMN);
2189
 
            lex->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
 
2216
            statement->alter_info.flags.set(ALTER_CHANGE_COLUMN);
 
2217
            statement->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
2190
2218
          }
2191
2219
          field_def
2192
2220
          {
2193
2221
            LEX *lex=Lex;
 
2222
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
2223
 
2194
2224
            if (add_field_to_list(lex->session,&$3,
2195
2225
                                  (enum enum_field_types) $5,
2196
 
                                  lex->length,lex->dec,lex->type,
2197
 
                                  lex->column_format,
2198
 
                                  lex->default_value, lex->on_update_value,
2199
 
                                  &lex->comment,
 
2226
                                  lex->length, lex->dec, lex->type,
 
2227
                                  statement->column_format,
 
2228
                                  statement->default_value, 
 
2229
                                  statement->on_update_value,
 
2230
                                  &statement->comment,
2200
2231
                                  $3.str, &lex->interval_list, lex->charset))
2201
2232
              DRIZZLE_YYABORT;
2202
2233
          }
2203
2234
          opt_place
2204
2235
        | DROP opt_column field_ident
2205
2236
          {
2206
 
            LEX *lex=Lex;
2207
 
            lex->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::COLUMN,
2208
 
                                                               $3.str));
2209
 
            lex->alter_info.flags.set(ALTER_DROP_COLUMN);
 
2237
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
2238
 
 
2239
            statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::COLUMN, $3.str));
 
2240
            statement->alter_info.flags.set(ALTER_DROP_COLUMN);
2210
2241
          }
2211
2242
        | DROP FOREIGN KEY_SYM opt_ident
2212
2243
          {
2213
 
            Lex->alter_info.flags.set(ALTER_DROP_INDEX);
2214
 
            Lex->alter_info.flags.set(ALTER_FOREIGN_KEY);
 
2244
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
2245
 
 
2246
            statement->alter_info.flags.set(ALTER_DROP_INDEX);
 
2247
            statement->alter_info.flags.set(ALTER_FOREIGN_KEY);
2215
2248
          }
2216
2249
        | DROP PRIMARY_SYM KEY_SYM
2217
2250
          {
2218
 
            LEX *lex=Lex;
2219
 
            lex->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY,
 
2251
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
2252
 
 
2253
            statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY,
2220
2254
                                                               "PRIMARY"));
2221
 
            lex->alter_info.flags.set(ALTER_DROP_INDEX);
 
2255
            statement->alter_info.flags.set(ALTER_DROP_INDEX);
2222
2256
          }
2223
2257
        | DROP key_or_index field_ident
2224
2258
          {
2225
 
            LEX *lex=Lex;
2226
 
            lex->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY,
2227
 
                                                               $3.str));
2228
 
            lex->alter_info.flags.set(ALTER_DROP_INDEX);
 
2259
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
2260
 
 
2261
            statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY,
 
2262
                                                                    $3.str));
 
2263
            statement->alter_info.flags.set(ALTER_DROP_INDEX);
2229
2264
          }
2230
2265
        | DISABLE_SYM KEYS
2231
2266
          {
2232
 
            LEX *lex=Lex;
2233
 
            lex->alter_info.keys_onoff= DISABLE;
2234
 
            lex->alter_info.flags.set(ALTER_KEYS_ONOFF);
 
2267
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
2268
 
 
2269
            statement->alter_info.keys_onoff= DISABLE;
 
2270
            statement->alter_info.flags.set(ALTER_KEYS_ONOFF);
2235
2271
          }
2236
2272
        | ENABLE_SYM KEYS
2237
2273
          {
2238
 
            LEX *lex=Lex;
2239
 
            lex->alter_info.keys_onoff= ENABLE;
2240
 
            lex->alter_info.flags.set(ALTER_KEYS_ONOFF);
 
2274
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
2275
 
 
2276
            statement->alter_info.keys_onoff= ENABLE;
 
2277
            statement->alter_info.flags.set(ALTER_KEYS_ONOFF);
2241
2278
          }
2242
2279
        | ALTER opt_column field_ident SET DEFAULT signed_literal
2243
2280
          {
2244
 
            LEX *lex=Lex;
2245
 
            lex->alter_info.alter_list.push_back(new AlterColumn($3.str,$6));
2246
 
            lex->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
 
2281
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
2282
 
 
2283
            statement->alter_info.alter_list.push_back(new AlterColumn($3.str,$6));
 
2284
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
2247
2285
          }
2248
2286
        | ALTER opt_column field_ident DROP DEFAULT
2249
2287
          {
2250
 
            LEX *lex=Lex;
2251
 
            lex->alter_info.alter_list.push_back(new AlterColumn($3.str,
2252
 
                                                                  (Item*) 0));
2253
 
            lex->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
 
2288
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
2289
 
 
2290
            statement->alter_info.alter_list.push_back(new AlterColumn($3.str, (Item*) 0));
 
2291
            statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
2254
2292
          }
2255
2293
        | RENAME opt_to table_ident
2256
2294
          {
2257
2295
            LEX *lex=Lex;
 
2296
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
2258
2297
            size_t dummy;
 
2298
 
2259
2299
            lex->select_lex.db=$3->db.str;
2260
2300
            if (lex->select_lex.db == NULL &&
2261
2301
                lex->copy_db_to(&lex->select_lex.db, &dummy))
2268
2308
              DRIZZLE_YYABORT;
2269
2309
            }
2270
2310
            lex->name= $3->table;
2271
 
            lex->alter_info.flags.set(ALTER_RENAME);
 
2311
            statement->alter_info.flags.set(ALTER_RENAME);
2272
2312
          }
2273
2313
        | CONVERT_SYM TO_SYM collation_name_or_default
2274
2314
          {
2275
 
            LEX *lex= Lex;
2276
 
            lex->create_info.table_charset=
2277
 
            lex->create_info.default_table_charset= $3;
2278
 
            lex->create_info.used_fields|= (HA_CREATE_USED_CHARSET |
 
2315
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
2316
 
 
2317
            statement->create_info.table_charset=
 
2318
            statement->create_info.default_table_charset= $3;
 
2319
            statement->create_info.used_fields|= (HA_CREATE_USED_CHARSET |
2279
2320
              HA_CREATE_USED_DEFAULT_CHARSET);
2280
 
            lex->alter_info.flags.set(ALTER_CONVERT);
 
2321
            statement->alter_info.flags.set(ALTER_CONVERT);
2281
2322
          }
2282
2323
        | create_table_options_space_separated
2283
2324
          {
2284
 
            LEX *lex=Lex;
2285
 
            lex->alter_info.flags.set(ALTER_OPTIONS);
 
2325
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
2326
 
 
2327
            statement->alter_info.flags.set(ALTER_OPTIONS);
2286
2328
          }
2287
2329
        | FORCE_SYM
2288
2330
          {
2289
 
            Lex->alter_info.flags.set(ALTER_FORCE);
 
2331
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
2332
 
 
2333
            statement->alter_info.flags.set(ALTER_FORCE);
2290
2334
          }
2291
2335
        | alter_order_clause
2292
2336
          {
2293
 
            LEX *lex=Lex;
2294
 
            lex->alter_info.flags.set(ALTER_ORDER);
 
2337
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
2338
 
 
2339
            statement->alter_info.flags.set(ALTER_ORDER);
2295
2340
          }
2296
2341
        ;
2297
2342
 
2309
2354
          /* empty */ {}
2310
2355
        | AFTER_SYM ident
2311
2356
          {
 
2357
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
2358
 
2312
2359
            store_position_for_column($2.str);
2313
 
            Lex->alter_info.flags.set(ALTER_COLUMN_ORDER);
 
2360
            statement->alter_info.flags.set(ALTER_COLUMN_ORDER);
2314
2361
          }
2315
2362
        | FIRST_SYM
2316
2363
          {
 
2364
            statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
 
2365
 
2317
2366
            store_position_for_column(first_keyword);
2318
 
            Lex->alter_info.flags.set(ALTER_COLUMN_ORDER);
 
2367
            statement->alter_info.flags.set(ALTER_COLUMN_ORDER);
2319
2368
          }
2320
2369
        ;
2321
2370
 
2361
2410
        ;
2362
2411
 
2363
2412
opt_checksum_type:
2364
 
          /* nothing */ { Lex->check_opt.flags= 0; }
2365
 
        | QUICK         { Lex->check_opt.flags= T_QUICK; }
2366
 
        | EXTENDED_SYM  { Lex->check_opt.flags= T_EXTEND; }
 
2413
          /* nothing */ { ((statement::Checksum *)Lex->statement)->check_opt.flags= 0; }
 
2414
        | QUICK         { ((statement::Checksum *)Lex->statement)->check_opt.flags= T_QUICK; }
 
2415
        | EXTENDED_SYM  { ((statement::Checksum *)Lex->statement)->check_opt.flags= T_EXTEND; }
2367
2416
        ;
2368
2417
 
2369
2418
 
2375
2424
            lex->statement= new(std::nothrow) statement::Analyze(YYSession);
2376
2425
            if (lex->statement == NULL)
2377
2426
              DRIZZLE_YYABORT;
2378
 
            lex->check_opt.init();
2379
2427
          }
2380
2428
          table_list
2381
2429
          {}
2390
2438
            lex->statement= new(std::nothrow) statement::Check(YYSession);
2391
2439
            if (lex->statement == NULL)
2392
2440
              DRIZZLE_YYABORT;
2393
 
            lex->check_opt.init();
2394
2441
          }
2395
2442
          table_list opt_mi_check_type
2396
2443
          {}
2397
2444
        ;
2398
2445
 
2399
2446
opt_mi_check_type:
2400
 
          /* empty */ { Lex->check_opt.flags = T_MEDIUM; }
 
2447
          /* empty */ { ((statement::Check *)Lex->statement)->check_opt.flags = T_MEDIUM; }
2401
2448
        | mi_check_types {}
2402
2449
        ;
2403
2450
 
2407
2454
        ;
2408
2455
 
2409
2456
mi_check_type:
2410
 
          QUICK               { Lex->check_opt.flags|= T_QUICK; }
2411
 
        | FAST_SYM            { Lex->check_opt.flags|= T_FAST; }
2412
 
        | MEDIUM_SYM          { Lex->check_opt.flags|= T_MEDIUM; }
2413
 
        | EXTENDED_SYM        { Lex->check_opt.flags|= T_EXTEND; }
2414
 
        | CHANGED             { Lex->check_opt.flags|= T_CHECK_ONLY_CHANGED; }
 
2457
          QUICK               { ((statement::Check *)Lex->statement)->check_opt.flags|= T_QUICK; }
 
2458
        | FAST_SYM            { ((statement::Check *)Lex->statement)->check_opt.flags|= T_FAST; }
 
2459
        | MEDIUM_SYM          { ((statement::Check *)Lex->statement)->check_opt.flags|= T_MEDIUM; }
 
2460
        | EXTENDED_SYM        { ((statement::Check *)Lex->statement)->check_opt.flags|= T_EXTEND; }
 
2461
        | CHANGED             { ((statement::Check *)Lex->statement)->check_opt.flags|= T_CHECK_ONLY_CHANGED; }
2415
2462
        ;
2416
2463
 
2417
2464
optimize:
2419
2466
          {
2420
2467
            LEX *lex=Lex;
2421
2468
            lex->sql_command = SQLCOM_OPTIMIZE;
2422
 
            lex->statement= new(std::nothrow) statement::Optimize(YYSession);
 
2469
            statement::Optimize *statement= new(std::nothrow) statement::Optimize(YYSession);
 
2470
            lex->statement= statement;
2423
2471
            if (lex->statement == NULL)
2424
2472
              DRIZZLE_YYABORT;
2425
 
            lex->check_opt.init();
2426
2473
          }
2427
2474
          table_list
2428
2475
          {}
2468
2515
          {
2469
2516
            LEX *lex= Lex;
2470
2517
            lex->sql_command= SQLCOM_SELECT;
2471
 
            lex->statement= new(std::nothrow) statement::Select(SQLCOM_SELECT,
2472
 
                                                            YYSession);
 
2518
            lex->statement= new(std::nothrow) statement::Select(YYSession);
2473
2519
            if (lex->statement == NULL)
2474
2520
              DRIZZLE_YYABORT;
2475
2521
          }
4333
4379
          {
4334
4380
            LEX *lex=Lex;
4335
4381
            lex->sql_command = SQLCOM_DROP_TABLE;
4336
 
            lex->statement= new(std::nothrow) statement::DropTable(YYSession);
 
4382
            statement::DropTable *statement= new(std::nothrow) statement::DropTable(YYSession);
 
4383
            lex->statement= statement;
4337
4384
            if (lex->statement == NULL)
4338
4385
              DRIZZLE_YYABORT;
4339
 
            lex->drop_temporary= $2;
4340
 
            lex->drop_if_exists= $4;
 
4386
            statement->drop_temporary= $2;
 
4387
            statement->drop_if_exists= $4;
4341
4388
          }
4342
4389
        | DROP build_method INDEX_SYM ident ON table_ident {}
4343
4390
          {
4344
4391
            LEX *lex=Lex;
4345
4392
            lex->sql_command= SQLCOM_DROP_INDEX;
4346
 
            lex->statement= new(std::nothrow) 
4347
 
              statement::DropIndex(YYSession);
 
4393
            statement::DropIndex *statement= new(std::nothrow) statement::DropIndex(YYSession);
 
4394
            lex->statement= statement;
4348
4395
            if (lex->statement == NULL)
4349
4396
              DRIZZLE_YYABORT;
4350
 
            lex->alter_info.reset();
4351
 
            lex->alter_info.flags.set(ALTER_DROP_INDEX);
4352
 
            lex->alter_info.build_method= $2;
4353
 
            lex->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY,
4354
 
                                                               $4.str));
 
4397
            statement->alter_info.flags.set(ALTER_DROP_INDEX);
 
4398
            statement->alter_info.build_method= $2;
 
4399
            statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY, $4.str));
4355
4400
            if (!lex->current_select->add_table_to_list(lex->session, $6, NULL,
4356
4401
                                                        TL_OPTION_UPDATING))
4357
4402
              DRIZZLE_YYABORT;
4358
 
 
4359
 
            lex->create_table_proto= new message::Table();
4360
4403
          }
4361
4404
        | DROP DATABASE if_exists ident
4362
4405
          {
4363
4406
            LEX *lex=Lex;
4364
4407
            lex->sql_command= SQLCOM_DROP_DB;
4365
 
            lex->statement= new(std::nothrow) statement::DropSchema(YYSession);
 
4408
            statement::DropSchema *statement= new(std::nothrow) statement::DropSchema(YYSession);
 
4409
            lex->statement= statement;
4366
4410
            if (lex->statement == NULL)
4367
4411
              DRIZZLE_YYABORT;
4368
 
            lex->drop_if_exists=$3;
 
4412
            statement->drop_if_exists=$3;
4369
4413
            lex->name= $4;
4370
4414
          }
4371
4415
table_list:
4684
4728
            lex->lock_option= TL_READ;
4685
4729
            mysql_init_select(lex);
4686
4730
            lex->current_select->parsing_place= SELECT_LIST;
4687
 
            memset(&lex->create_info, 0, sizeof(lex->create_info));
4688
4731
          }
4689
4732
          show_param
4690
4733
          {}
4696
4739
             LEX *lex= Lex;
4697
4740
             lex->sql_command= SQLCOM_SHOW_DATABASES;
4698
4741
             lex->statement=
4699
 
               new(std::nothrow) statement::Select(SQLCOM_SHOW_DATABASES, 
4700
 
                                                 YYSession);
 
4742
               new(std::nothrow) statement::Select(YYSession);
4701
4743
             if (lex->statement == NULL)
4702
4744
               DRIZZLE_YYABORT;
4703
4745
             if (prepare_schema_table(YYSession, lex, 0, "SCHEMATA"))
4708
4750
             LEX *lex= Lex;
4709
4751
             lex->sql_command= SQLCOM_SHOW_TABLES;
4710
4752
             lex->statement=
4711
 
               new(std::nothrow) statement::Select(SQLCOM_SHOW_TABLES,
4712
 
                                                 YYSession);
 
4753
               new(std::nothrow) statement::Select(YYSession);
4713
4754
             if (lex->statement == NULL)
4714
4755
               DRIZZLE_YYABORT;
4715
4756
             lex->select_lex.db= $3;
4721
4762
             LEX *lex= Lex;
4722
4763
             lex->sql_command= SQLCOM_SHOW_TABLE_STATUS;
4723
4764
             lex->statement=
4724
 
               new(std::nothrow) statement::Select(SQLCOM_SHOW_TABLE_STATUS,
4725
 
                                                 YYSession);
 
4765
               new(std::nothrow) statement::Select(YYSession);
4726
4766
             if (lex->statement == NULL)
4727
4767
               DRIZZLE_YYABORT;
4728
4768
             lex->select_lex.db= $3;
4734
4774
            LEX *lex= Lex;
4735
4775
            lex->sql_command= SQLCOM_SHOW_OPEN_TABLES;
4736
4776
            lex->statement=
4737
 
              new(std::nothrow) statement::Select(SQLCOM_SHOW_OPEN_TABLES,
4738
 
                                                YYSession);
 
4777
              new(std::nothrow) statement::Select(YYSession);
4739
4778
            if (lex->statement == NULL)
4740
4779
              DRIZZLE_YYABORT;
4741
4780
            lex->select_lex.db= $3;
4744
4783
          }
4745
4784
        | ENGINE_SYM known_storage_engines STATUS_SYM /* This should either go... well it should go */
4746
4785
          { 
4747
 
            Lex->show_engine= $2; 
4748
4786
            Lex->sql_command= SQLCOM_SHOW_ENGINE_STATUS;
4749
4787
            Lex->statement= 
4750
 
              new(std::nothrow) statement::ShowEngineStatus(YYSession);
 
4788
              new(std::nothrow) statement::ShowEngineStatus(YYSession, $2);
4751
4789
            if (Lex->statement == NULL)
4752
4790
              DRIZZLE_YYABORT;
4753
4791
          }
4756
4794
            LEX *lex= Lex;
4757
4795
            lex->sql_command= SQLCOM_SHOW_FIELDS;
4758
4796
            lex->statement=
4759
 
              new(std::nothrow) statement::Select(SQLCOM_SHOW_FIELDS, YYSession);
 
4797
              new(std::nothrow) statement::Select(YYSession);
4760
4798
            if (lex->statement == NULL)
4761
4799
              DRIZZLE_YYABORT;
4762
4800
            if ($5)
4768
4806
          {
4769
4807
            LEX *lex= Lex;
4770
4808
            lex->sql_command= SQLCOM_SHOW_KEYS;
4771
 
            lex->statement= new(std::nothrow) statement::Select(SQLCOM_SHOW_KEYS,
4772
 
                                                            YYSession);
 
4809
            lex->statement= new(std::nothrow) statement::Select(YYSession);
4773
4810
            if (lex->statement == NULL)
4774
4811
              DRIZZLE_YYABORT;
4775
4812
            if ($4)
4781
4818
          { 
4782
4819
            (void) create_select_for_variable("warning_count"); 
4783
4820
            LEX *lex= Lex;
4784
 
            lex->statement= new(std::nothrow) statement::Select(SQLCOM_SELECT,
4785
 
                                                            YYSession);
 
4821
            lex->statement= new(std::nothrow) statement::Select(YYSession);
4786
4822
            if (lex->statement == NULL)
4787
4823
              DRIZZLE_YYABORT;
4788
4824
          }
4790
4826
          { 
4791
4827
            (void) create_select_for_variable("error_count"); 
4792
4828
            LEX *lex= Lex;
4793
 
            lex->statement= new(std::nothrow) statement::Select(SQLCOM_SELECT,
4794
 
                                                            YYSession);
 
4829
            lex->statement= new(std::nothrow) statement::Select(YYSession);
4795
4830
            if (lex->statement == NULL)
4796
4831
              DRIZZLE_YYABORT;
4797
4832
          }
4835
4870
            LEX *lex= Lex;
4836
4871
            lex->sql_command= SQLCOM_SHOW_VARIABLES;
4837
4872
            lex->statement=
4838
 
              new(std::nothrow) statement::Select(SQLCOM_SHOW_VARIABLES, 
4839
 
                                                YYSession);
 
4873
              new(std::nothrow) statement::Select(YYSession);
4840
4874
            if (lex->statement == NULL)
4841
4875
              DRIZZLE_YYABORT;
4842
4876
            lex->option_type= $1;
4846
4880
        | CREATE DATABASE opt_if_not_exists ident
4847
4881
          {
4848
4882
            Lex->sql_command=SQLCOM_SHOW_CREATE_DB;
4849
 
            Lex->statement= new(std::nothrow) statement::ShowCreateSchema(YYSession);
 
4883
            statement::ShowCreateSchema *statement= new(std::nothrow) statement::ShowCreateSchema(YYSession);
 
4884
            Lex->statement= statement;
4850
4885
            if (Lex->statement == NULL)
4851
4886
              DRIZZLE_YYABORT;
4852
 
            Lex->create_info.options=$3;
 
4887
            statement->create_info.options=$3;
4853
4888
            Lex->name= $4;
4854
4889
          }
4855
4890
        | CREATE TABLE_SYM table_ident
4869
4904
        ;
4870
4905
 
4871
4906
opt_full:
4872
 
          /* empty */ { Lex->verbose=0; }
4873
 
        | FULL        { Lex->verbose=1; }
 
4907
          /* empty */ { Lex->verbose= false; }
 
4908
        | FULL        { Lex->verbose= true; }
4874
4909
        ;
4875
4910
 
4876
4911
from_or_in:
4904
4939
            mysql_init_select(lex);
4905
4940
            lex->current_select->parsing_place= SELECT_LIST;
4906
4941
            lex->sql_command= SQLCOM_SHOW_FIELDS;
4907
 
            lex->statement= new(std::nothrow) statement::Select(SQLCOM_SHOW_FIELDS,
4908
 
                                                            YYSession);
 
4942
            lex->statement= new(std::nothrow) statement::Select(YYSession);
4909
4943
            if (lex->statement == NULL)
4910
4944
              DRIZZLE_YYABORT;
4911
4945
            lex->select_lex.db= 0;
5025
5059
          {
5026
5060
            Session *session= YYSession;
5027
5061
            LEX *lex= session->lex;
 
5062
 
 
5063
            lex->sql_command= SQLCOM_LOAD;
 
5064
            statement::Load *statement= new(std::nothrow) statement::Load(YYSession);
 
5065
            lex->statement= statement;
 
5066
            if (lex->statement == NULL)
 
5067
              DRIZZLE_YYABORT;
 
5068
 
5028
5069
            Lex_input_stream *lip= session->m_lip;
5029
 
 
5030
 
            lex->fname_start= lip->get_ptr();
 
5070
            statement->fname_start= lip->get_ptr();
5031
5071
          }
5032
5072
          load_data_lock INFILE TEXT_STRING_filesystem
5033
5073
          {
5034
5074
            LEX *lex=Lex;
5035
 
            lex->sql_command= SQLCOM_LOAD;
5036
 
            lex->statement= new(std::nothrow) statement::Load(YYSession);
5037
 
            if (lex->statement == NULL)
5038
 
              DRIZZLE_YYABORT;
5039
5075
            lex->lock_option= $4;
5040
5076
            lex->duplicates= DUP_ERROR;
5041
5077
            lex->ignore= 0;
5045
5081
          opt_duplicate INTO
5046
5082
          {
5047
5083
            Session *session= YYSession;
5048
 
            LEX *lex= session->lex;
5049
5084
            Lex_input_stream *lip= session->m_lip;
5050
 
            lex->fname_end= lip->get_ptr();
 
5085
            ((statement::Load *)Lex->statement)->fname_end= lip->get_ptr();
5051
5086
          }
5052
5087
          TABLE_SYM table_ident
5053
5088
          {
5712
5747
          {
5713
5748
            LEX *lex=Lex;
5714
5749
            lex->sql_command= SQLCOM_SET_OPTION;
5715
 
            lex->statement= new(std::nothrow) statement::SetOption(YYSession);
 
5750
            statement::SetOption *statement= new(std::nothrow) statement::SetOption(YYSession);
 
5751
            lex->statement= statement;
5716
5752
            if (lex->statement == NULL)
5717
5753
              DRIZZLE_YYABORT;
5718
5754
            mysql_init_select(lex);
5719
5755
            lex->option_type=OPT_SESSION;
5720
5756
            lex->var_list.empty();
5721
 
            lex->one_shot_set= 0;
5722
5757
          }
5723
5758
          option_value_list
5724
5759
          {}
5751
5786
 
5752
5787
option_type2:
5753
5788
          /* empty */ { $$= OPT_DEFAULT; }
5754
 
        | ONE_SHOT_SYM { Lex->one_shot_set= 1; $$= OPT_SESSION; }
 
5789
        | ONE_SHOT_SYM { ((statement::SetOption *)Lex->statement)->one_shot_set= true; $$= OPT_SESSION; }
5755
5790
        ;
5756
5791
 
5757
5792
opt_var_type:
5867
5902
            lex->statement= new(std::nothrow) statement::StartTransaction(YYSession);
5868
5903
            if (lex->statement == NULL)
5869
5904
              DRIZZLE_YYABORT;
5870
 
            lex->start_transaction_opt= 0;
5871
5905
          }
5872
5906
          opt_work {}
5873
5907
        ;
5901
5935
          {
5902
5936
            LEX *lex=Lex;
5903
5937
            lex->sql_command= SQLCOM_COMMIT;
5904
 
            lex->statement= new(std::nothrow) statement::Commit(YYSession);
 
5938
            statement::Commit *statement= new(std::nothrow) statement::Commit(YYSession);
 
5939
            lex->statement= statement;
5905
5940
            if (lex->statement == NULL)
5906
5941
              DRIZZLE_YYABORT;
5907
 
            lex->tx_chain= $3; 
5908
 
            lex->tx_release= $4;
 
5942
            statement->tx_chain= $3; 
 
5943
            statement->tx_release= $4;
5909
5944
          }
5910
5945
        ;
5911
5946
 
5914
5949
          {
5915
5950
            LEX *lex=Lex;
5916
5951
            lex->sql_command= SQLCOM_ROLLBACK;
5917
 
            lex->statement= new(std::nothrow) statement::Rollback(YYSession);
 
5952
            statement::Rollback *statement= new(std::nothrow) statement::Rollback(YYSession);
 
5953
            lex->statement= statement;
5918
5954
            if (lex->statement == NULL)
5919
5955
              DRIZZLE_YYABORT;
5920
 
            lex->tx_chain= $3; 
5921
 
            lex->tx_release= $4;
 
5956
            statement->tx_chain= $3; 
 
5957
            statement->tx_release= $4;
5922
5958
          }
5923
5959
        | ROLLBACK_SYM opt_work
5924
5960
          TO_SYM opt_savepoint ident