summaryrefslogtreecommitdiff
path: root/sql/field.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2020-07-08 08:31:32 +0400
committerAlexander Barkov <bar@mariadb.com>2020-08-01 07:43:50 +0400
commitd63631c3fa333373d94271d5f68196a4ecec76de (patch)
tree7482067b4521c4c6b9598cbacf8083d10ef940e5 /sql/field.cc
parenta8458a2345ea2497ada2f1bd01aeb9c34934dfc6 (diff)
downloadmariadb-git-d63631c3fa333373d94271d5f68196a4ecec76de.tar.gz
MDEV-19632 Replication aborts with ER_SLAVE_CONVERSION_FAILED upon CREATE ... SELECT in ORACLE mode
- Adding optional qualifiers to data types: CREATE TABLE t1 (a schema.DATE); Qualifiers now work only for three pre-defined schemas: mariadb_schema oracle_schema maxdb_schema These schemas are virtual (hard-coded) for now, but may turn into real databases on disk in the future. - mariadb_schema.TYPE now always resolves to a true MariaDB data type TYPE without sql_mode specific translations. - oracle_schema.DATE translates to MariaDB DATETIME. - maxdb_schema.TIMESTAMP translates to MariaDB DATETIME. - Fixing SHOW CREATE TABLE to use a qualifier for a data type TYPE if the current sql_mode translates TYPE to something else. The above changes fix the reported problem, so this script: SET sql_mode=ORACLE; CREATE TABLE t2 AS SELECT mariadb_date_column FROM t1; is now replicated as: SET sql_mode=ORACLE; CREATE TABLE t2 (mariadb_date_column mariadb_schema.DATE); and the slave can unambiguously treat DATE as the true MariaDB DATE without ORACLE specific translation to DATETIME. Similar, SET sql_mode=MAXDB; CREATE TABLE t2 AS SELECT mariadb_timestamp_column FROM t1; is now replicated as: SET sql_mode=MAXDB; CREATE TABLE t2 (mariadb_timestamp_column mariadb_schema.TIMESTAMP); so the slave treats TIMESTAMP as the true MariaDB TIMESTAMP without MAXDB specific translation to DATETIME.
Diffstat (limited to 'sql/field.cc')
-rw-r--r--sql/field.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/sql/field.cc b/sql/field.cc
index f5daab00670..e011e01dce7 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -10407,6 +10407,19 @@ void Column_definition::set_attributes(const Lex_field_type_st &type,
set_handler(type.type_handler());
charset= cs;
+#if MYSQL_VERSION_ID > 100500
+#error When merging to 10.5, please move the code below to
+#error Type_handler_timestamp_common::Column_definition_set_attributes()
+#else
+ /*
+ Unlike other types TIMESTAMP fields are NOT NULL by default.
+ Unless --explicit-defaults-for-timestamp is given.
+ */
+ if (!opt_explicit_defaults_for_timestamp &&
+ type.type_handler()->field_type() == MYSQL_TYPE_TIMESTAMP)
+ flags|= NOT_NULL_FLAG;
+#endif
+
if (type.length())
{
int err;