~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_yacc.yy

  • Committer: Brian Aker
  • Date: 2011-01-21 18:46:44 UTC
  • mto: This revision was merged to the branch mainline in revision 2102.
  • Revision ID: brian@tangent.org-20110121184644-d3ibhdfldcviagzl
Additional show to functions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4868
4868
           }
4869
4869
           /* SHOW COLUMNS FROM table_name */
4870
4870
        | COLUMNS from_or_in table_ident opt_db show_wild
4871
 
          {
4872
 
             Lex->sql_command= SQLCOM_SELECT;
4873
 
 
4874
 
             drizzled::statement::Show *select= new statement::Show(YYSession);
4875
 
             Lex->statement= select;
4876
 
 
4877
 
             util::string::const_shared_ptr schema(YYSession->schema());
4878
 
             if ($4)
4879
 
             {
4880
 
              select->setShowPredicate($4, $3->table.str);
4881
 
             }
4882
 
             else if ($3->db.str)
4883
 
             {
4884
 
              select->setShowPredicate($3->db.str, $3->table.str);
4885
 
             }
4886
 
             else if (schema)
4887
 
             {
4888
 
               select->setShowPredicate(*schema, $3->table.str);
4889
 
             }
4890
 
             else
4891
 
             {
4892
 
               my_error(ER_NO_DB_ERROR, MYF(0));
4893
 
               DRIZZLE_YYABORT;
4894
 
             }
4895
 
 
4896
 
             {
4897
 
               drizzled::identifier::Table identifier(select->getShowSchema().c_str(), $3->table.str);
4898
 
               if (not plugin::StorageEngine::doesTableExist(*YYSession, identifier))
4899
 
               {
4900
 
                   my_error(ER_NO_SUCH_TABLE, MYF(0),
4901
 
                            select->getShowSchema().c_str(), 
4902
 
                            $3->table.str);
4903
 
               }
4904
 
             }
4905
 
 
4906
 
             if (prepare_new_schema_table(YYSession, Lex, "SHOW_COLUMNS"))
4907
 
               DRIZZLE_YYABORT;
4908
 
 
4909
 
             if (YYSession->add_item_to_list( new Item_field(&YYSession->lex->current_select->
4910
 
                                                           context,
4911
 
                                                           NULL, NULL, "*")))
4912
 
               DRIZZLE_YYABORT;
4913
 
             (YYSession->lex->current_select->with_wild)++;
4914
 
 
4915
 
          }
 
4871
           {
 
4872
             if (not show::buildColumns(YYSession, $4, $3))
 
4873
               DRIZZLE_YYABORT;
 
4874
           }
4916
4875
          /* SHOW INDEXES from table */
4917
4876
        | keys_or_index from_or_in table_ident opt_db where_clause
4918
 
          {
4919
 
             Lex->sql_command= SQLCOM_SELECT;
4920
 
             drizzled::statement::Show *select= new statement::Show(YYSession);
4921
 
             Lex->statement= select;
4922
 
 
4923
 
             util::string::const_shared_ptr schema(YYSession->schema());
4924
 
             if ($4)
4925
 
             {
4926
 
              select->setShowPredicate($4, $3->table.str);
4927
 
             }
4928
 
             else if ($3->db.str)
4929
 
             {
4930
 
              select->setShowPredicate($3->db.str, $3->table.str);
4931
 
             }
4932
 
             else if (schema)
4933
 
             {
4934
 
               select->setShowPredicate(*schema, $3->table.str);
4935
 
             }
4936
 
             else
4937
 
             {
4938
 
               my_error(ER_NO_DB_ERROR, MYF(0));
4939
 
               DRIZZLE_YYABORT;
4940
 
             }
4941
 
 
4942
 
             {
4943
 
               drizzled::identifier::Table identifier(select->getShowSchema().c_str(), $3->table.str);
4944
 
               if (not plugin::StorageEngine::doesTableExist(*YYSession, identifier))
4945
 
               {
4946
 
                   my_error(ER_NO_SUCH_TABLE, MYF(0),
4947
 
                            select->getShowSchema().c_str(), 
4948
 
                            $3->table.str);
4949
 
               }
4950
 
             }
4951
 
 
4952
 
             if (prepare_new_schema_table(YYSession, Lex, "SHOW_INDEXES"))
4953
 
               DRIZZLE_YYABORT;
4954
 
 
4955
 
             if (YYSession->add_item_to_list( new Item_field(&YYSession->lex->current_select->
4956
 
                                                           context,
4957
 
                                                           NULL, NULL, "*")))
4958
 
               DRIZZLE_YYABORT;
4959
 
             (YYSession->lex->current_select->with_wild)++;
4960
 
          }
 
4877
           {
 
4878
             if (not show::buildIndex(YYSession, $4, $3))
 
4879
               DRIZZLE_YYABORT;
 
4880
           }
4961
4881
        | COUNT_SYM '(' '*' ')' WARNINGS
4962
4882
          {
4963
4883
            (void) create_select_for_variable("warning_count");
4979
4899
            Lex->statement= new statement::ShowErrors(YYSession);
4980
4900
          }
4981
4901
        | opt_var_type STATUS_SYM show_wild
4982
 
           {
4983
 
             Lex->sql_command= SQLCOM_SELECT;
4984
 
             Lex->statement= new statement::Show(YYSession);
4985
 
 
4986
 
             if ($1 == OPT_GLOBAL)
4987
 
             {
4988
 
               if (prepare_new_schema_table(YYSession, Lex, "GLOBAL_STATUS"))
4989
 
                 DRIZZLE_YYABORT;
4990
 
             }
4991
 
             else
4992
 
             {
4993
 
               if (prepare_new_schema_table(YYSession, Lex, "SESSION_STATUS"))
4994
 
                 DRIZZLE_YYABORT;
4995
 
             }
4996
 
 
4997
 
             std::string key("Variable_name");
4998
 
             std::string value("Value");
4999
 
 
5000
 
             Item_field *my_field= new Item_field(&YYSession->lex->current_select->context, NULL, NULL, "VARIABLE_NAME");
5001
 
             my_field->is_autogenerated_name= false;
5002
 
             my_field->set_name(key.c_str(), key.length(), system_charset_info);
5003
 
 
5004
 
             if (YYSession->add_item_to_list(my_field))
5005
 
               DRIZZLE_YYABORT;
5006
 
 
5007
 
             my_field= new Item_field(&YYSession->lex->current_select->context, NULL, NULL, "VARIABLE_VALUE");
5008
 
             my_field->is_autogenerated_name= false;
5009
 
             my_field->set_name(value.c_str(), value.length(), system_charset_info);
5010
 
 
5011
 
             if (YYSession->add_item_to_list(my_field))
5012
 
               DRIZZLE_YYABORT;
5013
 
           }
 
4902
          {
 
4903
            if (not show::buildStatus(YYSession, $1))
 
4904
              DRIZZLE_YYABORT;
 
4905
          }
5014
4906
        | CREATE TABLE_SYM table_ident
5015
 
           {
5016
 
             Lex->sql_command= SQLCOM_SELECT;
5017
 
             statement::Show *select= new statement::Show(YYSession);
5018
 
             Lex->statement= select;
5019
 
 
5020
 
             if (Lex->statement == NULL)
5021
 
               DRIZZLE_YYABORT;
5022
 
 
5023
 
             if (prepare_new_schema_table(YYSession, Lex, "TABLE_SQL_DEFINITION"))
5024
 
               DRIZZLE_YYABORT;
5025
 
 
5026
 
             util::string::const_shared_ptr schema(YYSession->schema());
5027
 
             if ($3->db.str)
5028
 
             {
5029
 
               select->setShowPredicate($3->db.str, $3->table.str);
5030
 
             }
5031
 
             else if (schema)
5032
 
             {
5033
 
               select->setShowPredicate(*schema, $3->table.str);
5034
 
             }
5035
 
             else
5036
 
             {
5037
 
               my_error(ER_NO_DB_ERROR, MYF(0));
5038
 
               DRIZZLE_YYABORT;
5039
 
             }
5040
 
 
5041
 
             std::string key("Table");
5042
 
             std::string value("Create Table");
5043
 
 
5044
 
             Item_field *my_field= new Item_field(&YYSession->lex->current_select->context, NULL, NULL, "TABLE_NAME");
5045
 
             my_field->is_autogenerated_name= false;
5046
 
             my_field->set_name(key.c_str(), key.length(), system_charset_info);
5047
 
 
5048
 
             if (YYSession->add_item_to_list(my_field))
5049
 
               DRIZZLE_YYABORT;
5050
 
 
5051
 
             my_field= new Item_field(&YYSession->lex->current_select->context, NULL, NULL, "TABLE_SQL_DEFINITION");
5052
 
             my_field->is_autogenerated_name= false;
5053
 
             my_field->set_name(value.c_str(), value.length(), system_charset_info);
5054
 
 
5055
 
             if (YYSession->add_item_to_list(my_field))
5056
 
               DRIZZLE_YYABORT;
5057
 
           }
 
4907
          {
 
4908
            if (not show::buildCreateTable(YYSession, $3))
 
4909
              DRIZZLE_YYABORT;
 
4910
          }
5058
4911
        | PROCESSLIST_SYM
5059
4912
          {
5060
 
           {
5061
 
             Lex->sql_command= SQLCOM_SELECT;
5062
 
             Lex->statement= new statement::Show(YYSession);
5063
 
 
5064
 
             if (prepare_new_schema_table(YYSession, Lex, "PROCESSLIST"))
5065
 
               DRIZZLE_YYABORT;
5066
 
 
5067
 
             if (YYSession->add_item_to_list( new Item_field(&YYSession->lex->current_select->
5068
 
                                                           context,
5069
 
                                                           NULL, NULL, "*")))
5070
 
               DRIZZLE_YYABORT;
5071
 
             (YYSession->lex->current_select->with_wild)++;
5072
 
           }
 
4913
            if (not show::buildProcesslist(YYSession))
 
4914
              DRIZZLE_YYABORT;
5073
4915
          }
5074
4916
        | opt_var_type  VARIABLES show_wild
5075
4917
          {
5076
4918
            if (not show::buildVariables(YYSession, $1))
5077
 
            {
5078
4919
              DRIZZLE_YYABORT;
5079
 
            }
5080
4920
          }
5081
4921
        | CREATE DATABASE opt_if_not_exists ident
5082
4922
          {
5083
4923
            if (not show::buildCreateSchema(YYSession, $4))
5084
 
            {
5085
4924
              DRIZZLE_YYABORT;
5086
 
            }
5087
4925
          }
5088
4926
 
5089
4927
opt_db: