~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_parse.cc

  • Committer: Brian Aker
  • Date: 2009-09-24 06:23:51 UTC
  • mfrom: (1128.2.12 merge)
  • Revision ID: brian@gaz-20090924062351-nuf8tv8ftg7oc9ad
Merge of Lex -> Statement refactoring

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
#include <drizzled/select_send.h>
37
37
#include <drizzled/plugin/client.h>
38
38
#include <drizzled/statement.h>
 
39
#include <drizzled/statement/alter_table.h>
39
40
#include "drizzled/probes.h"
40
41
 
41
42
#include <bitset>
818
819
{
819
820
  register CreateField *new_field;
820
821
  LEX  *lex= session->lex;
 
822
  drizzled::statement::AlterTable *statement= (drizzled::statement::AlterTable *)lex->statement;
821
823
 
822
824
  if (check_identifier_name(field_name, ER_TOO_LONG_IDENT))
823
 
    return(1);
 
825
    return true;
824
826
 
825
827
  if (type_modifier & PRI_KEY_FLAG)
826
828
  {
829
831
    key= new Key(Key::PRIMARY, null_lex_str,
830
832
                      &default_key_create_info,
831
833
                      0, lex->col_list);
832
 
    lex->alter_info.key_list.push_back(key);
 
834
    statement->alter_info.key_list.push_back(key);
833
835
    lex->col_list.empty();
834
836
  }
835
837
  if (type_modifier & (UNIQUE_FLAG | UNIQUE_KEY_FLAG))
839
841
    key= new Key(Key::UNIQUE, null_lex_str,
840
842
                 &default_key_create_info, 0,
841
843
                 lex->col_list);
842
 
    lex->alter_info.key_list.push_back(key);
 
844
    statement->alter_info.key_list.push_back(key);
843
845
    lex->col_list.empty();
844
846
  }
845
847
 
857
859
         type == DRIZZLE_TYPE_TIMESTAMP))
858
860
    {
859
861
      my_error(ER_INVALID_DEFAULT, MYF(0), field_name->str);
860
 
      return(1);
 
862
      return true;
861
863
    }
862
864
    else if (default_value->type() == Item::NULL_ITEM)
863
865
    {
866
868
          NOT_NULL_FLAG)
867
869
      {
868
870
        my_error(ER_INVALID_DEFAULT, MYF(0), field_name->str);
869
 
        return(1);
 
871
        return true;
870
872
      }
871
873
    }
872
874
    else if (type_modifier & AUTO_INCREMENT_FLAG)
873
875
    {
874
876
      my_error(ER_INVALID_DEFAULT, MYF(0), field_name->str);
875
 
      return(1);
 
877
      return true;
876
878
    }
877
879
  }
878
880
 
879
881
  if (on_update_value && type != DRIZZLE_TYPE_TIMESTAMP)
880
882
  {
881
883
    my_error(ER_INVALID_ON_UPDATE, MYF(0), field_name->str);
882
 
    return(1);
 
884
    return true;
883
885
  }
884
886
 
885
887
  if (!(new_field= new CreateField()) ||
886
888
      new_field->init(session, field_name->str, type, length, decimals, type_modifier,
887
889
                      default_value, on_update_value, comment, change,
888
890
                      interval_list, cs, 0, column_format))
889
 
    return(1);
 
891
    return true;
890
892
 
891
 
  lex->alter_info.create_list.push_back(new_field);
 
893
  statement->alter_info.create_list.push_back(new_field);
892
894
  lex->last_field=new_field;
893
 
  return(0);
 
895
 
 
896
  return false;
894
897
}
895
898
 
896
899