From 07a9c082d94ad5603d7c0b7c8320c25ad6d5c755 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Tue, 6 Jul 2010 14:38:03 -0300 Subject: Bug#54783: optimize table crashes with invalid timestamp default value and NO_ZERO_DATE The problem was that a older version of the error path for a failed admin statement relied upon a few error conditions being met in order to access a table handler, the first one being that the table object pointer was not NULL. Probably due to chance, in all cases a table object was closed but the reference wasn't reset, the other conditions didn't evaluate to true. With the addition of a new check on the error path, the handler started being dereferenced whenever it was not reset to NULL, causing problems for code paths which closed the table but didn't reset the reference. The solution is to reset the reference whenever a admin statement fails and the tables are closed. --- mysql-test/t/partition_innodb.test | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'mysql-test/t/partition_innodb.test') diff --git a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test index ccca4df9882..30f5894716c 100644 --- a/mysql-test/t/partition_innodb.test +++ b/mysql-test/t/partition_innodb.test @@ -452,3 +452,19 @@ SELECT * FROM t1; COMMIT; DROP TABLE t1; --enable_parsing + +--echo # +--echo # Bug#54783: optimize table crashes with invalid timestamp default value and NO_ZERO_DATE +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 (a INT, b TIMESTAMP DEFAULT '0000-00-00 00:00:00') + ENGINE=INNODB PARTITION BY LINEAR HASH (a) PARTITIONS 1; +SET @old_mode = @@sql_mode; +SET SESSION sql_mode = 'NO_ZERO_DATE'; +OPTIMIZE TABLE t1; +SET SESSION sql_mode = @old_mode; +DROP TABLE t1; -- cgit v1.2.1