summaryrefslogtreecommitdiff
path: root/sql/field.cc
diff options
context:
space:
mode:
authormsvensson@neptunus.(none) <>2006-08-01 20:24:30 +0200
committermsvensson@neptunus.(none) <>2006-08-01 20:24:30 +0200
commit31be565d2ed48ebc2d4bc57d0896b8750810527b (patch)
tree846b441c9730546494aa063e2bc4f74751efde48 /sql/field.cc
parentd8d17559eee16aa2f40159711f1b7967b79c5b6a (diff)
parent09a36146b85ec542a93e6d47bc645470d1ca30d3 (diff)
downloadmariadb-git-31be565d2ed48ebc2d4bc57d0896b8750810527b.tar.gz
Merge neptunus.(none):/home/msvensson/mysql/mysql-5.0
into neptunus.(none):/home/msvensson/mysql/mysql-5.0-maint
Diffstat (limited to 'sql/field.cc')
-rw-r--r--sql/field.cc21
1 files changed, 19 insertions, 2 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 98de224f900..510e3bd259f 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -8265,7 +8265,8 @@ bool create_field::init(THD *thd, char *fld_name, enum_field_types fld_type,
comment= *fld_comment;
/*
- Set flag if this field doesn't have a default value
+ Set NO_DEFAULT_VALUE_FLAG if this field doesn't have a default value and
+ it is NOT NULL, not an AUTO_INCREMENT field and not a TIMESTAMP.
*/
if (!fld_default_value && !(fld_type_modifier & AUTO_INCREMENT_FLAG) &&
(fld_type_modifier & NOT_NULL_FLAG) && fld_type != FIELD_TYPE_TIMESTAMP)
@@ -8342,12 +8343,28 @@ bool create_field::init(THD *thd, char *fld_name, enum_field_types fld_type,
/* Allow empty as default value. */
String str,*res;
res= fld_default_value->val_str(&str);
- if (res->length())
+ /*
+ A default other than '' is always an error, and any non-NULL
+ specified default is an error in strict mode.
+ */
+ if (res->length() || (thd->variables.sql_mode &
+ (MODE_STRICT_TRANS_TABLES |
+ MODE_STRICT_ALL_TABLES)))
{
my_error(ER_BLOB_CANT_HAVE_DEFAULT, MYF(0),
fld_name); /* purecov: inspected */
DBUG_RETURN(TRUE);
}
+ else
+ {
+ /*
+ Otherwise a default of '' is just a warning.
+ */
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_BLOB_CANT_HAVE_DEFAULT,
+ ER(ER_BLOB_CANT_HAVE_DEFAULT),
+ fld_name);
+ }
def= 0;
}
flags|= BLOB_FLAG;