Commit 5b0a7607 authored by Eugene Kosov's avatar Eugene Kosov

MDEV-26621 assertion failue "index->table->persistent_autoinc" in...

MDEV-26621 assertion failue "index->table->persistent_autoinc" in /storage/innobase/btr/btr0btr.cc during IMPORT

dict_index_t::clear_instant_alter(): when searhing for an AUTO_INCREMENT column
don't skip the beginning of the list because the field can be at the beginning of the list
parent 689b8d06
...@@ -70,3 +70,11 @@ select * from t1; ...@@ -70,3 +70,11 @@ select * from t1;
ERROR HY000: Tablespace has been discarded for table `t1` ERROR HY000: Tablespace has been discarded for table `t1`
drop table t2; drop table t2;
drop table t1; drop table t1;
CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT, i1 INT) ENGINE=INNODB;
CREATE TABLE t2 (id INT PRIMARY KEY AUTO_INCREMENT, i1 INT, i2 INT) ENGINE=INNODB;
ALTER TABLE t2 DROP COLUMN i2, ALGORITHM=INSTANT;
ALTER TABLE t2 DISCARD TABLESPACE;
FLUSH TABLE t1 FOR EXPORT;
UNLOCK TABLES;
ALTER TABLE t2 IMPORT TABLESPACE;
DROP TABLE t2, t1;
...@@ -82,3 +82,22 @@ select * from t1; ...@@ -82,3 +82,22 @@ select * from t1;
drop table t2; drop table t2;
drop table t1; drop table t1;
--let $MYSQLD_DATADIR= `SELECT @@datadir`
CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT, i1 INT) ENGINE=INNODB;
CREATE TABLE t2 (id INT PRIMARY KEY AUTO_INCREMENT, i1 INT, i2 INT) ENGINE=INNODB;
ALTER TABLE t2 DROP COLUMN i2, ALGORITHM=INSTANT;
ALTER TABLE t2 DISCARD TABLESPACE;
FLUSH TABLE t1 FOR EXPORT;
--copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_DATADIR/test/t2.ibd
--copy_file $MYSQLD_DATADIR/test/t1.cfg $MYSQLD_DATADIR/test/t2.cfg
UNLOCK TABLES;
ALTER TABLE t2 IMPORT TABLESPACE;
DROP TABLE t2, t1;
...@@ -2440,7 +2440,7 @@ inline void dict_index_t::clear_instant_alter() ...@@ -2440,7 +2440,7 @@ inline void dict_index_t::clear_instant_alter()
{ return a.col->ind < b.col->ind; }); { return a.col->ind < b.col->ind; });
table->instant = NULL; table->instant = NULL;
if (ai_col) { if (ai_col) {
auto a = std::find_if(begin, end, auto a = std::find_if(fields, end,
[ai_col](const dict_field_t& f) [ai_col](const dict_field_t& f)
{ return f.col == ai_col; }); { return f.col == ai_col; });
table->persistent_autoinc = (a == end) ? 0 : 1 + (a - fields); table->persistent_autoinc = (a == end) ? 0 : 1 + (a - fields);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment