~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_yacc.yy

  • Committer: Padraig O'Sullivan
  • Date: 2009-08-26 03:17:31 UTC
  • mfrom: (1124 staging)
  • mto: This revision was merged to the branch mainline in revision 1139.
  • Revision ID: osullivan.padraig@gmail.com-20090826031731-at2as3ledixngra3
MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
#include <drizzled/function/get_system_var.h>
88
88
#include <mysys/thr_lock.h>
89
89
#include <drizzled/message/table.pb.h>
90
 
#include <drizzled/command.h>
91
 
#include <drizzled/command/checksum.h>
92
 
#include <drizzled/command/commit.h>
93
 
#include <drizzled/command/empty_query.h>
94
 
#include <drizzled/command/load.h>
95
 
#include <drizzled/command/rollback.h>
96
 
#include <drizzled/command/select.h>
97
 
#include <drizzled/command/show_create.h>
98
 
#include <drizzled/command/show_engine_status.h>
99
 
#include <drizzled/command/show_errors.h>
100
 
#include <drizzled/command/show_processlist.h>
101
 
#include <drizzled/command/show_status.h>
102
 
#include <drizzled/command/show_warnings.h>
 
90
#include <drizzled/statement.h>
 
91
#include <drizzled/statement/alter_schema.h>
 
92
#include <drizzled/statement/analyze.h>
 
93
#include <drizzled/statement/change_schema.h>
 
94
#include <drizzled/statement/check.h>
 
95
#include <drizzled/statement/checksum.h>
 
96
#include <drizzled/statement/commit.h>
 
97
#include <drizzled/statement/create_schema.h>
 
98
#include <drizzled/statement/delete.h>
 
99
#include <drizzled/statement/drop_schema.h>
 
100
#include <drizzled/statement/drop_table.h>
 
101
#include <drizzled/statement/empty_query.h>
 
102
#include <drizzled/statement/flush.h>
 
103
#include <drizzled/statement/kill.h>
 
104
#include <drizzled/statement/load.h>
 
105
#include <drizzled/statement/optimize.h>
 
106
#include <drizzled/statement/rollback.h>
 
107
#include <drizzled/statement/select.h>
 
108
#include <drizzled/statement/set_option.h>
 
109
#include <drizzled/statement/show_create.h>
 
110
#include <drizzled/statement/show_create_schema.h>
 
111
#include <drizzled/statement/show_engine_status.h>
 
112
#include <drizzled/statement/show_errors.h>
 
113
#include <drizzled/statement/show_processlist.h>
 
114
#include <drizzled/statement/show_status.h>
 
115
#include <drizzled/statement/show_warnings.h>
 
116
#include <drizzled/statement/truncate.h>
 
117
#include <drizzled/statement/unlock_tables.h>
 
118
#include <drizzled/statement/update.h>
103
119
 
104
120
using namespace drizzled;
105
121
 
368
384
  List<String> *string_list;
369
385
  String *string;
370
386
  Key_part_spec *key_part;
371
 
  Function_builder *udf;
 
387
  const ::drizzled::plugin::Function *udf;
372
388
  TableList *table_list;
373
389
  struct sys_var_with_base variable;
374
390
  enum enum_var_type var_type;
380
396
  enum ha_rkey_function ha_rkey_mode;
381
397
  enum enum_tx_isolation tx_isolation;
382
398
  enum Cast_target cast_type;
383
 
  enum ha_choice choice;
384
399
  const CHARSET_INFO *charset;
385
400
  thr_lock_type lock_type;
386
401
  interval_type interval, interval_time_st;
520
535
%token  DECIMAL_SYM                   /* SQL-2003-R */
521
536
%token  DECLARE_SYM                   /* SQL-2003-R */
522
537
%token  DEFAULT                       /* SQL-2003-R */
523
 
%token  DELAY_KEY_WRITE_SYM
524
538
%token  DELETE_SYM                    /* SQL-2003-R */
525
539
%token  DESC                          /* SQL-2003-N */
526
540
%token  DESCRIBE                      /* SQL-2003-R */
527
541
%token  DETERMINISTIC_SYM             /* SQL-2003-R */
528
 
%token  DIRECTORY_SYM
529
542
%token  DISABLE_SYM
530
543
%token  DISCARD
531
544
%token  DISTINCT                      /* SQL-2003-R */
694
707
%token  OUTER
695
708
%token  OUTFILE
696
709
%token  OUT_SYM                       /* SQL-2003-R */
697
 
%token  PACK_KEYS_SYM
698
710
%token  PAGE_SYM
699
 
%token  PAGE_CHECKSUM_SYM
700
711
%token  PARAM_MARKER
701
712
%token  PARTIAL                       /* SQL-2003-N */
702
713
%token  PHASE_SYM
795
806
%token  SUBJECT_SYM
796
807
%token  SUBSTRING                     /* SQL-2003-N */
797
808
%token  SUM_SYM                       /* SQL-2003-N */
798
 
%token  SUPER_SYM
799
809
%token  SUSPEND_SYM
800
810
%token  SWAPS_SYM
801
811
%token  SWITCHES_SYM
804
814
%token  TABLESPACE
805
815
%token  TABLE_REF_PRIORITY
806
816
%token  TABLE_SYM                     /* SQL-2003-R */
807
 
%token  TABLE_CHECKSUM_SYM
808
817
%token  TEMPORARY_SYM                 /* SQL-2003-N */
809
818
%token  TEMPTABLE_SYM
810
819
%token  TERMINATED
922
931
%type <ulonglong_number>
923
932
        ulonglong_num
924
933
 
925
 
%type <choice> choice
926
 
 
927
934
%type <lock_type>
928
935
        load_data_lock
929
936
 
1075
1082
            else
1076
1083
            {
1077
1084
              session->lex->sql_command= SQLCOM_EMPTY_QUERY;
1078
 
              session->lex->command= 
1079
 
                new(std::nothrow) command::EmptyQuery(SQLCOM_EMPTY_QUERY,
1080
 
                                                      YYSession);
1081
 
              if (session->lex->command == NULL)
 
1085
              session->lex->statement= 
 
1086
                new(std::nothrow) statement::EmptyQuery(YYSession);
 
1087
              if (session->lex->statement == NULL)
1082
1088
                DRIZZLE_YYABORT;
1083
1089
            }
1084
1090
          }
1142
1148
            lex->create_info.default_table_charset= NULL;
1143
1149
            lex->name.str= 0;
1144
1150
 
1145
 
            drizzled::message::Table *proto=
1146
 
              lex->create_table_proto= new drizzled::message::Table();
 
1151
            message::Table *proto=
 
1152
              lex->create_table_proto= new(std::nothrow) message::Table();
 
1153
 
 
1154
            if (lex->create_table_proto == NULL)
 
1155
              DRIZZLE_YYABORT;
1147
1156
            
1148
1157
            proto->set_name($5->table.str);
1149
1158
            if($2 & HA_LEX_CREATE_TMP_TABLE)
1150
 
              proto->set_type(drizzled::message::Table::TEMPORARY);
 
1159
              proto->set_type(message::Table::TEMPORARY);
1151
1160
            else
1152
 
              proto->set_type(drizzled::message::Table::STANDARD);
 
1161
              proto->set_type(message::Table::STANDARD);
1153
1162
 
1154
1163
            {
1155
 
              drizzled::message::Table::StorageEngine *protoengine;
 
1164
              message::Table::StorageEngine *protoengine;
1156
1165
              protoengine= proto->mutable_engine();
1157
1166
              StorageEngine *engine= ha_default_storage_engine(session);
1158
1167
 
1179
1188
            lex->alter_info.build_method= $2;
1180
1189
            lex->col_list.empty();
1181
1190
            lex->change=NULL;
 
1191
 
 
1192
            lex->create_table_proto= new message::Table();
1182
1193
          }
1183
1194
          '(' key_list ')' key_options
1184
1195
          {
1198
1209
          {
1199
1210
            LEX *lex=Lex;
1200
1211
            lex->sql_command=SQLCOM_CREATE_DB;
 
1212
            lex->statement= new(std::nothrow) statement::CreateSchema(YYSession);
 
1213
            if (lex->statement == NULL)
 
1214
              DRIZZLE_YYABORT;
1201
1215
            lex->name= $4;
1202
1216
            lex->create_info.options=$3;
1203
1217
          }
1337
1351
            Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE;
1338
1352
 
1339
1353
            {
1340
 
              drizzled::message::Table::StorageEngine *protoengine;
 
1354
              message::Table::StorageEngine *protoengine;
1341
1355
              protoengine= Lex->create_table_proto->mutable_engine();
1342
1356
 
1343
1357
              protoengine->set_name($3->getName());
1344
1358
            }
1345
1359
          }
1346
 
        | MAX_ROWS opt_equal ulonglong_num
1347
 
          {
1348
 
            Lex->create_info.max_rows= $3;
1349
 
            Lex->create_info.used_fields|= HA_CREATE_USED_MAX_ROWS;
1350
 
          }
1351
 
        | MIN_ROWS opt_equal ulonglong_num
1352
 
          {
1353
 
            Lex->create_info.min_rows= $3;
1354
 
            Lex->create_info.used_fields|= HA_CREATE_USED_MIN_ROWS;
1355
 
          }
1356
 
        | AVG_ROW_LENGTH opt_equal ulong_num
1357
 
          {
1358
 
            Lex->create_info.avg_row_length=$3;
1359
 
            Lex->create_info.used_fields|= HA_CREATE_USED_AVG_ROW_LENGTH;
1360
 
          }
1361
1360
        | BLOCK_SIZE_SYM opt_equal ulong_num    
1362
1361
          { 
1363
1362
            Lex->create_info.block_size= $3; 
1365
1364
          }
1366
1365
        | COMMENT_SYM opt_equal TEXT_STRING_sys
1367
1366
          {
1368
 
            Lex->create_info.comment=$3;
1369
 
            Lex->create_info.used_fields|= HA_CREATE_USED_COMMENT;
 
1367
            message::Table::TableOptions *tableopts;
 
1368
            tableopts= Lex->create_table_proto->mutable_options();
 
1369
 
 
1370
            tableopts->set_comment($3.str);
1370
1371
          }
1371
1372
        | AUTO_INC opt_equal ulonglong_num
1372
1373
          {
1373
1374
            Lex->create_info.auto_increment_value=$3;
1374
1375
            Lex->create_info.used_fields|= HA_CREATE_USED_AUTO;
1375
1376
          }
1376
 
        | PACK_KEYS_SYM opt_equal ulong_num
1377
 
          {
1378
 
            switch($3) {
1379
 
            case 0:
1380
 
                Lex->create_info.table_options|= HA_OPTION_NO_PACK_KEYS;
1381
 
                break;
1382
 
            case 1:
1383
 
                Lex->create_info.table_options|= HA_OPTION_PACK_KEYS;
1384
 
                break;
1385
 
            default:
1386
 
                my_parse_error(ER(ER_SYNTAX_ERROR));
1387
 
                DRIZZLE_YYABORT;
1388
 
            }
1389
 
            Lex->create_info.used_fields|= HA_CREATE_USED_PACK_KEYS;
1390
 
          }
1391
 
        | PACK_KEYS_SYM opt_equal DEFAULT
1392
 
          {
1393
 
            Lex->create_info.table_options&=
1394
 
              ~(HA_OPTION_PACK_KEYS | HA_OPTION_NO_PACK_KEYS);
1395
 
            Lex->create_info.used_fields|= HA_CREATE_USED_PACK_KEYS;
1396
 
          }
1397
 
        | CHECKSUM_SYM opt_equal ulong_num
1398
 
          {
1399
 
            Lex->create_info.table_options|= $3 ? HA_OPTION_CHECKSUM : HA_OPTION_NO_CHECKSUM;
1400
 
            Lex->create_info.used_fields|= HA_CREATE_USED_CHECKSUM;
1401
 
          }
1402
 
        | TABLE_CHECKSUM_SYM opt_equal ulong_num
1403
 
          {
1404
 
             Lex->create_info.table_options|= $3 ? HA_OPTION_CHECKSUM : HA_OPTION_NO_CHECKSUM;
1405
 
             Lex->create_info.used_fields|= HA_CREATE_USED_CHECKSUM;
1406
 
          }
1407
 
        | PAGE_CHECKSUM_SYM opt_equal choice
1408
 
          {
1409
 
            Lex->create_info.used_fields|= HA_CREATE_USED_PAGE_CHECKSUM;
1410
 
            Lex->create_info.page_checksum= $3;
1411
 
          }
1412
 
        | DELAY_KEY_WRITE_SYM opt_equal ulong_num
1413
 
          {
1414
 
            Lex->create_info.table_options|= $3 ? HA_OPTION_DELAY_KEY_WRITE : HA_OPTION_NO_DELAY_KEY_WRITE;
1415
 
            Lex->create_info.used_fields|= HA_CREATE_USED_DELAY_KEY_WRITE;
1416
 
          }
1417
1377
        | ROW_FORMAT_SYM opt_equal row_types
1418
1378
          {
1419
1379
            Lex->create_info.row_type= $3;
1421
1381
            Lex->alter_info.flags.set(ALTER_ROW_FORMAT);
1422
1382
          }
1423
1383
        | default_collation
1424
 
        | DATA_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys
1425
 
          {
1426
 
            Lex->create_info.data_file_name= $4.str;
1427
 
            Lex->create_info.used_fields|= HA_CREATE_USED_DATADIR;
1428
 
          }
1429
 
        | INDEX_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys
1430
 
          {
1431
 
            Lex->create_info.index_file_name= $4.str;
1432
 
            Lex->create_info.used_fields|= HA_CREATE_USED_INDEXDIR;
1433
 
          }
1434
 
        | CONNECTION_SYM opt_equal TEXT_STRING_sys
1435
 
          {
1436
 
            Lex->create_info.connect_string.str= $3.str;
1437
 
            Lex->create_info.connect_string.length= $3.length;
1438
 
            Lex->create_info.used_fields|= HA_CREATE_USED_CONNECTION;
1439
 
          }
1440
1384
        | KEY_BLOCK_SIZE opt_equal ulong_num
1441
1385
          {
1442
1386
            Lex->create_info.used_fields|= HA_CREATE_USED_KEY_BLOCK_SIZE;
2126
2070
            lex->alter_info.reset();
2127
2071
            lex->alter_info.build_method= $2;
2128
2072
 
2129
 
            lex->create_table_proto= new drizzled::message::Table();
 
2073
            lex->create_table_proto= new message::Table();
2130
2074
          }
2131
2075
          alter_commands
2132
2076
          {}
2139
2083
          {
2140
2084
            LEX *lex=Lex;
2141
2085
            lex->sql_command=SQLCOM_ALTER_DB;
 
2086
            lex->statement= new(std::nothrow) statement::AlterSchema(YYSession);
 
2087
            if (lex->statement == NULL)
 
2088
              DRIZZLE_YYABORT;
2142
2089
            lex->name= $3;
2143
2090
            if (lex->name.str == NULL &&
2144
2091
                lex->copy_db_to(&lex->name.str, &lex->name.length))
2376
2323
          {
2377
2324
            LEX *lex=Lex;
2378
2325
            lex->sql_command = SQLCOM_CHECKSUM;
2379
 
            lex->command= new(std::nothrow) command::Checksum(SQLCOM_CHECKSUM,
2380
 
                                                              YYSession);
2381
 
            if (lex->command == NULL)
 
2326
            lex->statement= new(std::nothrow) statement::Checksum(YYSession);
 
2327
            if (lex->statement == NULL)
2382
2328
              DRIZZLE_YYABORT;
2383
2329
          }
2384
2330
          table_list opt_checksum_type
2397
2343
          {
2398
2344
            LEX *lex=Lex;
2399
2345
            lex->sql_command = SQLCOM_ANALYZE;
 
2346
            lex->statement= new(std::nothrow) statement::Analyze(YYSession);
 
2347
            if (lex->statement == NULL)
 
2348
              DRIZZLE_YYABORT;
2400
2349
            lex->check_opt.init();
2401
2350
          }
2402
2351
          table_list
2409
2358
            LEX *lex=Lex;
2410
2359
 
2411
2360
            lex->sql_command = SQLCOM_CHECK;
 
2361
            lex->statement= new(std::nothrow) statement::Check(YYSession);
 
2362
            if (lex->statement == NULL)
 
2363
              DRIZZLE_YYABORT;
2412
2364
            lex->check_opt.init();
2413
2365
          }
2414
2366
          table_list opt_mi_check_type
2438
2390
          {
2439
2391
            LEX *lex=Lex;
2440
2392
            lex->sql_command = SQLCOM_OPTIMIZE;
 
2393
            lex->statement= new(std::nothrow) statement::Optimize(YYSession);
 
2394
            if (lex->statement == NULL)
 
2395
              DRIZZLE_YYABORT;
2441
2396
            lex->check_opt.init();
2442
2397
          }
2443
2398
          table_list
2481
2436
          {
2482
2437
            LEX *lex= Lex;
2483
2438
            lex->sql_command= SQLCOM_SELECT;
2484
 
            lex->command= new(std::nothrow) command::Select(SQLCOM_SELECT,
 
2439
            lex->statement= new(std::nothrow) statement::Select(SQLCOM_SELECT,
2485
2440
                                                            YYSession);
2486
 
            if (lex->command == NULL)
 
2441
            if (lex->statement == NULL)
2487
2442
              DRIZZLE_YYABORT;
2488
2443
          }
2489
2444
        ;
3192
3147
function_call_generic:
3193
3148
          IDENT_sys '('
3194
3149
          {
3195
 
            Function_builder *udf= 0;
3196
 
            udf= find_udf($1.str, $1.length);
 
3150
            plugin::Registry &plugins= plugin::Registry::singleton();
 
3151
            const plugin::Function *udf= plugins.function.get($1.str, $1.length);
3197
3152
 
3198
 
            /* Temporary placing the result of find_udf in $3 */
 
3153
            /* Temporary placing the result of getFunction in $3 */
3199
3154
            $<udf>$= udf;
3200
3155
          }
3201
3156
          opt_udf_expr_list ')'
3220
3175
            }
3221
3176
            else
3222
3177
            {
3223
 
              /* Retrieving the result of find_udf */
3224
 
              Function_builder *udf= $<udf>3;
 
3178
              /* Retrieving the result of slot::Function::get */
 
3179
              const plugin::Function *udf= $<udf>3;
3225
3180
              if (udf)
3226
3181
              {
3227
3182
                item= Create_udf_func::s_singleton.create(session, udf, $4);
4277
4232
        | FLOAT_NUM
4278
4233
        ;
4279
4234
 
4280
 
choice:
4281
 
        ulong_num { $$= $1 != 0 ? HA_CHOICE_YES : HA_CHOICE_NO; }
4282
 
        | DEFAULT { $$= HA_CHOICE_UNDEF; }
4283
 
        ;
4284
 
 
4285
4235
select_var_list_init:
4286
4236
          {
4287
4237
            LEX *lex=Lex;
4351
4301
          {
4352
4302
            LEX *lex=Lex;
4353
4303
            lex->sql_command = SQLCOM_DROP_TABLE;
 
4304
            lex->statement= new(std::nothrow) statement::DropTable(YYSession);
 
4305
            if (lex->statement == NULL)
 
4306
              DRIZZLE_YYABORT;
4354
4307
            lex->drop_temporary= $2;
4355
4308
            lex->drop_if_exists= $4;
4356
4309
          }
4366
4319
            if (!lex->current_select->add_table_to_list(lex->session, $6, NULL,
4367
4320
                                                        TL_OPTION_UPDATING))
4368
4321
              DRIZZLE_YYABORT;
 
4322
 
 
4323
            lex->create_table_proto= new message::Table();
4369
4324
          }
4370
4325
        | DROP DATABASE if_exists ident
4371
4326
          {
4372
4327
            LEX *lex=Lex;
4373
4328
            lex->sql_command= SQLCOM_DROP_DB;
 
4329
            lex->statement= new(std::nothrow) statement::DropSchema(YYSession);
 
4330
            if (lex->statement == NULL)
 
4331
              DRIZZLE_YYABORT;
4374
4332
            lex->drop_if_exists=$3;
4375
4333
            lex->name= $4;
4376
4334
          }
4561
4519
            LEX *lex= Lex;
4562
4520
            mysql_init_select(lex);
4563
4521
            lex->sql_command= SQLCOM_UPDATE;
 
4522
            lex->statement= new(std::nothrow) statement::Update(YYSession);
 
4523
            if (lex->statement == NULL)
 
4524
              DRIZZLE_YYABORT;
4564
4525
            lex->lock_option= TL_UNLOCK; /* Will be set later */
4565
4526
            lex->duplicates= DUP_ERROR; 
4566
4527
            if (!lex->select_lex.add_table_to_list(YYSession, $3, NULL,0))
4621
4582
          {
4622
4583
            LEX *lex= Lex;
4623
4584
            lex->sql_command= SQLCOM_DELETE;
 
4585
            lex->statement= new(std::nothrow) statement::Delete(YYSession);
 
4586
            if (lex->statement == NULL)
 
4587
              DRIZZLE_YYABORT;
4624
4588
            mysql_init_select(lex);
4625
4589
            lex->lock_option= TL_WRITE_DEFAULT;
4626
4590
            lex->ignore= 0;
4655
4619
          {
4656
4620
            LEX* lex= Lex;
4657
4621
            lex->sql_command= SQLCOM_TRUNCATE;
 
4622
            lex->statement= new(std::nothrow) statement::Truncate(YYSession);
 
4623
            if (lex->statement == NULL)
 
4624
              DRIZZLE_YYABORT;
4658
4625
            lex->select_lex.options= 0;
4659
4626
            lex->select_lex.init_order();
4660
4627
          }
4686
4653
           {
4687
4654
             LEX *lex= Lex;
4688
4655
             lex->sql_command= SQLCOM_SHOW_DATABASES;
4689
 
             lex->command=
4690
 
               new(std::nothrow) command::Select(SQLCOM_SHOW_DATABASES, 
 
4656
             lex->statement=
 
4657
               new(std::nothrow) statement::Select(SQLCOM_SHOW_DATABASES, 
4691
4658
                                                 YYSession);
4692
 
             if (lex->command == NULL)
 
4659
             if (lex->statement == NULL)
4693
4660
               DRIZZLE_YYABORT;
4694
4661
             if (prepare_schema_table(YYSession, lex, 0, "SCHEMATA"))
4695
4662
               DRIZZLE_YYABORT;
4698
4665
           {
4699
4666
             LEX *lex= Lex;
4700
4667
             lex->sql_command= SQLCOM_SHOW_TABLES;
4701
 
             lex->command=
4702
 
               new(std::nothrow) command::Select(SQLCOM_SHOW_TABLES,
 
4668
             lex->statement=
 
4669
               new(std::nothrow) statement::Select(SQLCOM_SHOW_TABLES,
4703
4670
                                                 YYSession);
4704
 
             if (lex->command == NULL)
 
4671
             if (lex->statement == NULL)
4705
4672
               DRIZZLE_YYABORT;
4706
4673
             lex->select_lex.db= $3;
4707
4674
             if (prepare_schema_table(YYSession, lex, 0, "TABLE_NAMES"))
4711
4678
           {
4712
4679
             LEX *lex= Lex;
4713
4680
             lex->sql_command= SQLCOM_SHOW_TABLE_STATUS;
4714
 
             lex->command=
4715
 
               new(std::nothrow) command::Select(SQLCOM_SHOW_TABLE_STATUS,
 
4681
             lex->statement=
 
4682
               new(std::nothrow) statement::Select(SQLCOM_SHOW_TABLE_STATUS,
4716
4683
                                                 YYSession);
4717
 
             if (lex->command == NULL)
 
4684
             if (lex->statement == NULL)
4718
4685
               DRIZZLE_YYABORT;
4719
4686
             lex->select_lex.db= $3;
4720
4687
             if (prepare_schema_table(YYSession, lex, 0, "TABLES"))
4724
4691
          {
4725
4692
            LEX *lex= Lex;
4726
4693
            lex->sql_command= SQLCOM_SHOW_OPEN_TABLES;
4727
 
            lex->command=
4728
 
              new(std::nothrow) command::Select(SQLCOM_SHOW_OPEN_TABLES,
 
4694
            lex->statement=
 
4695
              new(std::nothrow) statement::Select(SQLCOM_SHOW_OPEN_TABLES,
4729
4696
                                                YYSession);
4730
 
            if (lex->command == NULL)
 
4697
            if (lex->statement == NULL)
4731
4698
              DRIZZLE_YYABORT;
4732
4699
            lex->select_lex.db= $3;
4733
4700
            if (prepare_schema_table(YYSession, lex, 0, "OPEN_TABLES"))
4737
4704
          { 
4738
4705
            Lex->show_engine= $2; 
4739
4706
            Lex->sql_command= SQLCOM_SHOW_ENGINE_STATUS;
4740
 
            Lex->command= 
4741
 
              new(std::nothrow) command::ShowEngineStatus(SQLCOM_SHOW_ENGINE_STATUS,
4742
 
                                                          YYSession);
4743
 
            if (Lex->command == NULL)
 
4707
            Lex->statement= 
 
4708
              new(std::nothrow) statement::ShowEngineStatus(YYSession);
 
4709
            if (Lex->statement == NULL)
4744
4710
              DRIZZLE_YYABORT;
4745
4711
          }
4746
4712
        | opt_full COLUMNS from_or_in table_ident opt_db show_wild
4747
4713
          {
4748
4714
            LEX *lex= Lex;
4749
4715
            lex->sql_command= SQLCOM_SHOW_FIELDS;
4750
 
            lex->command=
4751
 
              new(std::nothrow) command::Select(SQLCOM_SHOW_FIELDS, YYSession);
4752
 
            if (lex->command == NULL)
 
4716
            lex->statement=
 
4717
              new(std::nothrow) statement::Select(SQLCOM_SHOW_FIELDS, YYSession);
 
4718
            if (lex->statement == NULL)
4753
4719
              DRIZZLE_YYABORT;
4754
4720
            if ($5)
4755
4721
              $4->change_db($5);
4760
4726
          {
4761
4727
            LEX *lex= Lex;
4762
4728
            lex->sql_command= SQLCOM_SHOW_KEYS;
4763
 
            lex->command= new(std::nothrow) command::Select(SQLCOM_SHOW_KEYS,
 
4729
            lex->statement= new(std::nothrow) statement::Select(SQLCOM_SHOW_KEYS,
4764
4730
                                                            YYSession);
4765
 
            if (lex->command == NULL)
 
4731
            if (lex->statement == NULL)
4766
4732
              DRIZZLE_YYABORT;
4767
4733
            if ($4)
4768
4734
              $3->change_db($4);
4773
4739
          { 
4774
4740
            (void) create_select_for_variable("warning_count"); 
4775
4741
            LEX *lex= Lex;
4776
 
            lex->command= new(std::nothrow) command::Select(SQLCOM_SELECT,
 
4742
            lex->statement= new(std::nothrow) statement::Select(SQLCOM_SELECT,
4777
4743
                                                            YYSession);
4778
 
            if (lex->command == NULL)
 
4744
            if (lex->statement == NULL)
4779
4745
              DRIZZLE_YYABORT;
4780
4746
          }
4781
4747
        | COUNT_SYM '(' '*' ')' ERRORS
4782
4748
          { 
4783
4749
            (void) create_select_for_variable("error_count"); 
4784
4750
            LEX *lex= Lex;
4785
 
            lex->command= new(std::nothrow) command::Select(SQLCOM_SELECT,
 
4751
            lex->statement= new(std::nothrow) statement::Select(SQLCOM_SELECT,
4786
4752
                                                            YYSession);
4787
 
            if (lex->command == NULL)
 
4753
            if (lex->statement == NULL)
4788
4754
              DRIZZLE_YYABORT;
4789
4755
          }
4790
4756
        | WARNINGS opt_limit_clause_init
4791
4757
          { 
4792
4758
            Lex->sql_command = SQLCOM_SHOW_WARNS;
4793
 
            Lex->command= new(std::nothrow) command::ShowWarnings(SQLCOM_SHOW_WARNS,
4794
 
                                                                  YYSession);
4795
 
            if (Lex->command == NULL)
 
4759
            Lex->statement= new(std::nothrow) statement::ShowWarnings(YYSession);
 
4760
            if (Lex->statement == NULL)
4796
4761
              DRIZZLE_YYABORT;
4797
4762
          }
4798
4763
        | ERRORS opt_limit_clause_init
4799
4764
          { 
4800
4765
            Lex->sql_command = SQLCOM_SHOW_ERRORS;
4801
 
            Lex->command= new(std::nothrow) command::ShowErrors(SQLCOM_SHOW_ERRORS,
4802
 
                                                                YYSession);
4803
 
            if (Lex->command == NULL)
 
4766
            Lex->statement= new(std::nothrow) statement::ShowErrors(YYSession);
 
4767
            if (Lex->statement == NULL)
4804
4768
              DRIZZLE_YYABORT;
4805
4769
          }
4806
4770
        | opt_var_type STATUS_SYM show_wild
4807
4771
          {
4808
4772
            LEX *lex= Lex;
4809
4773
            lex->sql_command= SQLCOM_SHOW_STATUS;
4810
 
            lex->command=
4811
 
              new(std::nothrow) command::ShowStatus(SQLCOM_SHOW_STATUS,
4812
 
                                                    YYSession,
 
4774
            lex->statement=
 
4775
              new(std::nothrow) statement::ShowStatus(YYSession,
4813
4776
                                                    &LOCK_status);
4814
 
            if (lex->command == NULL)
 
4777
            if (lex->statement == NULL)
4815
4778
              DRIZZLE_YYABORT;
4816
4779
            lex->option_type= $1;
4817
4780
            if (prepare_schema_table(YYSession, lex, 0, "STATUS"))
4820
4783
        | opt_full PROCESSLIST_SYM
4821
4784
          { 
4822
4785
            Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;
4823
 
            Lex->command= 
4824
 
              new(std::nothrow) command::ShowProcesslist(SQLCOM_SHOW_PROCESSLIST,
4825
 
                                                         YYSession);
4826
 
            if (Lex->command == NULL)
 
4786
            Lex->statement= 
 
4787
              new(std::nothrow) statement::ShowProcesslist(YYSession);
 
4788
            if (Lex->statement == NULL)
4827
4789
              DRIZZLE_YYABORT;
4828
4790
          }
4829
4791
        | opt_var_type  VARIABLES show_wild
4830
4792
          {
4831
4793
            LEX *lex= Lex;
4832
4794
            lex->sql_command= SQLCOM_SHOW_VARIABLES;
4833
 
            lex->command=
4834
 
              new(std::nothrow) command::Select(SQLCOM_SHOW_VARIABLES, 
 
4795
            lex->statement=
 
4796
              new(std::nothrow) statement::Select(SQLCOM_SHOW_VARIABLES, 
4835
4797
                                                YYSession);
4836
 
            if (lex->command == NULL)
 
4798
            if (lex->statement == NULL)
4837
4799
              DRIZZLE_YYABORT;
4838
4800
            lex->option_type= $1;
4839
4801
            if (prepare_schema_table(YYSession, lex, 0, "VARIABLES"))
4842
4804
        | CREATE DATABASE opt_if_not_exists ident
4843
4805
          {
4844
4806
            Lex->sql_command=SQLCOM_SHOW_CREATE_DB;
 
4807
            Lex->statement= new(std::nothrow) statement::ShowCreateSchema(YYSession);
 
4808
            if (Lex->statement == NULL)
 
4809
              DRIZZLE_YYABORT;
4845
4810
            Lex->create_info.options=$3;
4846
4811
            Lex->name= $4;
4847
4812
          }
4849
4814
          {
4850
4815
            LEX *lex= Lex;
4851
4816
            lex->sql_command = SQLCOM_SHOW_CREATE;
4852
 
            lex->command= new(std::nothrow) command::ShowCreate(SQLCOM_SHOW_CREATE,
4853
 
                                                                YYSession);
4854
 
            if (lex->command == NULL)
 
4817
            lex->statement= new(std::nothrow) statement::ShowCreate(YYSession);
 
4818
            if (lex->statement == NULL)
4855
4819
              DRIZZLE_YYABORT;
4856
4820
            if (!lex->select_lex.add_table_to_list(YYSession, $3, NULL,0))
4857
4821
              DRIZZLE_YYABORT;
4898
4862
            mysql_init_select(lex);
4899
4863
            lex->current_select->parsing_place= SELECT_LIST;
4900
4864
            lex->sql_command= SQLCOM_SHOW_FIELDS;
4901
 
            lex->command= new(std::nothrow) command::Select(SQLCOM_SHOW_FIELDS,
 
4865
            lex->statement= new(std::nothrow) statement::Select(SQLCOM_SHOW_FIELDS,
4902
4866
                                                            YYSession);
4903
 
            if (lex->command == NULL)
 
4867
            if (lex->statement == NULL)
4904
4868
              DRIZZLE_YYABORT;
4905
4869
            lex->select_lex.db= 0;
4906
4870
            lex->verbose= 0;
4946
4910
          {
4947
4911
            LEX *lex=Lex;
4948
4912
            lex->sql_command= SQLCOM_FLUSH;
 
4913
            lex->statement= new(std::nothrow) statement::Flush(YYSession);
 
4914
            if (lex->statement == NULL)
 
4915
              DRIZZLE_YYABORT;
4949
4916
            lex->type= 0;
4950
4917
          }
4951
4918
          flush_options
4983
4950
            lex->value_list.empty();
4984
4951
            lex->value_list.push_front($3);
4985
4952
            lex->sql_command= SQLCOM_KILL;
 
4953
            lex->statement= new(std::nothrow) statement::Kill(YYSession);
 
4954
            if (lex->statement == NULL)
 
4955
              DRIZZLE_YYABORT;
4986
4956
          }
4987
4957
        ;
4988
4958
 
4999
4969
          {
5000
4970
            LEX *lex=Lex;
5001
4971
            lex->sql_command=SQLCOM_CHANGE_DB;
 
4972
            lex->statement= new(std::nothrow) statement::ChangeSchema(YYSession);
 
4973
            if (lex->statement == NULL)
 
4974
              DRIZZLE_YYABORT;
5002
4975
            lex->select_lex.db= $2.str;
5003
4976
          }
5004
4977
        ;
5018
4991
          {
5019
4992
            LEX *lex=Lex;
5020
4993
            lex->sql_command= SQLCOM_LOAD;
5021
 
            lex->command= new(std::nothrow) command::Load(SQLCOM_LOAD,
5022
 
                                                          YYSession);
5023
 
            if (lex->command == NULL)
 
4994
            lex->statement= new(std::nothrow) statement::Load(YYSession);
 
4995
            if (lex->statement == NULL)
5024
4996
              DRIZZLE_YYABORT;
5025
4997
            lex->lock_option= $4;
5026
4998
            lex->duplicates= DUP_ERROR;
5555
5527
        | DATETIME_SYM             {}
5556
5528
        | DATE_SYM                 {}
5557
5529
        | DAY_SYM                  {}
5558
 
        | DELAY_KEY_WRITE_SYM      {}
5559
 
        | DIRECTORY_SYM            {}
5560
5530
        | DISABLE_SYM              {}
5561
5531
        | DISCARD                  {}
5562
5532
        | DUMPFILE                 {}
5625
5595
        | ONE_SHOT_SYM             {}
5626
5596
        | ONE_SYM                  {}
5627
5597
        | ONLINE_SYM               {}
5628
 
        | PACK_KEYS_SYM            {}
5629
5598
        | PAGE_SYM                 {}
5630
 
        | PAGE_CHECKSUM_SYM        {}
5631
5599
        | PARTIAL                  {}
5632
5600
        | PHASE_SYM                {}
5633
5601
        | POINT_SYM                {}
5672
5640
        | STRING_SYM               {}
5673
5641
        | SUBDATE_SYM              {}
5674
5642
        | SUBJECT_SYM              {}
5675
 
        | SUPER_SYM                {}
5676
5643
        | SUSPEND_SYM              {}
5677
5644
        | SWAPS_SYM                {}
5678
5645
        | SWITCHES_SYM             {}
5679
5646
        | TABLES                   {}
5680
 
        | TABLE_CHECKSUM_SYM       {}
5681
5647
        | TABLESPACE               {}
5682
5648
        | TEMPORARY_SYM            {}
5683
5649
        | TEMPTABLE_SYM            {}
5713
5679
          {
5714
5680
            LEX *lex=Lex;
5715
5681
            lex->sql_command= SQLCOM_SET_OPTION;
 
5682
            lex->statement= new(std::nothrow) statement::SetOption(YYSession);
 
5683
            if (lex->statement == NULL)
 
5684
              DRIZZLE_YYABORT;
5716
5685
            mysql_init_select(lex);
5717
5686
            lex->option_type=OPT_SESSION;
5718
5687
            lex->var_list.empty();
5849
5818
          {
5850
5819
            LEX *lex= Lex;
5851
5820
            lex->sql_command= SQLCOM_UNLOCK_TABLES;
 
5821
            lex->statement= new(std::nothrow) statement::UnlockTables(YYSession);
 
5822
            if (lex->statement == NULL)
 
5823
              DRIZZLE_YYABORT;
5852
5824
          }
5853
5825
          table_or_tables
5854
5826
          {}
5893
5865
          {
5894
5866
            LEX *lex=Lex;
5895
5867
            lex->sql_command= SQLCOM_COMMIT;
5896
 
            lex->command= new(std::nothrow) command::Commit(SQLCOM_COMMIT,
5897
 
                                                            YYSession);
5898
 
            if (lex->command == NULL)
 
5868
            lex->statement= new(std::nothrow) statement::Commit(YYSession);
 
5869
            if (lex->statement == NULL)
5899
5870
              DRIZZLE_YYABORT;
5900
5871
            lex->tx_chain= $3; 
5901
5872
            lex->tx_release= $4;
5907
5878
          {
5908
5879
            LEX *lex=Lex;
5909
5880
            lex->sql_command= SQLCOM_ROLLBACK;
5910
 
            lex->command= new(std::nothrow) command::Rollback(SQLCOM_ROLLBACK,
5911
 
                                                              YYSession);
5912
 
            if (lex->command == NULL)
 
5881
            lex->statement= new(std::nothrow) statement::Rollback(YYSession);
 
5882
            if (lex->statement == NULL)
5913
5883
              DRIZZLE_YYABORT;
5914
5884
            lex->tx_chain= $3; 
5915
5885
            lex->tx_release= $4;