MDEV-25630 Rollback of instant operation adds wrong column to secondary index
Problem: ======= InnoDB alter fails before applying instant operation. So rollback assigns wrong column to the secondary index field. It leads to the assert failure in the consecutive alter. Fix: === InnoDB shouldn't do rollback of instant operation when it fails before applying instant operation.
This commit is contained in:
parent
5bc12ca9c2
commit
4cd92143ea
@ -2854,3 +2854,30 @@ SELECT COUNT(*) FROM t1;
|
||||
COUNT(*)
|
||||
16
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-25630 Rollback of instant operation adds wrong
|
||||
# column to secondary index
|
||||
#
|
||||
CREATE TABLE t1 (f1 INT, f2 INT, f3 INT, f4 INT,
|
||||
PRIMARY KEY(f1, f4),
|
||||
KEY(f2))ENGINE=InnoDB;
|
||||
CREATE TABLE t2 (f1 INT, f2 INT, PRIMARY KEY(f1),
|
||||
FOREIGN KEY fk (f2) REFERENCES t2(f1)
|
||||
)ENGINE=InnoDB;
|
||||
ALTER TABLE t1 ADD f5 INT;
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
ALTER TABLE t1 DROP COLUMN f3, ADD FOREIGN KEY fk (f1)
|
||||
REFERENCES x(x);
|
||||
ERROR HY000: Failed to add the foreign key constraint 'test/fk' to system tables
|
||||
ALTER TABLE t1 DROP COLUMN f5;
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`f1` int(11) NOT NULL,
|
||||
`f2` int(11) DEFAULT NULL,
|
||||
`f3` int(11) DEFAULT NULL,
|
||||
`f4` int(11) NOT NULL,
|
||||
PRIMARY KEY (`f1`,`f4`),
|
||||
KEY `f2` (`f2`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
DROP TABLE t1, t2;
|
||||
|
@ -917,3 +917,23 @@ INSERT INTO t1(a, b) SELECT '', '' FROM seq_1_to_16;
|
||||
SELECT COUNT(*) FROM t1;
|
||||
# Cleanup
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-25630 Rollback of instant operation adds wrong
|
||||
--echo # column to secondary index
|
||||
--echo #
|
||||
CREATE TABLE t1 (f1 INT, f2 INT, f3 INT, f4 INT,
|
||||
PRIMARY KEY(f1, f4),
|
||||
KEY(f2))ENGINE=InnoDB;
|
||||
CREATE TABLE t2 (f1 INT, f2 INT, PRIMARY KEY(f1),
|
||||
FOREIGN KEY fk (f2) REFERENCES t2(f1)
|
||||
)ENGINE=InnoDB;
|
||||
|
||||
ALTER TABLE t1 ADD f5 INT;
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
--error ER_FK_FAIL_ADD_SYSTEM
|
||||
ALTER TABLE t1 DROP COLUMN f3, ADD FOREIGN KEY fk (f1)
|
||||
REFERENCES x(x);
|
||||
ALTER TABLE t1 DROP COLUMN f5;
|
||||
SHOW CREATE TABLE t1;
|
||||
DROP TABLE t1, t2;
|
||||
|
@ -766,6 +766,13 @@ inline void dict_table_t::rollback_instant(
|
||||
const ulint* col_map)
|
||||
{
|
||||
ut_d(dict_sys.assert_locked());
|
||||
|
||||
if (cols == old_cols) {
|
||||
/* Alter fails before instant operation happens.
|
||||
So there is no need to do rollback instant operation */
|
||||
return;
|
||||
}
|
||||
|
||||
dict_index_t* index = indexes.start;
|
||||
mtr_t mtr;
|
||||
mtr.start();
|
||||
|
Loading…
x
Reference in New Issue
Block a user