~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_yacc.yy

  • Committer: Brian Aker
  • Date: 2009-08-17 00:51:17 UTC
  • mfrom: (1115.3.4 captain)
  • Revision ID: brian@gaz-20090817005117-j9der2dkee8pwbw5
Merge Jay

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/checksum.h>
 
92
#include <drizzled/statement/commit.h>
 
93
#include <drizzled/statement/delete.h>
 
94
#include <drizzled/statement/empty_query.h>
 
95
#include <drizzled/statement/load.h>
 
96
#include <drizzled/statement/rollback.h>
 
97
#include <drizzled/statement/select.h>
 
98
#include <drizzled/statement/show_create.h>
 
99
#include <drizzled/statement/show_create_schema.h>
 
100
#include <drizzled/statement/show_engine_status.h>
 
101
#include <drizzled/statement/show_errors.h>
 
102
#include <drizzled/statement/show_processlist.h>
 
103
#include <drizzled/statement/show_status.h>
 
104
#include <drizzled/statement/show_warnings.h>
 
105
#include <drizzled/statement/unlock_tables.h>
103
106
 
104
107
using namespace drizzled;
105
108
 
1075
1078
            else
1076
1079
            {
1077
1080
              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)
 
1081
              session->lex->statement= 
 
1082
                new(std::nothrow) statement::EmptyQuery(YYSession);
 
1083
              if (session->lex->statement == NULL)
1082
1084
                DRIZZLE_YYABORT;
1083
1085
            }
1084
1086
          }
2376
2378
          {
2377
2379
            LEX *lex=Lex;
2378
2380
            lex->sql_command = SQLCOM_CHECKSUM;
2379
 
            lex->command= new(std::nothrow) command::Checksum(SQLCOM_CHECKSUM,
2380
 
                                                              YYSession);
2381
 
            if (lex->command == NULL)
 
2381
            lex->statement= new(std::nothrow) statement::Checksum(YYSession);
 
2382
            if (lex->statement == NULL)
2382
2383
              DRIZZLE_YYABORT;
2383
2384
          }
2384
2385
          table_list opt_checksum_type
2481
2482
          {
2482
2483
            LEX *lex= Lex;
2483
2484
            lex->sql_command= SQLCOM_SELECT;
2484
 
            lex->command= new(std::nothrow) command::Select(SQLCOM_SELECT,
 
2485
            lex->statement= new(std::nothrow) statement::Select(SQLCOM_SELECT,
2485
2486
                                                            YYSession);
2486
 
            if (lex->command == NULL)
 
2487
            if (lex->statement == NULL)
2487
2488
              DRIZZLE_YYABORT;
2488
2489
          }
2489
2490
        ;
4621
4622
          {
4622
4623
            LEX *lex= Lex;
4623
4624
            lex->sql_command= SQLCOM_DELETE;
 
4625
            lex->statement= new(std::nothrow) statement::Delete(YYSession);
 
4626
            if (lex->statement == NULL)
 
4627
              DRIZZLE_YYABORT;
4624
4628
            mysql_init_select(lex);
4625
4629
            lex->lock_option= TL_WRITE_DEFAULT;
4626
4630
            lex->ignore= 0;
4686
4690
           {
4687
4691
             LEX *lex= Lex;
4688
4692
             lex->sql_command= SQLCOM_SHOW_DATABASES;
4689
 
             lex->command=
4690
 
               new(std::nothrow) command::Select(SQLCOM_SHOW_DATABASES, 
 
4693
             lex->statement=
 
4694
               new(std::nothrow) statement::Select(SQLCOM_SHOW_DATABASES, 
4691
4695
                                                 YYSession);
4692
 
             if (lex->command == NULL)
 
4696
             if (lex->statement == NULL)
4693
4697
               DRIZZLE_YYABORT;
4694
4698
             if (prepare_schema_table(YYSession, lex, 0, "SCHEMATA"))
4695
4699
               DRIZZLE_YYABORT;
4698
4702
           {
4699
4703
             LEX *lex= Lex;
4700
4704
             lex->sql_command= SQLCOM_SHOW_TABLES;
4701
 
             lex->command=
4702
 
               new(std::nothrow) command::Select(SQLCOM_SHOW_TABLES,
 
4705
             lex->statement=
 
4706
               new(std::nothrow) statement::Select(SQLCOM_SHOW_TABLES,
4703
4707
                                                 YYSession);
4704
 
             if (lex->command == NULL)
 
4708
             if (lex->statement == NULL)
4705
4709
               DRIZZLE_YYABORT;
4706
4710
             lex->select_lex.db= $3;
4707
4711
             if (prepare_schema_table(YYSession, lex, 0, "TABLE_NAMES"))
4711
4715
           {
4712
4716
             LEX *lex= Lex;
4713
4717
             lex->sql_command= SQLCOM_SHOW_TABLE_STATUS;
4714
 
             lex->command=
4715
 
               new(std::nothrow) command::Select(SQLCOM_SHOW_TABLE_STATUS,
 
4718
             lex->statement=
 
4719
               new(std::nothrow) statement::Select(SQLCOM_SHOW_TABLE_STATUS,
4716
4720
                                                 YYSession);
4717
 
             if (lex->command == NULL)
 
4721
             if (lex->statement == NULL)
4718
4722
               DRIZZLE_YYABORT;
4719
4723
             lex->select_lex.db= $3;
4720
4724
             if (prepare_schema_table(YYSession, lex, 0, "TABLES"))
4724
4728
          {
4725
4729
            LEX *lex= Lex;
4726
4730
            lex->sql_command= SQLCOM_SHOW_OPEN_TABLES;
4727
 
            lex->command=
4728
 
              new(std::nothrow) command::Select(SQLCOM_SHOW_OPEN_TABLES,
 
4731
            lex->statement=
 
4732
              new(std::nothrow) statement::Select(SQLCOM_SHOW_OPEN_TABLES,
4729
4733
                                                YYSession);
4730
 
            if (lex->command == NULL)
 
4734
            if (lex->statement == NULL)
4731
4735
              DRIZZLE_YYABORT;
4732
4736
            lex->select_lex.db= $3;
4733
4737
            if (prepare_schema_table(YYSession, lex, 0, "OPEN_TABLES"))
4737
4741
          { 
4738
4742
            Lex->show_engine= $2; 
4739
4743
            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)
 
4744
            Lex->statement= 
 
4745
              new(std::nothrow) statement::ShowEngineStatus(YYSession);
 
4746
            if (Lex->statement == NULL)
4744
4747
              DRIZZLE_YYABORT;
4745
4748
          }
4746
4749
        | opt_full COLUMNS from_or_in table_ident opt_db show_wild
4747
4750
          {
4748
4751
            LEX *lex= Lex;
4749
4752
            lex->sql_command= SQLCOM_SHOW_FIELDS;
4750
 
            lex->command=
4751
 
              new(std::nothrow) command::Select(SQLCOM_SHOW_FIELDS, YYSession);
4752
 
            if (lex->command == NULL)
 
4753
            lex->statement=
 
4754
              new(std::nothrow) statement::Select(SQLCOM_SHOW_FIELDS, YYSession);
 
4755
            if (lex->statement == NULL)
4753
4756
              DRIZZLE_YYABORT;
4754
4757
            if ($5)
4755
4758
              $4->change_db($5);
4760
4763
          {
4761
4764
            LEX *lex= Lex;
4762
4765
            lex->sql_command= SQLCOM_SHOW_KEYS;
4763
 
            lex->command= new(std::nothrow) command::Select(SQLCOM_SHOW_KEYS,
 
4766
            lex->statement= new(std::nothrow) statement::Select(SQLCOM_SHOW_KEYS,
4764
4767
                                                            YYSession);
4765
 
            if (lex->command == NULL)
 
4768
            if (lex->statement == NULL)
4766
4769
              DRIZZLE_YYABORT;
4767
4770
            if ($4)
4768
4771
              $3->change_db($4);
4773
4776
          { 
4774
4777
            (void) create_select_for_variable("warning_count"); 
4775
4778
            LEX *lex= Lex;
4776
 
            lex->command= new(std::nothrow) command::Select(SQLCOM_SELECT,
 
4779
            lex->statement= new(std::nothrow) statement::Select(SQLCOM_SELECT,
4777
4780
                                                            YYSession);
4778
 
            if (lex->command == NULL)
 
4781
            if (lex->statement == NULL)
4779
4782
              DRIZZLE_YYABORT;
4780
4783
          }
4781
4784
        | COUNT_SYM '(' '*' ')' ERRORS
4782
4785
          { 
4783
4786
            (void) create_select_for_variable("error_count"); 
4784
4787
            LEX *lex= Lex;
4785
 
            lex->command= new(std::nothrow) command::Select(SQLCOM_SELECT,
 
4788
            lex->statement= new(std::nothrow) statement::Select(SQLCOM_SELECT,
4786
4789
                                                            YYSession);
4787
 
            if (lex->command == NULL)
 
4790
            if (lex->statement == NULL)
4788
4791
              DRIZZLE_YYABORT;
4789
4792
          }
4790
4793
        | WARNINGS opt_limit_clause_init
4791
4794
          { 
4792
4795
            Lex->sql_command = SQLCOM_SHOW_WARNS;
4793
 
            Lex->command= new(std::nothrow) command::ShowWarnings(SQLCOM_SHOW_WARNS,
4794
 
                                                                  YYSession);
4795
 
            if (Lex->command == NULL)
 
4796
            Lex->statement= new(std::nothrow) statement::ShowWarnings(YYSession);
 
4797
            if (Lex->statement == NULL)
4796
4798
              DRIZZLE_YYABORT;
4797
4799
          }
4798
4800
        | ERRORS opt_limit_clause_init
4799
4801
          { 
4800
4802
            Lex->sql_command = SQLCOM_SHOW_ERRORS;
4801
 
            Lex->command= new(std::nothrow) command::ShowErrors(SQLCOM_SHOW_ERRORS,
4802
 
                                                                YYSession);
4803
 
            if (Lex->command == NULL)
 
4803
            Lex->statement= new(std::nothrow) statement::ShowErrors(YYSession);
 
4804
            if (Lex->statement == NULL)
4804
4805
              DRIZZLE_YYABORT;
4805
4806
          }
4806
4807
        | opt_var_type STATUS_SYM show_wild
4807
4808
          {
4808
4809
            LEX *lex= Lex;
4809
4810
            lex->sql_command= SQLCOM_SHOW_STATUS;
4810
 
            lex->command=
4811
 
              new(std::nothrow) command::ShowStatus(SQLCOM_SHOW_STATUS,
4812
 
                                                    YYSession,
 
4811
            lex->statement=
 
4812
              new(std::nothrow) statement::ShowStatus(YYSession,
4813
4813
                                                    &LOCK_status);
4814
 
            if (lex->command == NULL)
 
4814
            if (lex->statement == NULL)
4815
4815
              DRIZZLE_YYABORT;
4816
4816
            lex->option_type= $1;
4817
4817
            if (prepare_schema_table(YYSession, lex, 0, "STATUS"))
4820
4820
        | opt_full PROCESSLIST_SYM
4821
4821
          { 
4822
4822
            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)
 
4823
            Lex->statement= 
 
4824
              new(std::nothrow) statement::ShowProcesslist(YYSession);
 
4825
            if (Lex->statement == NULL)
4827
4826
              DRIZZLE_YYABORT;
4828
4827
          }
4829
4828
        | opt_var_type  VARIABLES show_wild
4830
4829
          {
4831
4830
            LEX *lex= Lex;
4832
4831
            lex->sql_command= SQLCOM_SHOW_VARIABLES;
4833
 
            lex->command=
4834
 
              new(std::nothrow) command::Select(SQLCOM_SHOW_VARIABLES, 
 
4832
            lex->statement=
 
4833
              new(std::nothrow) statement::Select(SQLCOM_SHOW_VARIABLES, 
4835
4834
                                                YYSession);
4836
 
            if (lex->command == NULL)
 
4835
            if (lex->statement == NULL)
4837
4836
              DRIZZLE_YYABORT;
4838
4837
            lex->option_type= $1;
4839
4838
            if (prepare_schema_table(YYSession, lex, 0, "VARIABLES"))
4842
4841
        | CREATE DATABASE opt_if_not_exists ident
4843
4842
          {
4844
4843
            Lex->sql_command=SQLCOM_SHOW_CREATE_DB;
 
4844
            Lex->statement= new(std::nothrow) statement::ShowCreateSchema(YYSession);
 
4845
            if (Lex->statement == NULL)
 
4846
              DRIZZLE_YYABORT;
4845
4847
            Lex->create_info.options=$3;
4846
4848
            Lex->name= $4;
4847
4849
          }
4849
4851
          {
4850
4852
            LEX *lex= Lex;
4851
4853
            lex->sql_command = SQLCOM_SHOW_CREATE;
4852
 
            lex->command= new(std::nothrow) command::ShowCreate(SQLCOM_SHOW_CREATE,
4853
 
                                                                YYSession);
4854
 
            if (lex->command == NULL)
 
4854
            lex->statement= new(std::nothrow) statement::ShowCreate(YYSession);
 
4855
            if (lex->statement == NULL)
4855
4856
              DRIZZLE_YYABORT;
4856
4857
            if (!lex->select_lex.add_table_to_list(YYSession, $3, NULL,0))
4857
4858
              DRIZZLE_YYABORT;
4898
4899
            mysql_init_select(lex);
4899
4900
            lex->current_select->parsing_place= SELECT_LIST;
4900
4901
            lex->sql_command= SQLCOM_SHOW_FIELDS;
4901
 
            lex->command= new(std::nothrow) command::Select(SQLCOM_SHOW_FIELDS,
 
4902
            lex->statement= new(std::nothrow) statement::Select(SQLCOM_SHOW_FIELDS,
4902
4903
                                                            YYSession);
4903
 
            if (lex->command == NULL)
 
4904
            if (lex->statement == NULL)
4904
4905
              DRIZZLE_YYABORT;
4905
4906
            lex->select_lex.db= 0;
4906
4907
            lex->verbose= 0;
5018
5019
          {
5019
5020
            LEX *lex=Lex;
5020
5021
            lex->sql_command= SQLCOM_LOAD;
5021
 
            lex->command= new(std::nothrow) command::Load(SQLCOM_LOAD,
5022
 
                                                          YYSession);
5023
 
            if (lex->command == NULL)
 
5022
            lex->statement= new(std::nothrow) statement::Load(YYSession);
 
5023
            if (lex->statement == NULL)
5024
5024
              DRIZZLE_YYABORT;
5025
5025
            lex->lock_option= $4;
5026
5026
            lex->duplicates= DUP_ERROR;
5849
5849
          {
5850
5850
            LEX *lex= Lex;
5851
5851
            lex->sql_command= SQLCOM_UNLOCK_TABLES;
 
5852
            lex->statement= new(std::nothrow) statement::UnlockTables(YYSession);
 
5853
            if (lex->statement == NULL)
 
5854
              DRIZZLE_YYABORT;
5852
5855
          }
5853
5856
          table_or_tables
5854
5857
          {}
5893
5896
          {
5894
5897
            LEX *lex=Lex;
5895
5898
            lex->sql_command= SQLCOM_COMMIT;
5896
 
            lex->command= new(std::nothrow) command::Commit(SQLCOM_COMMIT,
5897
 
                                                            YYSession);
5898
 
            if (lex->command == NULL)
 
5899
            lex->statement= new(std::nothrow) statement::Commit(YYSession);
 
5900
            if (lex->statement == NULL)
5899
5901
              DRIZZLE_YYABORT;
5900
5902
            lex->tx_chain= $3; 
5901
5903
            lex->tx_release= $4;
5907
5909
          {
5908
5910
            LEX *lex=Lex;
5909
5911
            lex->sql_command= SQLCOM_ROLLBACK;
5910
 
            lex->command= new(std::nothrow) command::Rollback(SQLCOM_ROLLBACK,
5911
 
                                                              YYSession);
5912
 
            if (lex->command == NULL)
 
5912
            lex->statement= new(std::nothrow) statement::Rollback(YYSession);
 
5913
            if (lex->statement == NULL)
5913
5914
              DRIZZLE_YYABORT;
5914
5915
            lex->tx_chain= $3; 
5915
5916
            lex->tx_release= $4;