~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_yacc.yy

  • Committer: Brian Aker
  • Date: 2010-02-25 07:54:52 UTC
  • mfrom: (1273.13.101 build)
  • Revision ID: brian@gaz-20100225075452-19eozreshbrerypu
Merge of all patches in build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1037
1037
            statement->create_info.default_table_charset= NULL;
1038
1038
            lex->name.str= 0;
1039
1039
 
1040
 
            message::Table *proto= &statement->create_table_proto;
 
1040
            message::Table &proto= statement->create_table_proto;
1041
1041
           
1042
 
            proto->set_name($5->table.str);
 
1042
            proto.set_name($5->table.str);
1043
1043
            if($2)
1044
 
              proto->set_type(message::Table::TEMPORARY);
 
1044
              proto.set_type(message::Table::TEMPORARY);
1045
1045
            else
1046
 
              proto->set_type(message::Table::STANDARD);
 
1046
              proto.set_type(message::Table::STANDARD);
1047
1047
          }
1048
1048
          create2
1049
1049
          {
4748
4748
 
4749
4749
              if ($2)
4750
4750
              {
4751
 
                message::Schema schema_message;
4752
4751
                column_name.append($2);
4753
4752
                lex->select_lex.db= $2;
4754
 
                if (not plugin::StorageEngine::getSchemaDefinition($2, schema_message))
 
4753
                if (not plugin::StorageEngine::doesSchemaExist($2))
4755
4754
                {
4756
4755
                  my_error(ER_BAD_DB_ERROR, MYF(0), $2);
4757
4756
                }
4801
4800
 
4802
4801
             if ($3)
4803
4802
             {
4804
 
               message::Schema schema_message;
4805
4803
               lex->select_lex.db= $3;
4806
4804
 
4807
 
               if (not plugin::StorageEngine::getSchemaDefinition($3, schema_message))
 
4805
               if (not plugin::StorageEngine::doesSchemaExist($3))
4808
4806
               {
4809
4807
                 my_error(ER_BAD_DB_ERROR, MYF(0), $3);
4810
4808
               }
4821
4819
           }
4822
4820
        | COLUMNS from_or_in table_ident opt_db show_wild
4823
4821
          {
4824
 
            LEX *lex= Lex;
4825
 
            lex->sql_command= SQLCOM_SHOW_FIELDS;
4826
 
            lex->statement=
4827
 
              new(std::nothrow) statement::Select(YYSession);
4828
 
            if (lex->statement == NULL)
4829
 
              DRIZZLE_YYABORT;
4830
 
            if ($4)
4831
 
              $3->change_db($4);
4832
 
            if (prepare_schema_table(YYSession, lex, $3, "OLD_COLUMNS"))
4833
 
              DRIZZLE_YYABORT;
 
4822
            Item_field *my_field;
 
4823
             LEX *lex= Lex;
 
4824
             Session *session= YYSession;
 
4825
             statement::Select *select;
 
4826
 
 
4827
             lex->sql_command= SQLCOM_SELECT;
 
4828
 
 
4829
             select= new(std::nothrow) statement::Select(session);
 
4830
 
 
4831
             lex->statement= select;
 
4832
 
 
4833
             if (lex->statement == NULL)
 
4834
               DRIZZLE_YYABORT;
 
4835
 
 
4836
             if ($4)
 
4837
              select->setShowPredicate($4, $3->table.str);
 
4838
             else if ($3->db.str)
 
4839
              select->setShowPredicate($3->db.str, $3->table.str);
 
4840
             else
 
4841
              select->setShowPredicate(session->db, $3->table.str);
 
4842
 
 
4843
             {
 
4844
               drizzled::TableIdentifier identifier(select->getShowSchema().c_str(), $3->table.str);
 
4845
               if (plugin::StorageEngine::getTableDefinition(*session, identifier) != EEXIST)
 
4846
               {
 
4847
                   my_error(ER_NO_SUCH_TABLE, MYF(0),
 
4848
                            select->getShowSchema().c_str(), 
 
4849
                            $3->table.str);
 
4850
               }
 
4851
             }
 
4852
 
 
4853
             if (prepare_new_schema_table(session, lex, "COLUMNS"))
 
4854
               DRIZZLE_YYABORT;
 
4855
 
 
4856
             my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "COLUMN_NAME");
 
4857
             my_field->is_autogenerated_name= false;
 
4858
             my_field->set_name("Field");
 
4859
             if (session->add_item_to_list(my_field))
 
4860
               DRIZZLE_YYABORT;
 
4861
 
 
4862
             my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "DATA_TYPE");
 
4863
             my_field->is_autogenerated_name= false;
 
4864
             my_field->set_name("Type");
 
4865
             if (session->add_item_to_list(my_field))
 
4866
               DRIZZLE_YYABORT;
 
4867
 
 
4868
             my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "IS_NULLABLE");
 
4869
             my_field->is_autogenerated_name= false;
 
4870
             my_field->set_name("Null");
 
4871
             if (session->add_item_to_list(my_field))
 
4872
               DRIZZLE_YYABORT;
 
4873
 
 
4874
             my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "COLUMN_DEFAULT");
 
4875
             my_field->is_autogenerated_name= false;
 
4876
             my_field->set_name("Default");
 
4877
             if (session->add_item_to_list(my_field))
 
4878
               DRIZZLE_YYABORT;
 
4879
 
 
4880
             my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "COLUMN_DEFAULT_IS_NULL");
 
4881
             my_field->is_autogenerated_name= false;
 
4882
             my_field->set_name("Default is NULL");
 
4883
             if (session->add_item_to_list(my_field))
 
4884
               DRIZZLE_YYABORT;
 
4885
 
 
4886
             my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "COLUMN_DEFAULT_UPDATE");
 
4887
             my_field->is_autogenerated_name= false;
 
4888
             my_field->set_name("On Update");
 
4889
             if (session->add_item_to_list(my_field))
 
4890
               DRIZZLE_YYABORT;
4834
4891
          }
4835
4892
        | keys_or_index from_or_in table_ident opt_db where_clause
4836
4893
          {
4837
 
            LEX *lex= Lex;
4838
 
            lex->sql_command= SQLCOM_SHOW_KEYS;
4839
 
            lex->statement= new(std::nothrow) statement::Select(YYSession);
4840
 
            if (lex->statement == NULL)
4841
 
              DRIZZLE_YYABORT;
4842
 
            if ($4)
4843
 
              $3->change_db($4);
4844
 
            if (prepare_schema_table(YYSession, lex, $3, "OLD_STATISTICS"))
4845
 
              DRIZZLE_YYABORT;
 
4894
            Item_field *my_field;
 
4895
             LEX *lex= Lex;
 
4896
             Session *session= YYSession;
 
4897
             statement::Select *select;
 
4898
 
 
4899
             lex->sql_command= SQLCOM_SELECT;
 
4900
 
 
4901
             select= new(std::nothrow) statement::Select(session);
 
4902
 
 
4903
             lex->statement= select;
 
4904
 
 
4905
             if (lex->statement == NULL)
 
4906
               DRIZZLE_YYABORT;
 
4907
 
 
4908
             if ($4)
 
4909
              select->setShowPredicate($4, $3->table.str);
 
4910
             else if ($3->db.str)
 
4911
              select->setShowPredicate($3->db.str, $3->table.str);
 
4912
             else
 
4913
              select->setShowPredicate(session->db, $3->table.str);
 
4914
 
 
4915
             {
 
4916
               drizzled::TableIdentifier identifier(select->getShowSchema().c_str(), $3->table.str);
 
4917
               if (plugin::StorageEngine::getTableDefinition(*session, identifier) != EEXIST)
 
4918
               {
 
4919
                   my_error(ER_NO_SUCH_TABLE, MYF(0),
 
4920
                            select->getShowSchema().c_str(), 
 
4921
                            $3->table.str);
 
4922
               }
 
4923
             }
 
4924
 
 
4925
             if (prepare_new_schema_table(session, lex, "INDEX_PARTS"))
 
4926
               DRIZZLE_YYABORT;
 
4927
 
 
4928
             my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "TABLE_NAME");
 
4929
             my_field->is_autogenerated_name= false;
 
4930
             my_field->set_name("Table");
 
4931
             if (session->add_item_to_list(my_field))
 
4932
               DRIZZLE_YYABORT;
 
4933
 
 
4934
#if 0
 
4935
             my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "IS_UNIQUE");
 
4936
             my_field->is_autogenerated_name= false;
 
4937
             my_field->set_name("Non_unique");
 
4938
             if (session->add_item_to_list(my_field))
 
4939
               DRIZZLE_YYABORT;
 
4940
#endif
 
4941
 
 
4942
             my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "INDEX_NAME");
 
4943
             my_field->is_autogenerated_name= false;
 
4944
             my_field->set_name("Key_name");
 
4945
             if (session->add_item_to_list(my_field))
 
4946
               DRIZZLE_YYABORT;
 
4947
 
 
4948
             my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "SEQUENCE_IN_INDEX");
 
4949
             my_field->is_autogenerated_name= false;
 
4950
             my_field->set_name("Seq_in_index");
 
4951
             if (session->add_item_to_list(my_field))
 
4952
               DRIZZLE_YYABORT;
 
4953
 
 
4954
             my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "COLUMN_NAME");
 
4955
             my_field->is_autogenerated_name= false;
 
4956
             my_field->set_name("Column_name");
 
4957
             if (session->add_item_to_list(my_field))
 
4958
               DRIZZLE_YYABORT;
4846
4959
          }
4847
4960
        | COUNT_SYM '(' '*' ')' WARNINGS
4848
4961
          {
5026
5139
describe:
5027
5140
          describe_command table_ident
5028
5141
          {
 
5142
            Item_field *my_field;
 
5143
            Session *session= YYSession;
 
5144
            statement::Select *select;
5029
5145
            LEX *lex= Lex;
5030
5146
            lex->lock_option= TL_READ;
5031
5147
            mysql_init_select(lex);
5032
5148
            lex->current_select->parsing_place= SELECT_LIST;
5033
 
            lex->sql_command= SQLCOM_SHOW_FIELDS;
5034
 
            lex->statement= new(std::nothrow) statement::Select(YYSession);
 
5149
            lex->sql_command= SQLCOM_SELECT;
 
5150
            select= new(std::nothrow) statement::Select(session);
 
5151
            lex->statement= select;
5035
5152
            if (lex->statement == NULL)
5036
5153
              DRIZZLE_YYABORT;
5037
5154
            lex->select_lex.db= 0;
5038
 
            if (prepare_schema_table(YYSession, lex, $2, "OLD_COLUMNS"))
5039
 
              DRIZZLE_YYABORT;
 
5155
 
 
5156
             if ($2->db.str)
 
5157
              select->setShowPredicate($2->db.str, $2->table.str);
 
5158
             else
 
5159
              select->setShowPredicate(session->db, $2->table.str);
 
5160
 
 
5161
             {
 
5162
               drizzled::TableIdentifier identifier(select->getShowSchema().c_str(), $2->table.str);
 
5163
               if (plugin::StorageEngine::getTableDefinition(*session, identifier) != EEXIST)
 
5164
               {
 
5165
                   my_error(ER_NO_SUCH_TABLE, MYF(0),
 
5166
                            select->getShowSchema().c_str(), 
 
5167
                            $2->table.str);
 
5168
               }
 
5169
             }
 
5170
 
 
5171
             if (prepare_new_schema_table(session, lex, "COLUMNS"))
 
5172
               DRIZZLE_YYABORT;
 
5173
 
 
5174
             my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "COLUMN_NAME");
 
5175
             my_field->is_autogenerated_name= false;
 
5176
             my_field->set_name("Field");
 
5177
             if (session->add_item_to_list(my_field))
 
5178
               DRIZZLE_YYABORT;
 
5179
 
 
5180
             my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "DATA_TYPE");
 
5181
             my_field->is_autogenerated_name= false;
 
5182
             my_field->set_name("Type");
 
5183
             if (session->add_item_to_list(my_field))
 
5184
               DRIZZLE_YYABORT;
 
5185
 
 
5186
             my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "IS_NULLABLE");
 
5187
             my_field->is_autogenerated_name= false;
 
5188
             my_field->set_name("Null");
 
5189
             if (session->add_item_to_list(my_field))
 
5190
               DRIZZLE_YYABORT;
 
5191
 
 
5192
             my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "COLUMN_DEFAULT");
 
5193
             my_field->is_autogenerated_name= false;
 
5194
             my_field->set_name("Default");
 
5195
             if (session->add_item_to_list(my_field))
 
5196
               DRIZZLE_YYABORT;
 
5197
 
 
5198
             my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "COLUMN_DEFAULT_IS_NULL");
 
5199
             my_field->is_autogenerated_name= false;
 
5200
             my_field->set_name("Default is NULL");
 
5201
             if (session->add_item_to_list(my_field))
 
5202
               DRIZZLE_YYABORT;
 
5203
 
 
5204
             my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "COLUMN_DEFAULT_UPDATE");
 
5205
             my_field->is_autogenerated_name= false;
 
5206
             my_field->set_name("On Update");
 
5207
             if (session->add_item_to_list(my_field))
 
5208
               DRIZZLE_YYABORT;
5040
5209
          }
5041
5210
          opt_describe_column {}
5042
5211
        | describe_command opt_extended_describe