~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_parse.cc

  • Committer: Mark Atwood
  • Date: 2011-10-27 05:08:12 UTC
  • mfrom: (2445.1.11 rf)
  • Revision ID: me@mark.atwood.name-20111027050812-1icvs72lb0u4xdc4
mergeĀ lp:~olafvdspek/drizzle/refactor8

Show diffs side-by-side

added added

removed removed

Lines of Context:
793
793
    Return 0 if ok
794
794
*/
795
795
 
796
 
bool add_field_to_list(Session *session, lex_string_t *field_name, enum_field_types type,
 
796
bool add_field_to_list(Session *session, str_ref field_name, enum_field_types type,
797
797
                       const char *length, const char *decimals,
798
798
                       uint32_t type_modifier, column_format_type column_format,
799
799
                       Item *default_value, Item *on_update_value, str_ref comment,
802
802
  LEX  *lex= &session->lex();
803
803
  statement::AlterTable *statement= (statement::AlterTable *)lex->statement;
804
804
 
805
 
  if (check_identifier_name(*field_name, ER_TOO_LONG_IDENT))
 
805
  if (check_identifier_name(field_name, ER_TOO_LONG_IDENT))
806
806
    return true;
807
807
 
808
808
  if (type_modifier & PRI_KEY_FLAG)
809
809
  {
810
 
    lex->col_list.push_back(new Key_part_spec(*field_name, 0));
 
810
    lex->col_list.push_back(new Key_part_spec(field_name, 0));
811
811
    statement->alter_info.key_list.push_back(new Key(Key::PRIMARY, null_lex_string(), &default_key_create_info, 0, lex->col_list));
812
812
    lex->col_list.clear();
813
813
  }
814
814
  if (type_modifier & (UNIQUE_FLAG | UNIQUE_KEY_FLAG))
815
815
  {
816
 
    lex->col_list.push_back(new Key_part_spec(*field_name, 0));
 
816
    lex->col_list.push_back(new Key_part_spec(field_name, 0));
817
817
    statement->alter_info.key_list.push_back(new Key(Key::UNIQUE, null_lex_string(), &default_key_create_info, 0, lex->col_list));
818
818
    lex->col_list.clear();
819
819
  }
831
831
        !(((Item_func*)default_value)->functype() == Item_func::NOW_FUNC &&
832
832
         (type == DRIZZLE_TYPE_TIMESTAMP or type == DRIZZLE_TYPE_MICROTIME)))
833
833
    {
834
 
      my_error(ER_INVALID_DEFAULT, MYF(0), field_name->data());
 
834
      my_error(ER_INVALID_DEFAULT, MYF(0), field_name.data());
835
835
      return true;
836
836
    }
837
837
    else if (default_value->type() == Item::NULL_ITEM)
839
839
      default_value= 0;
840
840
      if ((type_modifier & (NOT_NULL_FLAG | AUTO_INCREMENT_FLAG)) == NOT_NULL_FLAG)
841
841
      {
842
 
        my_error(ER_INVALID_DEFAULT, MYF(0), field_name->data());
 
842
        my_error(ER_INVALID_DEFAULT, MYF(0), field_name.data());
843
843
        return true;
844
844
      }
845
845
    }
846
846
    else if (type_modifier & AUTO_INCREMENT_FLAG)
847
847
    {
848
 
      my_error(ER_INVALID_DEFAULT, MYF(0), field_name->data());
 
848
      my_error(ER_INVALID_DEFAULT, MYF(0), field_name.data());
849
849
      return true;
850
850
    }
851
851
  }
852
852
 
853
853
  if (on_update_value && (type != DRIZZLE_TYPE_TIMESTAMP and type != DRIZZLE_TYPE_MICROTIME))
854
854
  {
855
 
    my_error(ER_INVALID_ON_UPDATE, MYF(0), field_name->data());
 
855
    my_error(ER_INVALID_ON_UPDATE, MYF(0), field_name.data());
856
856
    return true;
857
857
  }
858
858
 
859
859
  CreateField* new_field= new CreateField;
860
 
  if (new_field->init(session, field_name->data(), type, length, decimals, type_modifier, comment, change, interval_list, cs, 0, column_format)
 
860
  if (new_field->init(session, field_name.data(), type, length, decimals, type_modifier, comment, change, interval_list, cs, 0, column_format)
861
861
      || new_field->setDefaultValue(default_value, on_update_value))
862
862
    return true;
863
863