~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_yacc.yy

Merging change info_schema changes.

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