mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Bug#11938039 "RE-EXECUTION OF FRM-ONLY ALTER TABLE WITH RENAME
CLAUSE FAILS OR ABORTS SERVER". Attempt to re-execute prepared ALTER TABLE statement which involves .FRM-only changes and also have RENAME clause led to unwarranted 'Table doesn't exist' error in production builds and assertion failure for debug builds. This problem stemmed from the fact that for such ALTER TABLE mysql_alter_table() code changed table list element for table to be altered when it tried to re-open table under new name. Since this change was not reverted back before next re-execution, it made this statement re-execution unsafe. This fix addresses this problem by avoiding changing table list element from the main table list in such a situation. Instead temporary TABLE_LIST object is used. mysql-test/r/alter_table.result: Added test case for bug#11938039 "RE-EXECUTION OF FRM-ONLY ALTER TABLE WITH RENAME CLAUSE FAILS OR ABORTS SERVER". mysql-test/t/alter_table.test: Added test case for bug#11938039 "RE-EXECUTION OF FRM-ONLY ALTER TABLE WITH RENAME CLAUSE FAILS OR ABORTS SERVER". sql/sql_table.cc: Changed mysql_alter_table() not to modify table list element for the table being altered while re-opening table after .FRM-only changes. Doing this made .FRM-only ALTER TABLE which also had RENAME clause unsafe for re-execution.
This commit is contained in:
@ -1391,3 +1391,16 @@ CREATE DATABASE db1 CHARACTER SET utf8;
|
||||
CREATE TABLE db1.t1 (bar TINYTEXT, KEY (bar(100)));
|
||||
ALTER TABLE db1.t1 ADD baz INT;
|
||||
DROP DATABASE db1;
|
||||
#
|
||||
# Bug#11938039 RE-EXECUTION OF FRM-ONLY ALTER TABLE WITH RENAME
|
||||
# CLAUSE FAILS OR ABORTS SERVER.
|
||||
#
|
||||
drop table if exists t1;
|
||||
create table t1 (a int);
|
||||
prepare stmt1 from 'alter table t1 alter column a set default 1, rename to t2';
|
||||
execute stmt1;
|
||||
rename table t2 to t1;
|
||||
# The below statement should succeed and not emit error or abort server.
|
||||
execute stmt1;
|
||||
deallocate prepare stmt1;
|
||||
drop table t2;
|
||||
|
Reference in New Issue
Block a user