Skip to content

Commit c877440

Browse files
committed
MDEV-17968 Error 174 "Fatal error during initialization of handler" from storage engine Aria upon DELETE from partitioned table
1 parent c353b2a commit c877440

File tree

3 files changed

+54
-3
lines changed

3 files changed

+54
-3
lines changed

mysql-test/main/type_timestamp.result

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,5 +1129,19 @@ Warnings:
11291129
Warning 1292 Truncated incorrect datetime value: 'N/A'
11301130
DROP TABLE t1;
11311131
#
1132+
# MDEV-17972 Assertion `is_valid_value_slow()' failed in Datetime::Datetime
1133+
#
1134+
SET time_zone='+00:00';
1135+
CREATE TABLE t1 (a TIMESTAMP(6)) ENGINE=MyISAM;
1136+
INSERT INTO t1 VALUES ('2001-01-01 10:20:30');
1137+
FLUSH TABLES;
1138+
MYD
1139+
FF77777777FFFFFF
1140+
SELECT a, CAST(a AS DATETIME) AS dt0, CAST(a AS DATETIME(6)) AS dt6 FROM t1;
1141+
a dt0 dt6
1142+
2033-07-07 03:01:11.999999 2033-07-07 03:01:11 2033-07-07 03:01:11.999999
1143+
DROP TABLE t1;
1144+
SET time_zone=DEFAULT;
1145+
#
11321146
# End of 10.4 tests
11331147
#

mysql-test/main/type_timestamp.test

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,28 @@ INSERT INTO t1 VALUES (1,'2018-06-19 00:00:00');
718718
SELECT NULLIF(b, 'N/A') AS f, MAX(a) FROM t1 GROUP BY f;
719719
DROP TABLE t1;
720720

721+
--echo #
722+
--echo # MDEV-17972 Assertion `is_valid_value_slow()' failed in Datetime::Datetime
723+
--echo #
724+
725+
let $MYSQLD_DATADIR= `select @@datadir`;
726+
SET time_zone='+00:00';
727+
CREATE TABLE t1 (a TIMESTAMP(6)) ENGINE=MyISAM;
728+
INSERT INTO t1 VALUES ('2001-01-01 10:20:30');
729+
FLUSH TABLES;
730+
--remove_file $MYSQLD_DATADIR/test/t1.MYD
731+
--disable_query_log
732+
# Write a data file with one record:
733+
# 0xFF - record flags
734+
# 0x77777777 - TIMESTAMP integer part
735+
# 0xFFFFFF - TIMESTAMP bad fractional part
736+
--eval SELECT CONCAT(0xFF,0x77777777,0xFFFFFF) INTO OUTFILE '$MYSQLD_DATADIR/test/t1.MYD' FIELDS TERMINATED BY '' ESCAPED BY '' LINES TERMINATED BY ''
737+
--eval SELECT HEX(LOAD_FILE('$MYSQLD_DATADIR/test/t1.MYD')) AS MYD
738+
--enable_query_log
739+
SELECT a, CAST(a AS DATETIME) AS dt0, CAST(a AS DATETIME(6)) AS dt6 FROM t1;
740+
DROP TABLE t1;
741+
SET time_zone=DEFAULT;
742+
721743
--echo #
722744
--echo # End of 10.4 tests
723745
--echo #

sql/compat56.cc

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@
2020
#include "myisampack.h"
2121
#include "my_time.h"
2222

23+
24+
static uint my_max_usec_value[7]
25+
{
26+
0,
27+
900000,
28+
990000,
29+
999000,
30+
999900,
31+
999990,
32+
999999
33+
};
34+
35+
2336
/*** MySQL56 TIME low-level memory and disk representation routines ***/
2437

2538
/*
@@ -397,19 +410,21 @@ void my_timestamp_from_binary(struct timeval *tm, const uchar *ptr, uint dec)
397410
case 0:
398411
default:
399412
tm->tv_usec= 0;
400-
break;
413+
return;
401414
case 1:
402415
case 2:
403416
tm->tv_usec= ((int) ptr[4]) * 10000;
404417
break;
405418
case 3:
406419
case 4:
407-
tm->tv_usec= mi_sint2korr(ptr + 4) * 100;
420+
tm->tv_usec= (uint) mi_uint2korr(ptr + 4) * 100;
408421
break;
409422
case 5:
410423
case 6:
411-
tm->tv_usec= mi_sint3korr(ptr + 4);
424+
tm->tv_usec= (uint) mi_uint3korr(ptr + 4);
412425
}
426+
// The binary data my be corrupt. Cut fractional seconds to the valid range.
427+
set_if_smaller(tm->tv_usec, my_max_usec_value[dec]);
413428
}
414429

415430

0 commit comments

Comments
 (0)