summaryrefslogtreecommitdiff
path: root/sql/field.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2015-09-22 14:01:54 +0400
committerAlexander Barkov <bar@mariadb.org>2015-09-22 14:01:54 +0400
commit5c9c8ef1eac0a3868a57ed8fda8bda8cd2453b37 (patch)
tree88739fffdf78de796c665affa6beb8687ca25a2b /sql/field.cc
parent89af0f11a83188cb2bfbfed0b54c00d718734995 (diff)
downloadmariadb-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.cc17
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 &&