diff options
-rw-r--r-- | mysql-test/extra/rpl_tests/check_type.inc | 8 | ||||
-rw-r--r-- | mysql-test/extra/rpl_tests/type_conversions.test | 91 | ||||
-rw-r--r-- | mysql-test/suite/binlog_encryption/rpl_typeconv.result | 44 | ||||
-rw-r--r-- | mysql-test/suite/rpl/r/rpl_typeconv.result | 44 | ||||
-rw-r--r-- | sql/rpl_utility.cc | 34 |
5 files changed, 219 insertions, 2 deletions
diff --git a/mysql-test/extra/rpl_tests/check_type.inc b/mysql-test/extra/rpl_tests/check_type.inc index 97300753d38..baba7a21e86 100644 --- a/mysql-test/extra/rpl_tests/check_type.inc +++ b/mysql-test/extra/rpl_tests/check_type.inc @@ -24,11 +24,19 @@ connection master; disable_warnings; DROP TABLE IF EXISTS t1; enable_warnings; +if ($source_temp_format) +{ + --eval SET @@global.mysql56_temporal_format= $source_temp_format +} eval CREATE TABLE t1( pk INT NOT NULL PRIMARY KEY, a $source_type ) ENGINE=$engine_type; sync_slave_with_master; +if ($target_temp_format) +{ + --eval SET @@global.mysql56_temporal_format= $source_temp_format +} eval ALTER TABLE t1 MODIFY a $target_type; connection master; diff --git a/mysql-test/extra/rpl_tests/type_conversions.test b/mysql-test/extra/rpl_tests/type_conversions.test index b013d471f01..511d59e3633 100644 --- a/mysql-test/extra/rpl_tests/type_conversions.test +++ b/mysql-test/extra/rpl_tests/type_conversions.test @@ -1007,5 +1007,96 @@ source extra/rpl_tests/check_type.inc; --echo # End of MDEV-15833 +--echo # +--echo # MDEV-17098 DATE <-> DATETIME +--echo # + +# NON-LOSSY +let $source_temp_format= 1; # irrelevant with DATE though +let $source_type= DATE; +let $target_temp_format= 1; # to produce MYSQL_TYPE_DATETIME2 +let $target_type= DATETIME(6); +let $source_value= '2018-10-11'; +let $target_value= '2018-10-11 00:00:00.000000'; +let $can_convert = $if_is_non_lossy; +source extra/rpl_tests/check_type.inc; + +let $source_temp_format= 1; +let $source_type= DATE; +let $target_temp_format= 0; # to produce "old" MYSQL_TYPE_DATETIME +let $target_type= DATETIME(6); +let $source_value= '2018-10-11'; +let $target_value= '2018-10-11 00:00:00.000000'; +let $can_convert = $if_is_non_lossy; +source extra/rpl_tests/check_type.inc; + +let $source_temp_format= 0; +let $source_type= DATE; +let $target_temp_format= 1; +let $target_type= DATETIME(6); +let $source_value= '2018-10-11'; +let $target_value= '2018-10-11 00:00:00.000000'; +let $can_convert = $if_is_non_lossy; +source extra/rpl_tests/check_type.inc; + +# zero-precision test version +let $source_temp_format= 1; +let $source_type= DATE; +let $target_temp_format= 1; +let $target_type= DATETIME(0); +let $source_value= '2018-10-11'; +let $target_value= '2018-10-11 00:00:00'; +let $can_convert = $if_is_non_lossy; +source extra/rpl_tests/check_type.inc; + +# LOSSY +let $source_temp_format= 1; +let $source_type= DATETIME(6); +let $target_temp_format= 1; +let $target_type= DATE; +let $source_value= '2018-10-11 00:00:00.000001'; +let $target_value= '2018-10-11'; +let $can_convert = $if_is_lossy; +source extra/rpl_tests/check_type.inc; + +let $source_temp_format= 1; +let $source_type= DATETIME(6); +let $target_temp_format= 0; +let $target_type= DATE; +let $source_value= '2018-10-11 00:00:00.000001'; +let $target_value= '2018-10-11'; +let $can_convert = $if_is_lossy; +source extra/rpl_tests/check_type.inc; + +# zero-precision test version +let $source_temp_format= 1; +let $source_type= DATETIME(0); +let $target_temp_format= 1; +let $target_type= DATE; +let $source_value= '2018-10-11 00:00:00'; +let $target_value= '2018-10-11'; +let $can_convert = $if_is_lossy; +source extra/rpl_tests/check_type.inc; + +# TODO: fix MDEV-17394 Row-based replication DATETIME(m) to +# DATETIME(s) does not work or incorrect +# +# +# let $source_temp_format= 0; +# let $source_type= DATETIME(6); +# let $target_temp_format= 1; +# let $target_type= DATE; +# ... +# let $source_temp_format= 0; +# let $source_type= DATETIME(6); +# let $target_temp_format= 0; +# let $target_type= DATE; +# ... + +let $source_temp_format=; +let $target_temp_format=; +--echo # End of MDEV-17098 + + --source include/rpl_reset.inc enable_query_log; diff --git a/mysql-test/suite/binlog_encryption/rpl_typeconv.result b/mysql-test/suite/binlog_encryption/rpl_typeconv.result index e9ffdd2b7b1..e65dede28e0 100644 --- a/mysql-test/suite/binlog_encryption/rpl_typeconv.result +++ b/mysql-test/suite/binlog_encryption/rpl_typeconv.result @@ -43,6 +43,10 @@ SET GLOBAL SLAVE_TYPE_CONVERSIONS=''; # MDEV-15833 Row format replication between LONGBLOB and MEDIUMBLOB does not work for long values # # End of MDEV-15833 +# +# MDEV-17098 DATE <-> DATETIME +# +# End of MDEV-17098 include/rpl_reset.inc connection slave; SET GLOBAL SLAVE_TYPE_CONVERSIONS='ALL_NON_LOSSY'; @@ -51,6 +55,10 @@ SET GLOBAL SLAVE_TYPE_CONVERSIONS='ALL_NON_LOSSY'; # MDEV-15833 Row format replication between LONGBLOB and MEDIUMBLOB does not work for long values # # End of MDEV-15833 +# +# MDEV-17098 DATE <-> DATETIME +# +# End of MDEV-17098 include/rpl_reset.inc connection slave; SET GLOBAL SLAVE_TYPE_CONVERSIONS='ALL_LOSSY'; @@ -59,6 +67,10 @@ SET GLOBAL SLAVE_TYPE_CONVERSIONS='ALL_LOSSY'; # MDEV-15833 Row format replication between LONGBLOB and MEDIUMBLOB does not work for long values # # End of MDEV-15833 +# +# MDEV-17098 DATE <-> DATETIME +# +# End of MDEV-17098 include/rpl_reset.inc connection slave; SET GLOBAL SLAVE_TYPE_CONVERSIONS='ALL_LOSSY,ALL_NON_LOSSY'; @@ -67,6 +79,10 @@ SET GLOBAL SLAVE_TYPE_CONVERSIONS='ALL_LOSSY,ALL_NON_LOSSY'; # MDEV-15833 Row format replication between LONGBLOB and MEDIUMBLOB does not work for long values # # End of MDEV-15833 +# +# MDEV-17098 DATE <-> DATETIME +# +# End of MDEV-17098 include/rpl_reset.inc connection slave; **** Result of conversions **** @@ -208,6 +224,13 @@ LONGBLOB TINYBLOB <Correct error> LONGBLOB BLOB <Correct error> LONGBLOB MEDIUMBLOB <Correct error> LONGBLOB VARBINARY(65500 <Correct error> +DATE DATETIME(6) <Correct error> +DATE DATETIME(6) <Correct error> +DATE DATETIME(6) <Correct error> +DATE DATETIME(0) <Correct error> +DATETIME(6) DATE <Correct error> +DATETIME(6) DATE <Correct error> +DATETIME(0) DATE <Correct error> TINYBLOB TINYBLOB ALL_NON_LOSSY <Correct value> TINYBLOB BLOB ALL_NON_LOSSY <Correct value> TINYBLOB MEDIUMBLOB ALL_NON_LOSSY <Correct value> @@ -345,6 +368,13 @@ LONGBLOB TINYBLOB ALL_NON_LOSSY <Correct error> LONGBLOB BLOB ALL_NON_LOSSY <Correct error> LONGBLOB MEDIUMBLOB ALL_NON_LOSSY <Correct error> LONGBLOB VARBINARY(65500 ALL_NON_LOSSY <Correct error> +DATE DATETIME(6) ALL_NON_LOSSY <Correct value> +DATE DATETIME(6) ALL_NON_LOSSY <Correct value> +DATE DATETIME(6) ALL_NON_LOSSY <Correct value> +DATE DATETIME(0) ALL_NON_LOSSY <Correct value> +DATETIME(6) DATE ALL_NON_LOSSY <Correct error> +DATETIME(6) DATE ALL_NON_LOSSY <Correct error> +DATETIME(0) DATE ALL_NON_LOSSY <Correct error> TINYBLOB TINYBLOB ALL_LOSSY <Correct value> TINYBLOB BLOB ALL_LOSSY <Correct error> TINYBLOB MEDIUMBLOB ALL_LOSSY <Correct error> @@ -482,6 +512,13 @@ LONGBLOB TINYBLOB ALL_LOSSY <Correct value> LONGBLOB BLOB ALL_LOSSY <Correct value> LONGBLOB MEDIUMBLOB ALL_LOSSY <Correct value> LONGBLOB VARBINARY(65500 ALL_LOSSY <Correct value> +DATE DATETIME(6) ALL_LOSSY <Correct error> +DATE DATETIME(6) ALL_LOSSY <Correct error> +DATE DATETIME(6) ALL_LOSSY <Correct error> +DATE DATETIME(0) ALL_LOSSY <Correct error> +DATETIME(6) DATE ALL_LOSSY <Correct value> +DATETIME(6) DATE ALL_LOSSY <Correct value> +DATETIME(0) DATE ALL_LOSSY <Correct value> TINYBLOB TINYBLOB ALL_LOSSY,ALL_NON_LOSSY <Correct value> TINYBLOB BLOB ALL_LOSSY,ALL_NON_LOSSY <Correct value> TINYBLOB MEDIUMBLOB ALL_LOSSY,ALL_NON_LOSSY <Correct value> @@ -619,6 +656,13 @@ LONGBLOB TINYBLOB ALL_LOSSY,ALL_NON_LOSSY <Correct value> LONGBLOB BLOB ALL_LOSSY,ALL_NON_LOSSY <Correct value> LONGBLOB MEDIUMBLOB ALL_LOSSY,ALL_NON_LOSSY <Correct value> LONGBLOB VARBINARY(65500 ALL_LOSSY,ALL_NON_LOSSY <Correct value> +DATE DATETIME(6) ALL_LOSSY,ALL_NON_LOSSY <Correct value> +DATE DATETIME(6) ALL_LOSSY,ALL_NON_LOSSY <Correct value> +DATE DATETIME(6) ALL_LOSSY,ALL_NON_LOSSY <Correct value> +DATE DATETIME(0) ALL_LOSSY,ALL_NON_LOSSY <Correct value> +DATETIME(6) DATE ALL_LOSSY,ALL_NON_LOSSY <Correct value> +DATETIME(6) DATE ALL_LOSSY,ALL_NON_LOSSY <Correct value> +DATETIME(0) DATE ALL_LOSSY,ALL_NON_LOSSY <Correct value> DROP TABLE type_conversions; call mtr.add_suppression("Slave SQL.*Column 1 of table .test.t1. cannot be converted from type.* error.* 1677"); connection master; diff --git a/mysql-test/suite/rpl/r/rpl_typeconv.result b/mysql-test/suite/rpl/r/rpl_typeconv.result index e9ffdd2b7b1..e65dede28e0 100644 --- a/mysql-test/suite/rpl/r/rpl_typeconv.result +++ b/mysql-test/suite/rpl/r/rpl_typeconv.result @@ -43,6 +43,10 @@ SET GLOBAL SLAVE_TYPE_CONVERSIONS=''; # MDEV-15833 Row format replication between LONGBLOB and MEDIUMBLOB does not work for long values # # End of MDEV-15833 +# +# MDEV-17098 DATE <-> DATETIME +# +# End of MDEV-17098 include/rpl_reset.inc connection slave; SET GLOBAL SLAVE_TYPE_CONVERSIONS='ALL_NON_LOSSY'; @@ -51,6 +55,10 @@ SET GLOBAL SLAVE_TYPE_CONVERSIONS='ALL_NON_LOSSY'; # MDEV-15833 Row format replication between LONGBLOB and MEDIUMBLOB does not work for long values # # End of MDEV-15833 +# +# MDEV-17098 DATE <-> DATETIME +# +# End of MDEV-17098 include/rpl_reset.inc connection slave; SET GLOBAL SLAVE_TYPE_CONVERSIONS='ALL_LOSSY'; @@ -59,6 +67,10 @@ SET GLOBAL SLAVE_TYPE_CONVERSIONS='ALL_LOSSY'; # MDEV-15833 Row format replication between LONGBLOB and MEDIUMBLOB does not work for long values # # End of MDEV-15833 +# +# MDEV-17098 DATE <-> DATETIME +# +# End of MDEV-17098 include/rpl_reset.inc connection slave; SET GLOBAL SLAVE_TYPE_CONVERSIONS='ALL_LOSSY,ALL_NON_LOSSY'; @@ -67,6 +79,10 @@ SET GLOBAL SLAVE_TYPE_CONVERSIONS='ALL_LOSSY,ALL_NON_LOSSY'; # MDEV-15833 Row format replication between LONGBLOB and MEDIUMBLOB does not work for long values # # End of MDEV-15833 +# +# MDEV-17098 DATE <-> DATETIME +# +# End of MDEV-17098 include/rpl_reset.inc connection slave; **** Result of conversions **** @@ -208,6 +224,13 @@ LONGBLOB TINYBLOB <Correct error> LONGBLOB BLOB <Correct error> LONGBLOB MEDIUMBLOB <Correct error> LONGBLOB VARBINARY(65500 <Correct error> +DATE DATETIME(6) <Correct error> +DATE DATETIME(6) <Correct error> +DATE DATETIME(6) <Correct error> +DATE DATETIME(0) <Correct error> +DATETIME(6) DATE <Correct error> +DATETIME(6) DATE <Correct error> +DATETIME(0) DATE <Correct error> TINYBLOB TINYBLOB ALL_NON_LOSSY <Correct value> TINYBLOB BLOB ALL_NON_LOSSY <Correct value> TINYBLOB MEDIUMBLOB ALL_NON_LOSSY <Correct value> @@ -345,6 +368,13 @@ LONGBLOB TINYBLOB ALL_NON_LOSSY <Correct error> LONGBLOB BLOB ALL_NON_LOSSY <Correct error> LONGBLOB MEDIUMBLOB ALL_NON_LOSSY <Correct error> LONGBLOB VARBINARY(65500 ALL_NON_LOSSY <Correct error> +DATE DATETIME(6) ALL_NON_LOSSY <Correct value> +DATE DATETIME(6) ALL_NON_LOSSY <Correct value> +DATE DATETIME(6) ALL_NON_LOSSY <Correct value> +DATE DATETIME(0) ALL_NON_LOSSY <Correct value> +DATETIME(6) DATE ALL_NON_LOSSY <Correct error> +DATETIME(6) DATE ALL_NON_LOSSY <Correct error> +DATETIME(0) DATE ALL_NON_LOSSY <Correct error> TINYBLOB TINYBLOB ALL_LOSSY <Correct value> TINYBLOB BLOB ALL_LOSSY <Correct error> TINYBLOB MEDIUMBLOB ALL_LOSSY <Correct error> @@ -482,6 +512,13 @@ LONGBLOB TINYBLOB ALL_LOSSY <Correct value> LONGBLOB BLOB ALL_LOSSY <Correct value> LONGBLOB MEDIUMBLOB ALL_LOSSY <Correct value> LONGBLOB VARBINARY(65500 ALL_LOSSY <Correct value> +DATE DATETIME(6) ALL_LOSSY <Correct error> +DATE DATETIME(6) ALL_LOSSY <Correct error> +DATE DATETIME(6) ALL_LOSSY <Correct error> +DATE DATETIME(0) ALL_LOSSY <Correct error> +DATETIME(6) DATE ALL_LOSSY <Correct value> +DATETIME(6) DATE ALL_LOSSY <Correct value> +DATETIME(0) DATE ALL_LOSSY <Correct value> TINYBLOB TINYBLOB ALL_LOSSY,ALL_NON_LOSSY <Correct value> TINYBLOB BLOB ALL_LOSSY,ALL_NON_LOSSY <Correct value> TINYBLOB MEDIUMBLOB ALL_LOSSY,ALL_NON_LOSSY <Correct value> @@ -619,6 +656,13 @@ LONGBLOB TINYBLOB ALL_LOSSY,ALL_NON_LOSSY <Correct value> LONGBLOB BLOB ALL_LOSSY,ALL_NON_LOSSY <Correct value> LONGBLOB MEDIUMBLOB ALL_LOSSY,ALL_NON_LOSSY <Correct value> LONGBLOB VARBINARY(65500 ALL_LOSSY,ALL_NON_LOSSY <Correct value> +DATE DATETIME(6) ALL_LOSSY,ALL_NON_LOSSY <Correct value> +DATE DATETIME(6) ALL_LOSSY,ALL_NON_LOSSY <Correct value> +DATE DATETIME(6) ALL_LOSSY,ALL_NON_LOSSY <Correct value> +DATE DATETIME(0) ALL_LOSSY,ALL_NON_LOSSY <Correct value> +DATETIME(6) DATE ALL_LOSSY,ALL_NON_LOSSY <Correct value> +DATETIME(6) DATE ALL_LOSSY,ALL_NON_LOSSY <Correct value> +DATETIME(0) DATE ALL_LOSSY,ALL_NON_LOSSY <Correct value> DROP TABLE type_conversions; call mtr.add_suppression("Slave SQL.*Column 1 of table .test.t1. cannot be converted from type.* error.* 1677"); connection master; diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc index bdf5b7dea80..9554daeedbd 100644 --- a/sql/rpl_utility.cc +++ b/sql/rpl_utility.cc @@ -765,14 +765,44 @@ can_convert_field_to(Field *field, case MYSQL_TYPE_TIME: case MYSQL_TYPE_DATETIME: case MYSQL_TYPE_YEAR: - case MYSQL_TYPE_NEWDATE: case MYSQL_TYPE_NULL: case MYSQL_TYPE_ENUM: case MYSQL_TYPE_SET: case MYSQL_TYPE_TIMESTAMP2: - case MYSQL_TYPE_DATETIME2: case MYSQL_TYPE_TIME2: DBUG_RETURN(false); + case MYSQL_TYPE_NEWDATE: + { + if (field->real_type() == MYSQL_TYPE_DATETIME2 || + field->real_type() == MYSQL_TYPE_DATETIME) + { + *order_var= -1; + DBUG_RETURN(is_conversion_ok(*order_var, rli)); + } + else + { + DBUG_RETURN(false); + } + } + break; + + //case MYSQL_TYPE_DATETIME: TODO: fix MDEV-17394 and uncomment. + // + //The "old" type does not specify the fraction part size which is required + //for correct conversion. + case MYSQL_TYPE_DATETIME2: + { + if (field->real_type() == MYSQL_TYPE_NEWDATE) + { + *order_var= 1; + DBUG_RETURN(is_conversion_ok(*order_var, rli)); + } + else + { + DBUG_RETURN(false); + } + } + break; } DBUG_RETURN(false); // To keep GCC happy } |