~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_insert.cc

  • Committer: Brian Aker
  • Date: 2008-12-18 21:36:23 UTC
  • mfrom: (685.4.10 enable-tests)
  • Revision ID: brian@tangent.org-20081218213623-nsgvfbcax1z6epx4
Merge from Jay

Show diffs side-by-side

added added

removed removed

Lines of Context:
994
994
******************************************************************************/
995
995
 
996
996
int check_that_all_fields_are_given_values(Session *session, Table *entry,
997
 
                                           TableList *table_list)
 
997
                                           TableList *)
998
998
{
999
999
  int err= 0;
1000
1000
  MY_BITMAP *write_set= entry->write_set;
1001
1001
 
1002
1002
  for (Field **field=entry->field ; *field ; field++)
1003
1003
  {
1004
 
    if (!bitmap_is_set(write_set, (*field)->field_index) &&
1005
 
        ((*field)->flags & NO_DEFAULT_VALUE_FLAG) &&
 
1004
    if (!bitmap_is_set(write_set, (*field)->field_index))
 
1005
    {
 
1006
      /*
 
1007
       * If the field doesn't have any default value
 
1008
       * and there is no actual value specified in the
 
1009
       * INSERT statement, throw error ER_NO_DEFAULT_FOR_FIELD.
 
1010
       */
 
1011
      if (((*field)->flags & NO_DEFAULT_VALUE_FLAG) &&
1006
1012
        ((*field)->real_type() != DRIZZLE_TYPE_ENUM))
 
1013
      {
 
1014
        my_error(ER_NO_DEFAULT_FOR_FIELD, MYF(0), (*field)->field_name);
 
1015
        err= 1;
 
1016
      }
 
1017
    }
 
1018
    else
1007
1019
    {
1008
 
      bool view= false;
1009
 
      if (table_list)
1010
 
      {
1011
 
        table_list= table_list->top_table();
1012
 
        view= test(0);
1013
 
      }
1014
 
      {
1015
 
        push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1016
 
                            ER_NO_DEFAULT_FOR_FIELD,
1017
 
                            ER(ER_NO_DEFAULT_FOR_FIELD),
1018
 
                            (*field)->field_name);
1019
 
      }
1020
 
      err= 1;
 
1020
      /*
 
1021
       * However, if an actual NULL value was specified
 
1022
       * for the field and the field is a NOT NULL field, 
 
1023
       * throw ER_BAD_NULL_ERROR.
 
1024
       *
 
1025
       * Per the SQL standard, inserting NULL into a NOT NULL
 
1026
       * field requires an error to be thrown.
 
1027
       */
 
1028
      if (((*field)->flags & NOT_NULL_FLAG) &&
 
1029
          (*field)->is_null())
 
1030
      {
 
1031
        my_error(ER_BAD_NULL_ERROR, MYF(0), (*field)->field_name);
 
1032
        err= 1;
 
1033
      }
1021
1034
    }
1022
1035
  }
1023
1036
  return session->abort_on_warning ? err : 0;