~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_yacc.yy

Updates based on code review from Jay.

- modified the SqlCommand base class to be abstract
- created new directory (command) where each command implementation will be
  placed in a separate file
- created namespace for various commands (drizzled::command)

Show diffs side-by-side

added added

removed removed

Lines of Context:
88
88
#include <drizzled/function/get_system_var.h>
89
89
#include <mysys/thr_lock.h>
90
90
#include <drizzled/message/table.pb.h>
91
 
#include <drizzled/sql_commands.h>
 
91
#include <drizzled/command.h>
 
92
#include <drizzled/command/show_status.h>
 
93
#include <drizzled/command/default_select.h>
92
94
 
93
 
using namespace drizzled;
 
95
using namespace drizzled::command;
94
96
 
95
97
class Table_ident;
96
98
class Item;
2502
2504
          {
2503
2505
            LEX *lex= Lex;
2504
2506
            lex->sql_command= SQLCOM_SELECT;
2505
 
            lex->command= new SqlCommand(SQLCOM_SELECT, YYSession);
 
2507
            lex->command= new DefaultSelect(SQLCOM_SELECT, 
 
2508
                                            YYSession,
 
2509
                                            lex->query_tables);
2506
2510
            if (lex->command == NULL)
2507
2511
              DRIZZLE_YYABORT;
2508
2512
          }
4765
4769
           {
4766
4770
             LEX *lex= Lex;
4767
4771
             lex->sql_command= SQLCOM_SHOW_DATABASES;
4768
 
             lex->command= new SqlCommand(SQLCOM_SHOW_DATABASES, YYSession);
 
4772
             lex->command= new DefaultSelect(SQLCOM_SHOW_DATABASES, 
 
4773
                                             YYSession,
 
4774
                                             lex->query_tables);
4769
4775
             if (lex->command == NULL)
4770
4776
               DRIZZLE_YYABORT;
4771
4777
             if (prepare_schema_table(YYSession, lex, 0, "SCHEMATA"))
4775
4781
           {
4776
4782
             LEX *lex= Lex;
4777
4783
             lex->sql_command= SQLCOM_SHOW_TABLES;
4778
 
             lex->command= new SqlCommand(SQLCOM_SHOW_TABLES, YYSession);
 
4784
             lex->command= new DefaultSelect(SQLCOM_SHOW_TABLES, 
 
4785
                                             YYSession,
 
4786
                                             lex->query_tables);
4779
4787
             if (lex->command == NULL)
4780
4788
               DRIZZLE_YYABORT;
4781
4789
             lex->select_lex.db= $3;
4786
4794
           {
4787
4795
             LEX *lex= Lex;
4788
4796
             lex->sql_command= SQLCOM_SHOW_TABLE_STATUS;
4789
 
             lex->command= new SqlCommand(SQLCOM_SHOW_TABLE_STATUS,
4790
 
                                          YYSession);
 
4797
             lex->command= new DefaultSelect(SQLCOM_SHOW_TABLE_STATUS,
 
4798
                                             YYSession,
 
4799
                                             lex->query_tables);
4791
4800
             if (lex->command == NULL)
4792
4801
               DRIZZLE_YYABORT;
4793
4802
             lex->select_lex.db= $3;
4798
4807
          {
4799
4808
            LEX *lex= Lex;
4800
4809
            lex->sql_command= SQLCOM_SHOW_OPEN_TABLES;
4801
 
            lex->command= new SqlCommand(SQLCOM_SHOW_OPEN_TABLES,
4802
 
                                         YYSession);
 
4810
            lex->command= new DefaultSelect(SQLCOM_SHOW_OPEN_TABLES,
 
4811
                                            YYSession,
 
4812
                                            lex->query_tables);
4803
4813
            if (lex->command == NULL)
4804
4814
              DRIZZLE_YYABORT;
4805
4815
            lex->select_lex.db= $3;
4815
4825
          {
4816
4826
            LEX *lex= Lex;
4817
4827
            lex->sql_command= SQLCOM_SHOW_FIELDS;
4818
 
            lex->command= new SqlCommand(SQLCOM_SHOW_FIELDS,
4819
 
                                         YYSession);
 
4828
            lex->command= new DefaultSelect(SQLCOM_SHOW_FIELDS,
 
4829
                                            YYSession,
 
4830
                                            lex->query_tables);
4820
4831
            if (lex->command == NULL)
4821
4832
              DRIZZLE_YYABORT;
4822
4833
            if ($5)
4828
4839
          {
4829
4840
            LEX *lex= Lex;
4830
4841
            lex->sql_command= SQLCOM_SHOW_KEYS;
4831
 
            lex->command= new SqlCommand(SQLCOM_SHOW_KEYS, YYSession);
 
4842
            lex->command= new DefaultSelect(SQLCOM_SHOW_KEYS, 
 
4843
                                            YYSession,
 
4844
                                            lex->query_tables);
4832
4845
            if (lex->command == NULL)
4833
4846
              DRIZZLE_YYABORT;
4834
4847
            if ($4)
4840
4853
          { 
4841
4854
            (void) create_select_for_variable("warning_count"); 
4842
4855
            LEX *lex= Lex;
4843
 
            lex->command= new SqlCommand(SQLCOM_SELECT, YYSession);
 
4856
            lex->command= new DefaultSelect(SQLCOM_SELECT, 
 
4857
                                            YYSession,
 
4858
                                            lex->query_tables);
4844
4859
            if (lex->command == NULL)
4845
4860
              DRIZZLE_YYABORT;
4846
4861
          }
4848
4863
          { 
4849
4864
            (void) create_select_for_variable("error_count"); 
4850
4865
            LEX *lex= Lex;
4851
 
            lex->command= new SqlCommand(SQLCOM_SELECT, YYSession);
 
4866
            lex->command= new DefaultSelect(SQLCOM_SELECT, 
 
4867
                                            YYSession,
 
4868
                                            lex->query_tables);
4852
4869
            if (lex->command == NULL)
4853
4870
              DRIZZLE_YYABORT;
4854
4871
          }
4860
4877
          {
4861
4878
            LEX *lex= Lex;
4862
4879
            lex->sql_command= SQLCOM_SHOW_STATUS;
4863
 
            lex->command= new ShowStatusCommand(SQLCOM_SHOW_STATUS,
4864
 
                                                YYSession);
 
4880
            lex->command= new ShowStatus(SQLCOM_SHOW_STATUS,
 
4881
                                         YYSession,
 
4882
                                         lex->query_tables,
 
4883
                                         &LOCK_status);
4865
4884
            if (lex->command == NULL)
4866
4885
              DRIZZLE_YYABORT;
4867
4886
            lex->option_type= $1;
4874
4893
          {
4875
4894
            LEX *lex= Lex;
4876
4895
            lex->sql_command= SQLCOM_SHOW_VARIABLES;
4877
 
            lex->command= new SqlCommand(SQLCOM_SHOW_VARIABLES, YYSession);
 
4896
            lex->command= new DefaultSelect(SQLCOM_SHOW_VARIABLES, 
 
4897
                                            YYSession,
 
4898
                                            lex->query_tables);
4878
4899
            if (lex->command == NULL)
4879
4900
              DRIZZLE_YYABORT;
4880
4901
            lex->option_type= $1;