~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_yacc.yy

Add in new show work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4827
4827
           DATABASES show_wild
4828
4828
           {
4829
4829
             LEX *lex= Lex;
4830
 
             lex->sql_command= SQLCOM_SHOW_DATABASES;
 
4830
             lex->sql_command= SQLCOM_SELECT;
4831
4831
             lex->statement=
4832
4832
               new(std::nothrow) statement::Select(YYSession);
4833
4833
             if (lex->statement == NULL)
4834
4834
               DRIZZLE_YYABORT;
4835
 
             if (prepare_schema_table(YYSession, lex, 0, "OLD_SCHEMATA"))
 
4835
 
 
4836
             Session *session= YYSession;
 
4837
 
 
4838
             std::string column_name= "Database";
 
4839
             if (Lex->wild)
 
4840
             {
 
4841
               column_name.append(" (");
 
4842
               column_name.append(Lex->wild->c_str());
 
4843
               column_name.append(")");
 
4844
             }
 
4845
 
 
4846
             if (Lex->current_select->where)
 
4847
             {
 
4848
               if (prepare_new_schema_table(YYSession, lex, "SCHEMAS"))
 
4849
                 DRIZZLE_YYABORT;
 
4850
             }
 
4851
             else
 
4852
             {
 
4853
               if (prepare_new_schema_table(YYSession, lex, "SCHEMA_NAMES"))
 
4854
                 DRIZZLE_YYABORT;
 
4855
             }
 
4856
 
 
4857
             Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "SCHEMA_NAME");
 
4858
             my_field->is_autogenerated_name= false;
 
4859
             my_field->set_name(column_name.c_str(), column_name.length(), system_charset_info);
 
4860
 
 
4861
             if (session->add_item_to_list(my_field))
4836
4862
               DRIZZLE_YYABORT;
4837
4863
           }
4838
4864
         | TABLES opt_db show_wild
4839
4865
           {
4840
4866
             LEX *lex= Lex;
4841
 
             lex->sql_command= SQLCOM_SHOW_TABLES;
 
4867
             lex->sql_command= SQLCOM_SELECT;
4842
4868
             lex->statement=
4843
4869
               new(std::nothrow) statement::Select(YYSession);
4844
4870
             if (lex->statement == NULL)
4845
4871
               DRIZZLE_YYABORT;
4846
 
             lex->select_lex.db= $2;
4847
 
             if (prepare_schema_table(YYSession, lex, 0, "TABLE_NAMES"))
 
4872
 
 
4873
              Session *session= YYSession;
 
4874
 
 
4875
              std::string column_name= "Tables_in_";
 
4876
 
 
4877
              if ($2)
 
4878
              {
 
4879
                message::Schema schema_message;
 
4880
                column_name.append($2);
 
4881
                lex->select_lex.db= $2;
 
4882
                if (not plugin::StorageEngine::getSchemaDefinition($2, schema_message))
 
4883
                {
 
4884
                  my_error(ER_BAD_DB_ERROR, MYF(0), $2);
 
4885
                }
 
4886
              }
 
4887
              else
 
4888
              {
 
4889
                column_name.append(session->db);
 
4890
              }
 
4891
 
 
4892
             if (Lex->wild)
 
4893
             {
 
4894
               column_name.append(" (");
 
4895
               column_name.append(Lex->wild->c_str());
 
4896
               column_name.append(")");
 
4897
             }
 
4898
 
 
4899
             if (Lex->current_select->where)
 
4900
             {
 
4901
               if (prepare_new_schema_table(YYSession, lex, "TABLES"))
 
4902
                 DRIZZLE_YYABORT;
 
4903
             }
 
4904
             else
 
4905
             {
 
4906
               if (prepare_new_schema_table(YYSession, lex, "LOCAL_TABLE_NAMES"))
 
4907
                 DRIZZLE_YYABORT;
 
4908
             }
 
4909
 
 
4910
             Item_field *my_field= new Item_field(&session->lex->current_select->context, NULL, NULL, "TABLE_NAME");
 
4911
             my_field->is_autogenerated_name= false;
 
4912
             my_field->set_name(column_name.c_str(), column_name.length(), system_charset_info);
 
4913
 
 
4914
             if (session->add_item_to_list(my_field))
4848
4915
               DRIZZLE_YYABORT;
4849
4916
           }
4850
4917
         | TABLE_SYM STATUS_SYM opt_db show_wild