diff options
author | Alexander Barkov <bar@mariadb.com> | 2018-12-12 14:07:27 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2018-12-12 14:07:27 +0400 |
commit | c8774408cb99ca5167fcefd57a35c37dfc003513 (patch) | |
tree | 7663b014a10f36157cc0ab642531dd7c36a1a385 | |
parent | c353b2a8fc10e16107ee6c7e26877f4243d4eaef (diff) | |
download | mariadb-git-c8774408cb99ca5167fcefd57a35c37dfc003513.tar.gz |
MDEV-17968 Error 174 "Fatal error during initialization of handler" from storage engine Aria upon DELETE from partitioned table
-rw-r--r-- | mysql-test/main/type_timestamp.result | 14 | ||||
-rw-r--r-- | mysql-test/main/type_timestamp.test | 22 | ||||
-rw-r--r-- | sql/compat56.cc | 21 |
3 files changed, 54 insertions, 3 deletions
diff --git a/mysql-test/main/type_timestamp.result b/mysql-test/main/type_timestamp.result index 439532131cc..e1256ae5b0c 100644 --- a/mysql-test/main/type_timestamp.result +++ b/mysql-test/main/type_timestamp.result @@ -1129,5 +1129,19 @@ Warnings: Warning 1292 Truncated incorrect datetime value: 'N/A' DROP TABLE t1; # +# MDEV-17972 Assertion `is_valid_value_slow()' failed in Datetime::Datetime +# +SET time_zone='+00:00'; +CREATE TABLE t1 (a TIMESTAMP(6)) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('2001-01-01 10:20:30'); +FLUSH TABLES; +MYD +FF77777777FFFFFF +SELECT a, CAST(a AS DATETIME) AS dt0, CAST(a AS DATETIME(6)) AS dt6 FROM t1; +a dt0 dt6 +2033-07-07 03:01:11.999999 2033-07-07 03:01:11 2033-07-07 03:01:11.999999 +DROP TABLE t1; +SET time_zone=DEFAULT; +# # End of 10.4 tests # diff --git a/mysql-test/main/type_timestamp.test b/mysql-test/main/type_timestamp.test index 5458d301a82..3eb2c86e57f 100644 --- a/mysql-test/main/type_timestamp.test +++ b/mysql-test/main/type_timestamp.test @@ -719,5 +719,27 @@ SELECT NULLIF(b, 'N/A') AS f, MAX(a) FROM t1 GROUP BY f; DROP TABLE t1; --echo # +--echo # MDEV-17972 Assertion `is_valid_value_slow()' failed in Datetime::Datetime +--echo # + +let $MYSQLD_DATADIR= `select @@datadir`; +SET time_zone='+00:00'; +CREATE TABLE t1 (a TIMESTAMP(6)) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('2001-01-01 10:20:30'); +FLUSH TABLES; +--remove_file $MYSQLD_DATADIR/test/t1.MYD +--disable_query_log +# Write a data file with one record: +# 0xFF - record flags +# 0x77777777 - TIMESTAMP integer part +# 0xFFFFFF - TIMESTAMP bad fractional part +--eval SELECT CONCAT(0xFF,0x77777777,0xFFFFFF) INTO OUTFILE '$MYSQLD_DATADIR/test/t1.MYD' FIELDS TERMINATED BY '' ESCAPED BY '' LINES TERMINATED BY '' +--eval SELECT HEX(LOAD_FILE('$MYSQLD_DATADIR/test/t1.MYD')) AS MYD +--enable_query_log +SELECT a, CAST(a AS DATETIME) AS dt0, CAST(a AS DATETIME(6)) AS dt6 FROM t1; +DROP TABLE t1; +SET time_zone=DEFAULT; + +--echo # --echo # End of 10.4 tests --echo # diff --git a/sql/compat56.cc b/sql/compat56.cc index d1cb8b0042c..2c444243934 100644 --- a/sql/compat56.cc +++ b/sql/compat56.cc @@ -20,6 +20,19 @@ #include "myisampack.h" #include "my_time.h" + +static uint my_max_usec_value[7] +{ + 0, + 900000, + 990000, + 999000, + 999900, + 999990, + 999999 +}; + + /*** MySQL56 TIME low-level memory and disk representation routines ***/ /* @@ -397,19 +410,21 @@ void my_timestamp_from_binary(struct timeval *tm, const uchar *ptr, uint dec) case 0: default: tm->tv_usec= 0; - break; + return; case 1: case 2: tm->tv_usec= ((int) ptr[4]) * 10000; break; case 3: case 4: - tm->tv_usec= mi_sint2korr(ptr + 4) * 100; + tm->tv_usec= (uint) mi_uint2korr(ptr + 4) * 100; break; case 5: case 6: - tm->tv_usec= mi_sint3korr(ptr + 4); + tm->tv_usec= (uint) mi_uint3korr(ptr + 4); } + // The binary data my be corrupt. Cut fractional seconds to the valid range. + set_if_smaller(tm->tv_usec, my_max_usec_value[dec]); } |