~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_parse.cc

Merged in latest plugin-slot-reorg.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
#include <drizzled/select_send.h>
36
36
#include <drizzled/plugin/client.h>
37
37
#include <drizzled/statement.h>
 
38
#include <drizzled/statement/alter_table.h>
38
39
#include "drizzled/probes.h"
39
40
 
40
 
#include "drizzled/plugin/registry.h"
 
41
#include "drizzled/plugin/logging.h"
 
42
#include "drizzled/plugin/info_schema_table.h"
41
43
 
42
44
#include <bitset>
43
45
#include <algorithm>
169
171
{
170
172
  bool error= 0;
171
173
  Query_id &query_id= Query_id::get_query_id();
172
 
  plugin::Registry &plugins= plugin::Registry::singleton();
173
174
 
174
175
  DRIZZLE_COMMAND_START(session->thread_id,
175
176
                        command);
191
192
 
192
193
  /* TODO: set session->lex->sql_command to SQLCOM_END here */
193
194
 
194
 
  plugins.logging.pre_do(session);
 
195
  plugin::Logging::pre_do(session);
195
196
 
196
197
  session->server_status&=
197
198
           ~(SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED);
301
302
  /* Free tables */
302
303
  session->close_thread_tables();
303
304
 
304
 
  plugins.logging.post_do(session);
 
305
  plugin::Logging::post_do(session);
305
306
 
306
307
  /* Store temp state for processlist */
307
308
  session->set_proc_info("cleaning up");
821
822
{
822
823
  register CreateField *new_field;
823
824
  LEX  *lex= session->lex;
 
825
  drizzled::statement::AlterTable *statement= (drizzled::statement::AlterTable *)lex->statement;
824
826
 
825
827
  if (check_identifier_name(field_name, ER_TOO_LONG_IDENT))
826
 
    return(1);
 
828
    return true;
827
829
 
828
830
  if (type_modifier & PRI_KEY_FLAG)
829
831
  {
832
834
    key= new Key(Key::PRIMARY, null_lex_str,
833
835
                      &default_key_create_info,
834
836
                      0, lex->col_list);
835
 
    lex->alter_info.key_list.push_back(key);
 
837
    statement->alter_info.key_list.push_back(key);
836
838
    lex->col_list.empty();
837
839
  }
838
840
  if (type_modifier & (UNIQUE_FLAG | UNIQUE_KEY_FLAG))
842
844
    key= new Key(Key::UNIQUE, null_lex_str,
843
845
                 &default_key_create_info, 0,
844
846
                 lex->col_list);
845
 
    lex->alter_info.key_list.push_back(key);
 
847
    statement->alter_info.key_list.push_back(key);
846
848
    lex->col_list.empty();
847
849
  }
848
850
 
860
862
         type == DRIZZLE_TYPE_TIMESTAMP))
861
863
    {
862
864
      my_error(ER_INVALID_DEFAULT, MYF(0), field_name->str);
863
 
      return(1);
 
865
      return true;
864
866
    }
865
867
    else if (default_value->type() == Item::NULL_ITEM)
866
868
    {
869
871
          NOT_NULL_FLAG)
870
872
      {
871
873
        my_error(ER_INVALID_DEFAULT, MYF(0), field_name->str);
872
 
        return(1);
 
874
        return true;
873
875
      }
874
876
    }
875
877
    else if (type_modifier & AUTO_INCREMENT_FLAG)
876
878
    {
877
879
      my_error(ER_INVALID_DEFAULT, MYF(0), field_name->str);
878
 
      return(1);
 
880
      return true;
879
881
    }
880
882
  }
881
883
 
882
884
  if (on_update_value && type != DRIZZLE_TYPE_TIMESTAMP)
883
885
  {
884
886
    my_error(ER_INVALID_ON_UPDATE, MYF(0), field_name->str);
885
 
    return(1);
 
887
    return true;
886
888
  }
887
889
 
888
890
  if (!(new_field= new CreateField()) ||
889
891
      new_field->init(session, field_name->str, type, length, decimals, type_modifier,
890
892
                      default_value, on_update_value, comment, change,
891
893
                      interval_list, cs, 0, column_format))
892
 
    return(1);
 
894
    return true;
893
895
 
894
 
  lex->alter_info.create_list.push_back(new_field);
 
896
  statement->alter_info.create_list.push_back(new_field);
895
897
  lex->last_field=new_field;
896
 
  return(0);
 
898
 
 
899
  return false;
897
900
}
898
901
 
899
902
 
991
994
  if (!ptr->derived && !my_strcasecmp(system_charset_info, ptr->db,
992
995
                                      INFORMATION_SCHEMA_NAME.c_str()))
993
996
  {
994
 
    plugin::InfoSchemaTable *schema_table= find_schema_table(ptr->table_name);
 
997
    plugin::InfoSchemaTable *schema_table= plugin::InfoSchemaTable::getTable(ptr->table_name);
995
998
    if (!schema_table ||
996
999
        (schema_table->isHidden() &&
997
1000
         ((sql_command_flags[lex->sql_command].test(CF_BIT_STATUS_COMMAND)) == 0 ||