mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
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/r/partition_innodb.result: Add test case result for Bug#54783 mysql-test/t/partition_innodb.test: Add test case for Bug#54783 sql/sql_table.cc: In case table recreate failed, set a appropriate result code. Reset reference to a closed table object, otherwise the error path might attempt to access it.
This commit is contained in:
parent
e1bbe2443c
commit
6eb854de1f
3 changed files with 37 additions and 0 deletions
|
@ -373,3 +373,21 @@ CREATE TABLE t1 (a INT) ENGINE=InnoDB
|
|||
PARTITION BY list(a) (PARTITION p1 VALUES IN (1));
|
||||
CREATE INDEX i1 ON t1 (a);
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#54783: optimize table crashes with invalid timestamp default value and NO_ZERO_DATE
|
||||
#
|
||||
DROP TABLE IF EXISTS t1;
|
||||
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;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
|
||||
test.t1 optimize error Invalid default value for 'b'
|
||||
test.t1 optimize status Operation failed
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'b' at row 1
|
||||
Error 1067 Invalid default value for 'b'
|
||||
SET SESSION sql_mode = @old_mode;
|
||||
DROP TABLE t1;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -4930,6 +4930,8 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
|||
*/
|
||||
if (thd->stmt_da->is_ok())
|
||||
thd->stmt_da->reset_diagnostics_area();
|
||||
table->table= NULL;
|
||||
result_code= result_code ? HA_ADMIN_FAILED : HA_ADMIN_OK;
|
||||
goto send_result;
|
||||
}
|
||||
}
|
||||
|
@ -5060,6 +5062,7 @@ send_result_message:
|
|||
trans_commit_stmt(thd);
|
||||
trans_commit(thd);
|
||||
close_thread_tables(thd);
|
||||
table->table= NULL;
|
||||
thd->mdl_context.release_transactional_locks();
|
||||
if (!result_code) // recreation went ok
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue