~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_yacc.yy

  • Committer: Brian Aker
  • Date: 2010-12-30 20:46:12 UTC
  • mto: (2060.2.1 clean)
  • mto: This revision was merged to the branch mainline in revision 2063.
  • Revision ID: brian@tangent.org-20101230204612-z0pcpi78ptnk5jhq
Last of Lex remove.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3976
3976
select_derived:
3977
3977
          get_select_lex
3978
3978
          {
3979
 
            LEX *lex= Lex;
3980
 
            if ($1->init_nested_join(lex->session))
 
3979
            if ($1->init_nested_join(Lex->session))
3981
3980
              DRIZZLE_YYABORT;
3982
3981
          }
3983
3982
          derived_table_list
3984
3983
          {
3985
 
            LEX *lex= Lex;
3986
3984
            /* for normal joins, $3 != NULL and end_nested_join() != NULL,
3987
3985
               for derived tables, both must equal NULL */
3988
3986
 
3989
 
            if (!($$= $1->end_nested_join(lex->session)) && $3)
 
3987
            if (!($$= $1->end_nested_join(Lex->session)) && $3)
3990
3988
              DRIZZLE_YYABORT;
3991
3989
            if (!$3 && $$)
3992
3990
            {
3999
3997
 
4000
3998
select_derived2:
4001
3999
          {
4002
 
            LEX *lex= Lex;
4003
 
            lex->derived_tables|= DERIVED_SUBQUERY;
4004
 
            if (!lex->expr_allows_subselect)
 
4000
            Lex->derived_tables|= DERIVED_SUBQUERY;
 
4001
            if (not Lex->expr_allows_subselect)
4005
4002
            {
4006
4003
              struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
4007
4004
              my_parse_error(&pass);
4008
4005
              DRIZZLE_YYABORT;
4009
4006
            }
4010
 
            if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE ||
4011
 
                new_select(lex, 1))
 
4007
            if (Lex->current_select->linkage == GLOBAL_OPTIONS_TYPE || new_select(Lex, 1))
4012
4008
              DRIZZLE_YYABORT;
4013
 
            init_select(lex);
4014
 
            lex->current_select->linkage= DERIVED_TABLE_TYPE;
4015
 
            lex->current_select->parsing_place= SELECT_LIST;
 
4009
            init_select(Lex);
 
4010
            Lex->current_select->linkage= DERIVED_TABLE_TYPE;
 
4011
            Lex->current_select->parsing_place= SELECT_LIST;
4016
4012
          }
4017
4013
          select_options select_item_list
4018
4014
          {
4028
4024
select_derived_init:
4029
4025
          SELECT_SYM
4030
4026
          {
4031
 
            LEX *lex= Lex;
4032
 
 
4033
 
            Select_Lex *sel= lex->current_select;
 
4027
            Select_Lex *sel= Lex->current_select;
4034
4028
            TableList *embedding;
4035
 
            if (!sel->embedding || sel->end_nested_join(lex->session))
 
4029
            if (!sel->embedding || sel->end_nested_join(Lex->session))
4036
4030
            {
4037
4031
              /* we are not in parentheses */
4038
4032
              struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
4264
4258
              MySQL syntax: GROUP BY col1, col2, col3 WITH ROLLUP
4265
4259
              SQL-2003: GROUP BY ... ROLLUP(col1, col2, col3)
4266
4260
            */
4267
 
            LEX *lex= Lex;
4268
 
            if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE)
 
4261
            if (Lex->current_select->linkage == GLOBAL_OPTIONS_TYPE)
4269
4262
            {
4270
4263
              my_error(ER_WRONG_USAGE, MYF(0), "WITH ROLLUP",
4271
4264
                       "global union parameters");
4272
4265
              DRIZZLE_YYABORT;
4273
4266
            }
4274
 
            lex->current_select->olap= ROLLUP_TYPE;
 
4267
            Lex->current_select->olap= ROLLUP_TYPE;
4275
4268
          }
4276
4269
        ;
4277
4270
 
4309
4302
order_clause:
4310
4303
          ORDER_SYM BY
4311
4304
          {
4312
 
            LEX *lex=Lex;
4313
 
            Select_Lex *sel= lex->current_select;
 
4305
            Select_Lex *sel= Lex->current_select;
4314
4306
            Select_Lex_Unit *unit= sel-> master_unit();
4315
4307
            if (sel->linkage != GLOBAL_OPTIONS_TYPE &&
4316
4308
                sel->olap != UNSPECIFIED_OLAP_TYPE &&
4320
4312
                       "CUBE/ROLLUP", "ORDER BY");
4321
4313
              DRIZZLE_YYABORT;
4322
4314
            }
4323
 
            if (lex->sql_command != SQLCOM_ALTER_TABLE && !unit->fake_select_lex)
 
4315
            if (Lex->sql_command != SQLCOM_ALTER_TABLE && !unit->fake_select_lex)
4324
4316
            {
4325
4317
              /*
4326
4318
                A query of the of the form (SELECT ...) ORDER BY order_list is
4334
4326
              if (!unit->is_union() &&
4335
4327
                  (first_sl->order_list.elements ||
4336
4328
                   first_sl->select_limit) &&           
4337
 
                  unit->add_fake_select_lex(lex->session))
 
4329
                  unit->add_fake_select_lex(Lex->session))
4338
4330
                DRIZZLE_YYABORT;
4339
4331
            }
4340
4332
          }
4357
4349
opt_limit_clause_init:
4358
4350
          /* empty */
4359
4351
          {
4360
 
            LEX *lex= Lex;
4361
 
            Select_Lex *sel= lex->current_select;
 
4352
            Select_Lex *sel= Lex->current_select;
4362
4353
            sel->offset_limit= 0;
4363
4354
            sel->select_limit= 0;
4364
4355
          }
4407
4398
delete_limit_clause:
4408
4399
          /* empty */
4409
4400
          {
4410
 
            LEX *lex=Lex;
4411
 
            lex->current_select->select_limit= 0;
 
4401
            Lex->current_select->select_limit= 0;
4412
4402
          }
4413
4403
        | LIMIT limit_option
4414
4404
          {
4437
4427
 
4438
4428
select_var_list_init:
4439
4429
          {
4440
 
            LEX *lex=Lex;
4441
 
            if (!lex->describe && (!(lex->result= new select_dumpvar())))
 
4430
            if (not Lex->describe && (not (Lex->result= new select_dumpvar())))
4442
4431
              DRIZZLE_YYABORT;
4443
4432
          }
4444
4433
          select_var_list
4453
4442
select_var_ident: 
4454
4443
          '@' ident_or_text
4455
4444
          {
4456
 
            LEX *lex=Lex;
4457
 
            if (lex->result)
4458
 
              ((select_dumpvar *)lex->result)->var_list.push_back( new var($2,0,0,(enum_field_types)0));
 
4445
            if (Lex->result)
 
4446
              ((select_dumpvar *)Lex->result)->var_list.push_back( new var($2,0,0,(enum_field_types)0));
4459
4447
            else
4460
4448
              /*
4461
4449
                The parser won't create select_result instance only
4462
4450
                if it's an EXPLAIN.
4463
4451
              */
4464
 
              assert(lex->describe);
 
4452
              assert(Lex->describe);
4465
4453
          }
4466
4454
        ;
4467
4455
 
4474
4462
into_destination:
4475
4463
          OUTFILE TEXT_STRING_filesystem
4476
4464
          {
4477
 
            LEX *lex= Lex;
4478
 
            lex->setCacheable(false);
4479
 
            if (!(lex->exchange= new file_exchange($2.str, 0)) ||
4480
 
                !(lex->result= new select_export(lex->exchange)))
 
4465
            Lex->setCacheable(false);
 
4466
            if (!(Lex->exchange= new file_exchange($2.str, 0)) ||
 
4467
                !(Lex->result= new select_export(Lex->exchange)))
4481
4468
              DRIZZLE_YYABORT;
4482
4469
          }
4483
4470
          opt_field_term opt_line_term
4484
4471
        | DUMPFILE TEXT_STRING_filesystem
4485
4472
          {
4486
 
            LEX *lex=Lex;
4487
 
            if (!lex->describe)
 
4473
            if (not Lex->describe)
4488
4474
            {
4489
 
              lex->setCacheable(false);
4490
 
              if (!(lex->exchange= new file_exchange($2.str,1)))
 
4475
              Lex->setCacheable(false);
 
4476
              if (not (Lex->exchange= new file_exchange($2.str,1)))
4491
4477
                DRIZZLE_YYABORT;
4492
 
              if (!(lex->result= new select_dump(lex->exchange)))
 
4478
              if (not (Lex->result= new select_dump(Lex->exchange)))
4493
4479
                DRIZZLE_YYABORT;
4494
4480
            }
4495
4481
          }
4504
4490
drop:
4505
4491
          DROP opt_temporary table_or_tables if_exists table_list
4506
4492
          {
4507
 
            LEX *lex=Lex;
4508
 
            lex->sql_command = SQLCOM_DROP_TABLE;
 
4493
            Lex->sql_command = SQLCOM_DROP_TABLE;
4509
4494
            statement::DropTable *statement= new(std::nothrow) statement::DropTable(YYSession);
4510
 
            lex->statement= statement;
4511
 
            if (lex->statement == NULL)
 
4495
            Lex->statement= statement;
 
4496
            if (Lex->statement == NULL)
4512
4497
              DRIZZLE_YYABORT;
4513
4498
            statement->drop_temporary= $2;
4514
4499
            statement->drop_if_exists= $4;
4515
4500
          }
4516
4501
        | DROP build_method INDEX_SYM ident ON table_ident {}
4517
4502
          {
4518
 
            LEX *lex=Lex;
4519
 
            lex->sql_command= SQLCOM_DROP_INDEX;
 
4503
            Lex->sql_command= SQLCOM_DROP_INDEX;
4520
4504
            statement::DropIndex *statement= new(std::nothrow) statement::DropIndex(YYSession);
4521
 
            lex->statement= statement;
4522
 
            if (lex->statement == NULL)
 
4505
            Lex->statement= statement;
 
4506
            if (Lex->statement == NULL)
4523
4507
              DRIZZLE_YYABORT;
4524
4508
            statement->alter_info.flags.set(ALTER_DROP_INDEX);
4525
4509
            statement->alter_info.build_method= $2;
4526
4510
            statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY, $4.str));
4527
 
            if (!lex->current_select->add_table_to_list(lex->session, $6, NULL,
4528
 
                                                        TL_OPTION_UPDATING))
 
4511
            if (not Lex->current_select->add_table_to_list(Lex->session, $6, NULL,
 
4512
                                                          TL_OPTION_UPDATING))
4529
4513
              DRIZZLE_YYABORT;
4530
4514
          }
4531
4515
        | DROP DATABASE if_exists ident
4532
4516
          {
4533
 
            LEX *lex=Lex;
4534
 
            lex->sql_command= SQLCOM_DROP_DB;
 
4517
            Lex->sql_command= SQLCOM_DROP_DB;
4535
4518
            statement::DropSchema *statement= new(std::nothrow) statement::DropSchema(YYSession);
4536
 
            lex->statement= statement;
4537
 
            if (lex->statement == NULL)
 
4519
            Lex->statement= statement;
 
4520
            if (Lex->statement == NULL)
4538
4521
              DRIZZLE_YYABORT;
4539
4522
            statement->drop_if_exists=$3;
4540
 
            lex->name= $4;
 
4523
            Lex->name= $4;
4541
4524
          }
4542
4525
table_list:
4543
4526
          table_name
4569
4552
execute:
4570
4553
       EXECUTE_SYM execute_var_or_string opt_status opt_concurrent opt_wait
4571
4554
       {
4572
 
          LEX *lex= Lex;
4573
4555
          statement::Execute *statement= new(std::nothrow) statement::Execute(YYSession, $2, $3, $4, $5);
4574
 
          lex->statement= statement;
4575
 
          if (lex->statement == NULL)
 
4556
          Lex->statement= statement;
 
4557
          if (Lex->statement == NULL)
4576
4558
            DRIZZLE_YYABORT;
4577
4559
       }
4578
4560
 
4609
4591
insert:
4610
4592
          INSERT
4611
4593
          {
4612
 
            LEX *lex= Lex;
4613
 
            lex->sql_command= SQLCOM_INSERT;
4614
 
            lex->statement= new(std::nothrow) statement::Insert(YYSession);
4615
 
            if (lex->statement == NULL)
 
4594
            Lex->sql_command= SQLCOM_INSERT;
 
4595
            Lex->statement= new(std::nothrow) statement::Insert(YYSession);
 
4596
            if (Lex->statement == NULL)
4616
4597
              DRIZZLE_YYABORT;
4617
 
            lex->duplicates= DUP_ERROR;
4618
 
            init_select(lex);
 
4598
            Lex->duplicates= DUP_ERROR;
 
4599
            init_select(Lex);
4619
4600
            /* for subselects */
4620
 
            lex->lock_option= TL_READ;
 
4601
            Lex->lock_option= TL_READ;
4621
4602
          }
4622
4603
          opt_ignore insert2
4623
4604
          {
4631
4612
replace:
4632
4613
          REPLACE
4633
4614
          {
4634
 
            LEX *lex= Lex;
4635
 
            lex->sql_command= SQLCOM_REPLACE;
4636
 
            lex->statement= new(std::nothrow) statement::Replace(YYSession);
4637
 
            if (lex->statement == NULL)
 
4615
            Lex->sql_command= SQLCOM_REPLACE;
 
4616
            Lex->statement= new(std::nothrow) statement::Replace(YYSession);
 
4617
            if (Lex->statement == NULL)
4638
4618
              DRIZZLE_YYABORT;
4639
 
            lex->duplicates= DUP_REPLACE;
4640
 
            init_select(lex);
 
4619
            Lex->duplicates= DUP_REPLACE;
 
4620
            init_select(Lex);
4641
4621
          }
4642
4622
          insert2
4643
4623
          {
4656
4636
insert_table:
4657
4637
          table_name
4658
4638
          {
4659
 
            LEX *lex=Lex;
4660
 
            lex->field_list.empty();
4661
 
            lex->many_values.empty();
4662
 
            lex->insert_list=0;
 
4639
            Lex->field_list.empty();
 
4640
            Lex->many_values.empty();
 
4641
            Lex->insert_list=0;
4663
4642
          };
4664
4643
 
4665
4644
insert_field_spec:
4668
4647
        | '(' fields ')' insert_values {}
4669
4648
        | SET
4670
4649
          {
4671
 
            LEX *lex=Lex;
4672
 
            if (!(lex->insert_list = new List_item) ||
4673
 
                lex->many_values.push_back(lex->insert_list))
 
4650
            if (not (Lex->insert_list = new List_item) ||
 
4651
                Lex->many_values.push_back(Lex->insert_list))
4674
4652
              DRIZZLE_YYABORT;
4675
4653
          }
4676
4654
          ident_eq_list
4709
4687
ident_eq_value:
4710
4688
          simple_ident_nospvar equal expr_or_default
4711
4689
          {
4712
 
            LEX *lex=Lex;
4713
 
            if (lex->field_list.push_back($1) ||
4714
 
                lex->insert_list->push_back($3))
 
4690
            if (Lex->field_list.push_back($1) ||
 
4691
                Lex->insert_list->push_back($3))
4715
4692
              DRIZZLE_YYABORT;
4716
4693
          }
4717
4694
        ;
4734
4711
          }
4735
4712
          opt_values ')'
4736
4713
          {
4737
 
            LEX *lex=Lex;
4738
 
            if (lex->many_values.push_back(lex->insert_list))
 
4714
            if (Lex->many_values.push_back(Lex->insert_list))
4739
4715
              DRIZZLE_YYABORT;
4740
4716
          }
4741
4717
        ;
4774
4750
update:
4775
4751
          UPDATE_SYM opt_ignore table_ident
4776
4752
          {
4777
 
            LEX *lex= Lex;
4778
 
            init_select(lex);
4779
 
            lex->sql_command= SQLCOM_UPDATE;
4780
 
            lex->statement= new(std::nothrow) statement::Update(YYSession);
4781
 
            if (lex->statement == NULL)
 
4753
            init_select(Lex);
 
4754
            Lex->sql_command= SQLCOM_UPDATE;
 
4755
            Lex->statement= new(std::nothrow) statement::Update(YYSession);
 
4756
            if (Lex->statement == NULL)
4782
4757
              DRIZZLE_YYABORT;
4783
 
            lex->lock_option= TL_UNLOCK; /* Will be set later */
4784
 
            lex->duplicates= DUP_ERROR;
4785
 
            if (!lex->select_lex.add_table_to_list(YYSession, $3, NULL,0))
 
4758
            Lex->lock_option= TL_UNLOCK; /* Will be set later */
 
4759
            Lex->duplicates= DUP_ERROR;
 
4760
            if (not Lex->select_lex.add_table_to_list(YYSession, $3, NULL,0))
4786
4761
              DRIZZLE_YYABORT;
4787
4762
          }
4788
4763
          SET update_list
4789
4764
          {
4790
 
            LEX *lex= Lex;
4791
 
            if (lex->select_lex.get_table_list()->derived)
 
4765
            if (Lex->select_lex.get_table_list()->derived)
4792
4766
            {
4793
4767
              /* it is single table update and it is update of derived table */
4794
4768
              my_error(ER_NON_UPDATABLE_TABLE, MYF(0),
4795
 
                       lex->select_lex.get_table_list()->alias, "UPDATE");
 
4769
                       Lex->select_lex.get_table_list()->alias, "UPDATE");
4796
4770
              DRIZZLE_YYABORT;
4797
4771
            }
4798
4772
            /*
4826
4800
insert_update_elem:
4827
4801
          simple_ident_nospvar equal expr_or_default
4828
4802
          {
4829
 
          LEX *lex= Lex;
4830
 
          if (lex->update_list.push_back($1) ||
4831
 
              lex->value_list.push_back($3))
 
4803
          if (Lex->update_list.push_back($1) ||
 
4804
              Lex->value_list.push_back($3))
4832
4805
              DRIZZLE_YYABORT;
4833
4806
          }
4834
4807
        ;
4838
4811
delete:
4839
4812
          DELETE_SYM
4840
4813
          {
4841
 
            LEX *lex= Lex;
4842
 
            lex->sql_command= SQLCOM_DELETE;
4843
 
            lex->statement= new(std::nothrow) statement::Delete(YYSession);
4844
 
            if (lex->statement == NULL)
 
4814
            Lex->sql_command= SQLCOM_DELETE;
 
4815
            Lex->statement= new(std::nothrow) statement::Delete(YYSession);
 
4816
            if (Lex->statement == NULL)
4845
4817
              DRIZZLE_YYABORT;
4846
 
            init_select(lex);
4847
 
            lex->lock_option= TL_WRITE_DEFAULT;
4848
 
            lex->ignore= 0;
4849
 
            lex->select_lex.init_order();
 
4818
            init_select(Lex);
 
4819
            Lex->lock_option= TL_WRITE_DEFAULT;
 
4820
            Lex->ignore= 0;
 
4821
            Lex->select_lex.init_order();
4850
4822
          }
4851
4823
          opt_delete_options single_multi
4852
4824
        ;
4874
4846
truncate:
4875
4847
          TRUNCATE_SYM opt_table_sym table_name
4876
4848
          {
4877
 
            LEX* lex= Lex;
4878
 
            lex->sql_command= SQLCOM_TRUNCATE;
4879
 
            lex->statement= new(std::nothrow) statement::Truncate(YYSession);
4880
 
            if (lex->statement == NULL)
 
4849
            Lex->sql_command= SQLCOM_TRUNCATE;
 
4850
            Lex->statement= new(std::nothrow) statement::Truncate(YYSession);
 
4851
            if (Lex->statement == NULL)
4881
4852
              DRIZZLE_YYABORT;
4882
 
            lex->select_lex.options= 0;
4883
 
            lex->select_lex.init_order();
 
4853
            Lex->select_lex.options= 0;
 
4854
            Lex->select_lex.init_order();
4884
4855
          }
4885
4856
        ;
4886
4857
 
4894
4865
show:
4895
4866
          SHOW
4896
4867
          {
4897
 
            LEX *lex=Lex;
4898
 
            lex->wild=0;
4899
 
            lex->lock_option= TL_READ;
4900
 
            init_select(lex);
4901
 
            lex->current_select->parsing_place= SELECT_LIST;
 
4868
            Lex->wild=0;
 
4869
            Lex->lock_option= TL_READ;
 
4870
            init_select(Lex);
 
4871
            Lex->current_select->parsing_place= SELECT_LIST;
4902
4872
          }
4903
4873
          show_param
4904
4874
          {}
4908
4878
show_param:
4909
4879
           DATABASES show_wild
4910
4880
           {
4911
 
             LEX *lex= Lex;
4912
 
 
4913
 
             lex->sql_command= SQLCOM_SELECT;
4914
 
             lex->statement=
 
4881
             Lex->sql_command= SQLCOM_SELECT;
 
4882
             Lex->statement=
4915
4883
               new(std::nothrow) statement::Show(YYSession);
4916
 
             if (lex->statement == NULL)
 
4884
             if (Lex->statement == NULL)
4917
4885
               DRIZZLE_YYABORT;
4918
4886
 
4919
4887
             std::string column_name= "Database";
4926
4894
 
4927
4895
             if (Lex->current_select->where)
4928
4896
             {
4929
 
               if (prepare_new_schema_table(YYSession, lex, "SCHEMAS"))
 
4897
               if (prepare_new_schema_table(YYSession, Lex, "SCHEMAS"))
4930
4898
                 DRIZZLE_YYABORT;
4931
4899
             }
4932
4900
             else
4933
4901
             {
4934
 
               if (prepare_new_schema_table(YYSession, lex, "SHOW_SCHEMAS"))
 
4902
               if (prepare_new_schema_table(YYSession, Lex, "SHOW_SCHEMAS"))
4935
4903
                 DRIZZLE_YYABORT;
4936
4904
             }
4937
4905
 
4948
4916
           /* SHOW TABLES */
4949
4917
         | TABLES opt_db show_wild
4950
4918
           {
4951
 
             LEX *lex= Lex;
4952
 
 
4953
 
             lex->sql_command= SQLCOM_SELECT;
 
4919
             Lex->sql_command= SQLCOM_SELECT;
4954
4920
 
4955
4921
             statement::Show *select=
4956
4922
               new(std::nothrow) statement::Show(YYSession);
4957
4923
 
4958
 
             lex->statement= select;
 
4924
             Lex->statement= select;
4959
4925
 
4960
 
             if (lex->statement == NULL)
 
4926
             if (Lex->statement == NULL)
4961
4927
               DRIZZLE_YYABORT;
4962
4928
 
4963
4929
 
4968
4934
              {
4969
4935
                SchemaIdentifier identifier($2);
4970
4936
                column_name.append($2);
4971
 
                lex->select_lex.db= $2;
 
4937
                Lex->select_lex.db= $2;
4972
4938
                if (not plugin::StorageEngine::doesSchemaExist(identifier))
4973
4939
                {
4974
4940
                  my_error(ER_BAD_DB_ERROR, MYF(0), $2);
4994
4960
               column_name.append(")");
4995
4961
             }
4996
4962
 
4997
 
             if (prepare_new_schema_table(YYSession, lex, "SHOW_TABLES"))
 
4963
             if (prepare_new_schema_table(YYSession, Lex, "SHOW_TABLES"))
4998
4964
               DRIZZLE_YYABORT;
4999
4965
 
5000
4966
             Item_field *my_field= new Item_field(&YYSession->lex->current_select->context, NULL, NULL, "TABLE_NAME");
5010
4976
           /* SHOW TEMPORARY TABLES */
5011
4977
         | TEMPORARY_SYM TABLES show_wild
5012
4978
           {
5013
 
             LEX *lex= Lex;
5014
 
 
5015
 
             lex->sql_command= SQLCOM_SELECT;
 
4979
             Lex->sql_command= SQLCOM_SELECT;
5016
4980
 
5017
4981
             statement::Show *select=
5018
4982
               new(std::nothrow) statement::Show(YYSession);
5019
4983
 
5020
 
             lex->statement= select;
 
4984
             Lex->statement= select;
5021
4985
 
5022
 
             if (lex->statement == NULL)
 
4986
             if (Lex->statement == NULL)
5023
4987
               DRIZZLE_YYABORT;
5024
4988
 
5025
4989
 
5026
 
             if (prepare_new_schema_table(YYSession, lex, "SHOW_TEMPORARY_TABLES"))
 
4990
             if (prepare_new_schema_table(YYSession, Lex, "SHOW_TEMPORARY_TABLES"))
5027
4991
               DRIZZLE_YYABORT;
5028
4992
 
5029
4993
             if (YYSession->add_item_to_list( new Item_field(&YYSession->lex->current_select->
5036
5000
           /* SHOW TABLE STATUS */
5037
5001
         | TABLE_SYM STATUS_SYM opt_db show_wild
5038
5002
           {
5039
 
             LEX *lex= Lex;
5040
 
             lex->sql_command= SQLCOM_SELECT;
 
5003
             Lex->sql_command= SQLCOM_SELECT;
5041
5004
             statement::Show *select=
5042
5005
               new(std::nothrow) statement::Show(YYSession);
5043
5006
 
5044
 
             lex->statement= select;
 
5007
             Lex->statement= select;
5045
5008
 
5046
 
             if (lex->statement == NULL)
 
5009
             if (Lex->statement == NULL)
5047
5010
               DRIZZLE_YYABORT;
5048
5011
 
5049
5012
             std::string column_name= "Tables_in_";
5051
5014
             util::string::const_shared_ptr schema(YYSession->schema());
5052
5015
             if ($3)
5053
5016
             {
5054
 
               lex->select_lex.db= $3;
 
5017
               Lex->select_lex.db= $3;
5055
5018
 
5056
5019
               SchemaIdentifier identifier($3);
5057
5020
               if (not plugin::StorageEngine::doesSchemaExist(identifier))
5071
5034
               DRIZZLE_YYABORT;
5072
5035
             }
5073
5036
 
5074
 
             if (prepare_new_schema_table(YYSession, lex, "SHOW_TABLE_STATUS"))
 
5037
             if (prepare_new_schema_table(YYSession, Lex, "SHOW_TABLE_STATUS"))
5075
5038
               DRIZZLE_YYABORT;
5076
5039
 
5077
5040
             if (YYSession->add_item_to_list( new Item_field(&YYSession->lex->current_select->
5083
5046
           /* SHOW COLUMNS FROM table_name */
5084
5047
        | COLUMNS from_or_in table_ident opt_db show_wild
5085
5048
          {
5086
 
             LEX *lex= Lex;
5087
5049
             statement::Show *select;
5088
5050
 
5089
 
             lex->sql_command= SQLCOM_SELECT;
 
5051
             Lex->sql_command= SQLCOM_SELECT;
5090
5052
 
5091
5053
             select= new(std::nothrow) statement::Show(YYSession);
5092
5054
 
5093
 
             lex->statement= select;
 
5055
             Lex->statement= select;
5094
5056
 
5095
 
             if (lex->statement == NULL)
 
5057
             if (Lex->statement == NULL)
5096
5058
               DRIZZLE_YYABORT;
5097
5059
 
5098
5060
             util::string::const_shared_ptr schema(YYSession->schema());
5124
5086
               }
5125
5087
             }
5126
5088
 
5127
 
             if (prepare_new_schema_table(YYSession, lex, "SHOW_COLUMNS"))
 
5089
             if (prepare_new_schema_table(YYSession, Lex, "SHOW_COLUMNS"))
5128
5090
               DRIZZLE_YYABORT;
5129
5091
 
5130
5092
             if (YYSession->add_item_to_list( new Item_field(&YYSession->lex->current_select->
5137
5099
          /* SHOW INDEXES from table */
5138
5100
        | keys_or_index from_or_in table_ident opt_db where_clause
5139
5101
          {
5140
 
             LEX *lex= Lex;
5141
5102
             statement::Show *select;
5142
5103
 
5143
 
             lex->sql_command= SQLCOM_SELECT;
 
5104
             Lex->sql_command= SQLCOM_SELECT;
5144
5105
 
5145
5106
             select= new(std::nothrow) statement::Show(YYSession);
5146
5107
 
5147
 
             lex->statement= select;
 
5108
             Lex->statement= select;
5148
5109
 
5149
 
             if (lex->statement == NULL)
 
5110
             if (Lex->statement == NULL)
5150
5111
               DRIZZLE_YYABORT;
5151
5112
 
5152
5113
             util::string::const_shared_ptr schema(YYSession->schema());
5178
5139
               }
5179
5140
             }
5180
5141
 
5181
 
             if (prepare_new_schema_table(YYSession, lex, "SHOW_INDEXES"))
 
5142
             if (prepare_new_schema_table(YYSession, Lex, "SHOW_INDEXES"))
5182
5143
               DRIZZLE_YYABORT;
5183
5144
 
5184
5145
             if (YYSession->add_item_to_list( new Item_field(&YYSession->lex->current_select->
5190
5151
        | COUNT_SYM '(' '*' ')' WARNINGS
5191
5152
          {
5192
5153
            (void) create_select_for_variable("warning_count");
5193
 
            LEX *lex= Lex;
5194
 
            lex->statement= new(std::nothrow) statement::Show(YYSession);
5195
 
            if (lex->statement == NULL)
 
5154
            Lex->statement= new(std::nothrow) statement::Show(YYSession);
 
5155
            if (Lex->statement == NULL)
5196
5156
              DRIZZLE_YYABORT;
5197
5157
          }
5198
5158
        | COUNT_SYM '(' '*' ')' ERRORS
5199
5159
          {
5200
5160
            (void) create_select_for_variable("error_count");
5201
 
            LEX *lex= Lex;
5202
 
            lex->statement= new(std::nothrow) statement::Show(YYSession);
5203
 
            if (lex->statement == NULL)
 
5161
            Lex->statement= new(std::nothrow) statement::Show(YYSession);
 
5162
            if (Lex->statement == NULL)
5204
5163
              DRIZZLE_YYABORT;
5205
5164
          }
5206
5165
        | WARNINGS opt_limit_clause_init
5219
5178
          }
5220
5179
        | opt_var_type STATUS_SYM show_wild
5221
5180
           {
5222
 
             LEX *lex= Lex;
5223
 
             lex->sql_command= SQLCOM_SELECT;
5224
 
             lex->statement=
5225
 
               new(std::nothrow) statement::Show(YYSession);
5226
 
             if (lex->statement == NULL)
 
5181
             Lex->sql_command= SQLCOM_SELECT;
 
5182
             Lex->statement= new(std::nothrow) statement::Show(YYSession);
 
5183
             if (Lex->statement == NULL)
5227
5184
               DRIZZLE_YYABORT;
5228
5185
 
5229
5186
             if ($1 == OPT_GLOBAL)
5230
5187
             {
5231
 
               if (prepare_new_schema_table(YYSession, lex, "GLOBAL_STATUS"))
 
5188
               if (prepare_new_schema_table(YYSession, Lex, "GLOBAL_STATUS"))
5232
5189
                 DRIZZLE_YYABORT;
5233
5190
             }
5234
5191
             else
5235
5192
             {
5236
 
               if (prepare_new_schema_table(YYSession, lex, "SESSION_STATUS"))
 
5193
               if (prepare_new_schema_table(YYSession, Lex, "SESSION_STATUS"))
5237
5194
                 DRIZZLE_YYABORT;
5238
5195
             }
5239
5196
 
5256
5213
           }
5257
5214
        | CREATE TABLE_SYM table_ident
5258
5215
           {
5259
 
             LEX *lex= Lex;
5260
 
             lex->sql_command= SQLCOM_SELECT;
 
5216
             Lex->sql_command= SQLCOM_SELECT;
5261
5217
             statement::Show *select=
5262
5218
               new(std::nothrow) statement::Show(YYSession);
5263
5219
 
5264
 
             lex->statement= select;
 
5220
             Lex->statement= select;
5265
5221
 
5266
 
             if (lex->statement == NULL)
 
5222
             if (Lex->statement == NULL)
5267
5223
               DRIZZLE_YYABORT;
5268
5224
 
5269
 
             if (prepare_new_schema_table(YYSession, lex, "TABLE_SQL_DEFINITION"))
 
5225
             if (prepare_new_schema_table(YYSession, Lex, "TABLE_SQL_DEFINITION"))
5270
5226
               DRIZZLE_YYABORT;
5271
5227
 
5272
5228
             util::string::const_shared_ptr schema(YYSession->schema());
5304
5260
        | PROCESSLIST_SYM
5305
5261
          {
5306
5262
           {
5307
 
             LEX *lex= Lex;
5308
 
             lex->sql_command= SQLCOM_SELECT;
5309
 
             lex->statement=
 
5263
             Lex->sql_command= SQLCOM_SELECT;
 
5264
             Lex->statement=
5310
5265
               new(std::nothrow) statement::Show(YYSession);
5311
 
             if (lex->statement == NULL)
 
5266
             if (Lex->statement == NULL)
5312
5267
               DRIZZLE_YYABORT;
5313
5268
 
5314
 
             if (prepare_new_schema_table(YYSession, lex, "PROCESSLIST"))
 
5269
             if (prepare_new_schema_table(YYSession, Lex, "PROCESSLIST"))
5315
5270
               DRIZZLE_YYABORT;
5316
5271
 
5317
5272
             if (YYSession->add_item_to_list( new Item_field(&YYSession->lex->current_select->
5323
5278
          }
5324
5279
        | opt_var_type  VARIABLES show_wild
5325
5280
           {
5326
 
             LEX *lex= Lex;
5327
 
             lex->sql_command= SQLCOM_SELECT;
5328
 
             lex->statement=
 
5281
             Lex->sql_command= SQLCOM_SELECT;
 
5282
             Lex->statement=
5329
5283
               new(std::nothrow) statement::Show(YYSession);
5330
 
             if (lex->statement == NULL)
 
5284
             if (Lex->statement == NULL)
5331
5285
               DRIZZLE_YYABORT;
5332
5286
 
5333
5287
             if ($1 == OPT_GLOBAL)
5334
5288
             {
5335
 
               if (prepare_new_schema_table(YYSession, lex, "GLOBAL_VARIABLES"))
 
5289
               if (prepare_new_schema_table(YYSession, Lex, "GLOBAL_VARIABLES"))
5336
5290
                 DRIZZLE_YYABORT;
5337
5291
             }
5338
5292
             else
5339
5293
             {
5340
 
               if (prepare_new_schema_table(YYSession, lex, "SESSION_VARIABLES"))
 
5294
               if (prepare_new_schema_table(YYSession, Lex, "SESSION_VARIABLES"))
5341
5295
                 DRIZZLE_YYABORT;
5342
5296
             }
5343
5297
 
5360
5314
           }
5361
5315
        | CREATE DATABASE opt_if_not_exists ident
5362
5316
           {
5363
 
             LEX *lex= Lex;
5364
 
             lex->sql_command= SQLCOM_SELECT;
 
5317
             Lex->sql_command= SQLCOM_SELECT;
5365
5318
             statement::Show *select=
5366
5319
               new(std::nothrow) statement::Show(YYSession);
5367
5320
 
5368
 
             lex->statement= select;
 
5321
             Lex->statement= select;
5369
5322
 
5370
 
             if (lex->statement == NULL)
 
5323
             if (Lex->statement == NULL)
5371
5324
               DRIZZLE_YYABORT;
5372
5325
 
5373
 
             if (prepare_new_schema_table(YYSession, lex, "SCHEMA_SQL_DEFINITION"))
 
5326
             if (prepare_new_schema_table(YYSession, Lex, "SCHEMA_SQL_DEFINITION"))
5374
5327
               DRIZZLE_YYABORT;
5375
5328
 
5376
5329
             util::string::const_shared_ptr schema(YYSession->schema());
5438
5391
          describe_command table_ident
5439
5392
          {
5440
5393
            statement::Show *select;
5441
 
            LEX *lex= Lex;
5442
 
            lex->lock_option= TL_READ;
5443
 
            init_select(lex);
5444
 
            lex->current_select->parsing_place= SELECT_LIST;
5445
 
            lex->sql_command= SQLCOM_SELECT;
 
5394
            Lex->lock_option= TL_READ;
 
5395
            init_select(Lex);
 
5396
            Lex->current_select->parsing_place= SELECT_LIST;
 
5397
            Lex->sql_command= SQLCOM_SELECT;
5446
5398
            select= new(std::nothrow) statement::Show(YYSession);
5447
 
            lex->statement= select;
5448
 
            if (lex->statement == NULL)
 
5399
            Lex->statement= select;
 
5400
            if (Lex->statement == NULL)
5449
5401
              DRIZZLE_YYABORT;
5450
 
            lex->select_lex.db= 0;
 
5402
            Lex->select_lex.db= 0;
5451
5403
 
5452
5404
             util::string::const_shared_ptr schema(YYSession->schema());
5453
5405
             if ($2->db.str)
5474
5426
               }
5475
5427
             }
5476
5428
 
5477
 
             if (prepare_new_schema_table(YYSession, lex, "SHOW_COLUMNS"))
 
5429
             if (prepare_new_schema_table(YYSession, Lex, "SHOW_COLUMNS"))
5478
5430
               DRIZZLE_YYABORT;
5479
5431
 
5480
5432
             if (YYSession->add_item_to_list( new Item_field(&YYSession->lex->current_select->
5491
5443
          { Lex->describe|= DESCRIBE_NORMAL; }
5492
5444
          select
5493
5445
          {
5494
 
            LEX *lex=Lex;
5495
 
            lex->select_lex.options|= SELECT_DESCRIBE;
 
5446
            Lex->select_lex.options|= SELECT_DESCRIBE;
5496
5447
          }
5497
5448
        ;
5498
5449
 
5523
5474
flush:
5524
5475
          FLUSH_SYM
5525
5476
          {
5526
 
            LEX *lex=Lex;
5527
 
            lex->sql_command= SQLCOM_FLUSH;
5528
 
            lex->statement= new(std::nothrow) statement::Flush(YYSession);
5529
 
            if (lex->statement == NULL)
 
5477
            Lex->sql_command= SQLCOM_FLUSH;
 
5478
            Lex->statement= new(std::nothrow) statement::Flush(YYSession);
 
5479
            if (Lex->statement == NULL)
5530
5480
              DRIZZLE_YYABORT;
5531
 
            lex->type= 0;
 
5481
            Lex->type= 0;
5532
5482
          }
5533
5483
          flush_options
5534
5484
          {}
5578
5528
kill:
5579
5529
          KILL_SYM kill_option expr
5580
5530
          {
5581
 
            LEX *lex=Lex;
5582
 
 
5583
5531
            if ($2)
5584
5532
            {
5585
5533
              Lex->type= ONLY_KILL_QUERY;
5589
5537
              Lex->type= 0;
5590
5538
            }
5591
5539
 
5592
 
            lex->value_list.empty();
5593
 
            lex->value_list.push_front($3);
5594
 
            lex->sql_command= SQLCOM_KILL;
5595
 
            lex->statement= new(std::nothrow) statement::Kill(YYSession);
5596
 
            if (lex->statement == NULL)
 
5540
            Lex->value_list.empty();
 
5541
            Lex->value_list.push_front($3);
 
5542
            Lex->sql_command= SQLCOM_KILL;
 
5543
            Lex->statement= new(std::nothrow) statement::Kill(YYSession);
 
5544
            if (Lex->statement == NULL)
5597
5545
              DRIZZLE_YYABORT;
5598
5546
          }
5599
5547
        ;
5609
5557
use:
5610
5558
          USE_SYM ident
5611
5559
          {
5612
 
            LEX *lex=Lex;
5613
 
            lex->sql_command=SQLCOM_CHANGE_DB;
5614
 
            lex->statement= new(std::nothrow) statement::ChangeSchema(YYSession);
5615
 
            if (lex->statement == NULL)
 
5560
            Lex->sql_command=SQLCOM_CHANGE_DB;
 
5561
            Lex->statement= new(std::nothrow) statement::ChangeSchema(YYSession);
 
5562
            if (Lex->statement == NULL)
5616
5563
              DRIZZLE_YYABORT;
5617
 
            lex->select_lex.db= $2.str;
 
5564
            Lex->select_lex.db= $2.str;
5618
5565
          }
5619
5566
        ;
5620
5567
 
5623
5570
load:
5624
5571
          LOAD data_file
5625
5572
          {
5626
 
            LEX *lex= YYSession->lex;
5627
 
 
5628
 
            lex->sql_command= SQLCOM_LOAD;
 
5573
            Lex->sql_command= SQLCOM_LOAD;
5629
5574
            statement::Load *statement= new(std::nothrow) statement::Load(YYSession);
5630
 
            lex->statement= statement;
5631
 
            if (lex->statement == NULL)
 
5575
            Lex->statement= statement;
 
5576
            if (Lex->statement == NULL)
5632
5577
              DRIZZLE_YYABORT;
5633
5578
 
5634
5579
            Lex_input_stream *lip= YYSession->m_lip;
5636
5581
          }
5637
5582
          load_data_lock INFILE TEXT_STRING_filesystem
5638
5583
          {
5639
 
            LEX *lex=Lex;
5640
 
            lex->lock_option= $4;
5641
 
            lex->duplicates= DUP_ERROR;
5642
 
            lex->ignore= 0;
5643
 
            if (!(lex->exchange= new file_exchange($6.str, 0, $2)))
 
5584
            Lex->lock_option= $4;
 
5585
            Lex->duplicates= DUP_ERROR;
 
5586
            Lex->ignore= 0;
 
5587
            if (not (Lex->exchange= new file_exchange($6.str, 0, $2)))
5644
5588
              DRIZZLE_YYABORT;
5645
5589
          }
5646
5590
          opt_duplicate INTO
5650
5594
          }
5651
5595
          TABLE_SYM table_ident
5652
5596
          {
5653
 
            LEX *lex=Lex;
5654
5597
            if (!Lex->current_select->add_table_to_list(YYSession,
5655
5598
                    $12, NULL, TL_OPTION_UPDATING,
5656
 
                    lex->lock_option))
 
5599
                    Lex->lock_option))
5657
5600
              DRIZZLE_YYABORT;
5658
 
            lex->field_list.empty();
5659
 
            lex->update_list.empty();
5660
 
            lex->value_list.empty();
 
5601
            Lex->field_list.empty();
 
5602
            Lex->update_list.empty();
 
5603
            Lex->value_list.empty();
5661
5604
          }
5662
5605
          opt_field_term opt_line_term opt_ignore_lines opt_field_or_var_spec
5663
5606
          opt_load_data_set_spec
5708
5651
          }
5709
5652
        | OPTIONALLY ENCLOSED BY text_string
5710
5653
          {
5711
 
            LEX *lex= Lex;
5712
 
            assert(lex->exchange != 0);
5713
 
            lex->exchange->enclosed= $4;
5714
 
            lex->exchange->opt_enclosed= 1;
 
5654
            assert(Lex->exchange != 0);
 
5655
            Lex->exchange->enclosed= $4;
 
5656
            Lex->exchange->opt_enclosed= 1;
5715
5657
          }
5716
5658
        | ENCLOSED BY text_string
5717
5659
          {
5947
5889
simple_ident_q:
5948
5890
          ident '.' ident
5949
5891
          {
5950
 
            LEX *lex= YYSession->lex;
5951
 
 
5952
5892
            {
5953
 
              Select_Lex *sel= lex->current_select;
 
5893
              Select_Lex *sel= Lex->current_select;
5954
5894
              if (sel->no_table_names_allowed)
5955
5895
              {
5956
5896
                my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5966
5906
          }
5967
5907
        | '.' ident '.' ident
5968
5908
          {
5969
 
            LEX *lex= YYSession->lex;
5970
 
            Select_Lex *sel= lex->current_select;
 
5909
            Select_Lex *sel= Lex->current_select;
5971
5910
            if (sel->no_table_names_allowed)
5972
5911
            {
5973
5912
              my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5981
5920
          }
5982
5921
        | ident '.' ident '.' ident
5983
5922
          {
5984
 
            LEX *lex= YYSession->lex;
5985
 
            Select_Lex *sel= lex->current_select;
 
5923
            Select_Lex *sel= Lex->current_select;
5986
5924
            if (sel->no_table_names_allowed)
5987
5925
            {
5988
5926
              my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
6271
6209
set:
6272
6210
          SET opt_option
6273
6211
          {
6274
 
            LEX *lex=Lex;
6275
 
            lex->sql_command= SQLCOM_SET_OPTION;
 
6212
            Lex->sql_command= SQLCOM_SET_OPTION;
6276
6213
            statement::SetOption *statement= new(std::nothrow) statement::SetOption(YYSession);
6277
 
            lex->statement= statement;
6278
 
            if (lex->statement == NULL)
 
6214
            Lex->statement= statement;
 
6215
            if (Lex->statement == NULL)
6279
6216
              DRIZZLE_YYABORT;
6280
 
            init_select(lex);
6281
 
            lex->option_type=OPT_SESSION;
6282
 
            lex->var_list.empty();
 
6217
            init_select(Lex);
 
6218
            Lex->option_type=OPT_SESSION;
 
6219
            Lex->var_list.empty();
6283
6220
          }
6284
6221
          option_value_list
6285
6222
          {}
6337
6274
sys_option_value:
6338
6275
          option_type internal_variable_name equal set_expr_or_default
6339
6276
          {
6340
 
            LEX *lex=Lex;
6341
 
 
6342
6277
            if ($2.var)
6343
6278
            { /* System variable */
6344
6279
              if ($1)
6345
 
                lex->option_type= $1;
6346
 
              lex->var_list.push_back(new set_var(lex->option_type, $2.var,
 
6280
                Lex->option_type= $1;
 
6281
              Lex->var_list.push_back(new set_var(Lex->option_type, $2.var,
6347
6282
                                      &$2.base_name, $4));
6348
6283
            }
6349
6284
          }
6350
6285
        | option_type TRANSACTION_SYM ISOLATION LEVEL_SYM isolation_types
6351
6286
          {
6352
 
            LEX *lex=Lex;
6353
 
            lex->option_type= $1;
6354
 
            lex->var_list.push_back(new set_var(lex->option_type,
 
6287
            Lex->option_type= $1;
 
6288
            Lex->var_list.push_back(new set_var(Lex->option_type,
6355
6289
                                                find_sys_var("tx_isolation"),
6356
6290
                                                &null_lex_str,
6357
6291
                                                new Item_int((int32_t) $5)));
6365
6299
          }
6366
6300
        | '@' '@' opt_var_ident_type internal_variable_name equal set_expr_or_default
6367
6301
          {
6368
 
            LEX *lex=Lex;
6369
 
            lex->var_list.push_back(new set_var($3, $4.var, &$4.base_name, $6));
 
6302
            Lex->var_list.push_back(new set_var($3, $4.var, &$4.base_name, $6));
6370
6303
          }
6371
6304
        ;
6372
6305
 
6408
6341
unlock:
6409
6342
          UNLOCK_SYM
6410
6343
          {
6411
 
            LEX *lex= Lex;
6412
 
            lex->sql_command= SQLCOM_UNLOCK_TABLES;
6413
 
            lex->statement= new(std::nothrow) statement::UnlockTables(YYSession);
6414
 
            if (lex->statement == NULL)
 
6344
            Lex->sql_command= SQLCOM_UNLOCK_TABLES;
 
6345
            Lex->statement= new(std::nothrow) statement::UnlockTables(YYSession);
 
6346
            if (Lex->statement == NULL)
6415
6347
              DRIZZLE_YYABORT;
6416
6348
          }
6417
6349
          table_or_tables
6421
6353
begin:
6422
6354
          BEGIN_SYM
6423
6355
          {
6424
 
            LEX *lex=Lex;
6425
 
            lex->sql_command = SQLCOM_BEGIN;
6426
 
            lex->statement= new(std::nothrow) statement::StartTransaction(YYSession);
6427
 
            if (lex->statement == NULL)
 
6356
            Lex->sql_command = SQLCOM_BEGIN;
 
6357
            Lex->statement= new(std::nothrow) statement::StartTransaction(YYSession);
 
6358
            if (Lex->statement == NULL)
6428
6359
              DRIZZLE_YYABORT;
6429
6360
          }
6430
6361
          opt_work {}
6457
6388
commit:
6458
6389
          COMMIT_SYM opt_work opt_chain opt_release
6459
6390
          {
6460
 
            LEX *lex=Lex;
6461
 
            lex->sql_command= SQLCOM_COMMIT;
 
6391
            Lex->sql_command= SQLCOM_COMMIT;
6462
6392
            statement::Commit *statement= new(std::nothrow) statement::Commit(YYSession);
6463
 
            lex->statement= statement;
6464
 
            if (lex->statement == NULL)
 
6393
            Lex->statement= statement;
 
6394
            if (Lex->statement == NULL)
6465
6395
              DRIZZLE_YYABORT;
6466
6396
            statement->tx_chain= $3;
6467
6397
            statement->tx_release= $4;
6471
6401
rollback:
6472
6402
          ROLLBACK_SYM opt_work opt_chain opt_release
6473
6403
          {
6474
 
            LEX *lex=Lex;
6475
 
            lex->sql_command= SQLCOM_ROLLBACK;
 
6404
            Lex->sql_command= SQLCOM_ROLLBACK;
6476
6405
            statement::Rollback *statement= new(std::nothrow) statement::Rollback(YYSession);
6477
 
            lex->statement= statement;
6478
 
            if (lex->statement == NULL)
 
6406
            Lex->statement= statement;
 
6407
            if (Lex->statement == NULL)
6479
6408
              DRIZZLE_YYABORT;
6480
6409
            statement->tx_chain= $3;
6481
6410
            statement->tx_release= $4;
6483
6412
        | ROLLBACK_SYM opt_work
6484
6413
          TO_SYM opt_savepoint ident
6485
6414
          {
6486
 
            LEX *lex=Lex;
6487
 
            lex->sql_command= SQLCOM_ROLLBACK_TO_SAVEPOINT;
6488
 
            lex->statement= new(std::nothrow) statement::RollbackToSavepoint(YYSession);
6489
 
            if (lex->statement == NULL)
 
6415
            Lex->sql_command= SQLCOM_ROLLBACK_TO_SAVEPOINT;
 
6416
            Lex->statement= new(std::nothrow) statement::RollbackToSavepoint(YYSession);
 
6417
            if (Lex->statement == NULL)
6490
6418
              DRIZZLE_YYABORT;
6491
 
            lex->ident= $5;
 
6419
            Lex->ident= $5;
6492
6420
          }
6493
6421
        ;
6494
6422
 
6495
6423
savepoint:
6496
6424
          SAVEPOINT_SYM ident
6497
6425
          {
6498
 
            LEX *lex=Lex;
6499
 
            lex->sql_command= SQLCOM_SAVEPOINT;
6500
 
            lex->statement= new(std::nothrow) statement::Savepoint(YYSession);
6501
 
            if (lex->statement == NULL)
 
6426
            Lex->sql_command= SQLCOM_SAVEPOINT;
 
6427
            Lex->statement= new(std::nothrow) statement::Savepoint(YYSession);
 
6428
            if (Lex->statement == NULL)
6502
6429
              DRIZZLE_YYABORT;
6503
 
            lex->ident= $2;
 
6430
            Lex->ident= $2;
6504
6431
          }
6505
6432
        ;
6506
6433
 
6507
6434
release:
6508
6435
          RELEASE_SYM SAVEPOINT_SYM ident
6509
6436
          {
6510
 
            LEX *lex=Lex;
6511
 
            lex->sql_command= SQLCOM_RELEASE_SAVEPOINT;
6512
 
            lex->statement= new(std::nothrow) statement::ReleaseSavepoint(YYSession);
6513
 
            if (lex->statement == NULL)
 
6437
            Lex->sql_command= SQLCOM_RELEASE_SAVEPOINT;
 
6438
            Lex->statement= new(std::nothrow) statement::ReleaseSavepoint(YYSession);
 
6439
            if (Lex->statement == NULL)
6514
6440
              DRIZZLE_YYABORT;
6515
 
            lex->ident= $3;
 
6441
            Lex->ident= $3;
6516
6442
          }
6517
6443
        ;
6518
6444
 
6550
6476
 
6551
6477
union_order_or_limit:
6552
6478
          {
6553
 
            LEX *lex= YYSession->lex;
6554
 
            assert(lex->current_select->linkage != GLOBAL_OPTIONS_TYPE);
6555
 
            Select_Lex *sel= lex->current_select;
 
6479
            assert(Lex->current_select->linkage != GLOBAL_OPTIONS_TYPE);
 
6480
            Select_Lex *sel= Lex->current_select;
6556
6481
            Select_Lex_Unit *unit= sel->master_unit();
6557
6482
            Select_Lex *fake= unit->fake_select_lex;
6558
6483
            if (fake)
6559
6484
            {
6560
6485
              unit->global_parameters= fake;
6561
6486
              fake->no_table_names_allowed= 1;
6562
 
              lex->current_select= fake;
 
6487
              Lex->current_select= fake;
6563
6488
            }
6564
6489
            YYSession->where= "global ORDER clause";
6565
6490
          }
6617
6542
 
6618
6543
subselect_start:
6619
6544
          {
6620
 
            LEX *lex=Lex;
6621
 
            if (!lex->expr_allows_subselect)
 
6545
            if (not Lex->expr_allows_subselect)
6622
6546
            {
6623
6547
              struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
6624
6548
              my_parse_error(&pass);
6638
6562
 
6639
6563
subselect_end:
6640
6564
          {
6641
 
            LEX *lex=Lex;
6642
 
            lex->pop_context();
6643
 
            Select_Lex *child= lex->current_select;
6644
 
            lex->current_select = lex->current_select->return_after_parsing();
6645
 
            lex->nest_level--;
6646
 
            lex->current_select->n_child_sum_items += child->n_sum_items;
 
6565
            Lex->pop_context();
 
6566
            Select_Lex *child= Lex->current_select;
 
6567
            Lex->current_select= Lex->current_select->return_after_parsing();
 
6568
            Lex->nest_level--;
 
6569
            Lex->current_select->n_child_sum_items += child->n_sum_items;
6647
6570
            /*
6648
6571
              A subselect can add fields to an outer select. Reserve space for
6649
6572
              them.
6650
6573
            */
6651
 
            lex->current_select->select_n_where_fields+=
 
6574
            Lex->current_select->select_n_where_fields+=
6652
6575
            child->select_n_where_fields;
6653
6576
          }
6654
6577
        ;