diff options
author | Alexander Barkov <bar@mariadb.org> | 2015-09-22 14:01:54 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2015-09-22 14:01:54 +0400 |
commit | 5c9c8ef1eac0a3868a57ed8fda8bda8cd2453b37 (patch) | |
tree | 88739fffdf78de796c665affa6beb8687ca25a2b /sql/field.cc | |
parent | 89af0f11a83188cb2bfbfed0b54c00d718734995 (diff) | |
download | mariadb-git-5c9c8ef1eac0a3868a57ed8fda8bda8cd2453b37.tar.gz |
MDEV-3929 Add system variable explicit_defaults_for_timestamp for compatibility with MySQL
Diffstat (limited to 'sql/field.cc')
-rw-r--r-- | sql/field.cc | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/sql/field.cc b/sql/field.cc index bacab1f79f4..5ba155d1315 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -10017,13 +10017,22 @@ bool Create_field::check(THD *thd) /* 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. + it is NOT NULL, not an AUTO_INCREMENT field. We need to do this check here and in mysql_create_prepare_table() as sp_head::fill_field_definition() calls this function. */ - if (!def && unireg_check == Field::NONE && - (flags & NOT_NULL_FLAG) && !is_timestamp_type(sql_type)) - flags|= NO_DEFAULT_VALUE_FLAG; + if (!def && unireg_check == Field::NONE && (flags & NOT_NULL_FLAG)) + { + /* + TIMESTAMP columns get implicit DEFAULT value when + explicit_defaults_for_timestamp is not set. + */ + if (opt_explicit_defaults_for_timestamp || + !is_timestamp_type(sql_type)) + { + flags|= NO_DEFAULT_VALUE_FLAG; + } + } if (!(flags & BLOB_FLAG) && ((length > max_field_charlength && |