Following test case in 10.4.18 throws the error:
ERROR 1808 (HY000): Schema mismatch (Number of indexes don't match, table has 1 indexes but the tablespace meta-data file has 2 indexes)
|
Test case:
--source include/have_innodb.inc
|
# FTS TABLE
|
CREATE TABLE t1(f1 CHAR(10), fulltext f_idx(f1))engine=innodb;
|
INSERT INTO t1 values("thiru");
|
ALTER TABLE t1 DROP INDEX f_idx;
|
FLUSH TABLE t1 FOR EXPORT;
|
let MYSQLD_DATADIR =`SELECT @@datadir`;
|
perl;
|
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
|
ib_backup_tablespaces("test", "t1");
|
EOF
|
UNLOCK TABLES;
|
DROP TABLE t1;
|
|
# New table without FTS index
|
CREATE TABLE t1(f1 CHAR(10))Engine=InnoDB;
|
ALTER TABLE t1 DISCARD TABLESPACE;
|
perl;
|
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
|
ib_discard_tablespaces("test", "t1");
|
ib_restore_tablespaces("test", "t1");
|
EOF
|
|
--disable_warnings
|
ALTER TABLE t1 IMPORT TABLESPACE;
|
--enable_warnings
|
SHOW CREATE TABLE t1;
|
SELECT COUNT(*) FROM t1;
|
DROP TABLE t1;
|
If we run the above test case in 10.4.22 :
'ALTER TABLE t1 IMPORT TABLESPACE' failed: 1808: Schema mismatch (Number of columns don't match, table has 4 columns but the tablespace meta-data file has 5 columns)
|
But in latest 10.4:
query 'ALTER TABLE t1 IMPORT TABLESPACE' failed: 1808: Schema mismatch (Number of indexes don't match, table has 1 indexes but the tablespace meta-data file has 2 indexes)
|
If we use the old .cfg file in latest 10.4 and 10.5 version then we get the same error:
MariaDB [test]> ALTER TABLE t1 IMPORT TABLESPACE;
|
ERROR 1808 (HY000): Schema mismatch (Number of indexes don't match, table has 1 indexes but the tablespace meta-data file has 2 indexes)
|
InnoDB can import the tablespace without .cfg file if the table doesn't have any secondary
index. (latest 10.4, latest 10.5)
--source include/have_innodb.inc
|
# FTS TABLE
|
CREATE TABLE t1(f1 CHAR(10), fulltext f_idx(f1))engine=innodb;
|
INSERT INTO t1 values("thiru");
|
ALTER TABLE t1 DROP INDEX f_idx;
|
FLUSH TABLE t1 FOR EXPORT;
|
let MYSQLD_DATADIR =`SELECT @@datadir`;
|
perl;
|
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
|
ib_backup_tablespaces("test", "t1");
|
EOF
|
UNLOCK TABLES;
|
DROP TABLE t1;
|
|
# New table without FTS index
|
CREATE TABLE t1(f1 CHAR(10))Engine=InnoDB;
|
ALTER TABLE t1 DISCARD TABLESPACE;
|
perl;
|
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
|
ib_discard_tablespaces("test", "t1");
|
ib_restore_tablespaces("test", "t1");
|
EOF
|
|
--echo # Remove .cfg file
|
--remove_file $MYSQLD_DATADIR/test/t1.cfg
|
--disable_warnings
|
ALTER TABLE t1 IMPORT TABLESPACE;
|
--enable_warnings
|
SHOW CREATE TABLE t1;
|
SELECT COUNT(*) FROM t1;
|
DROP TABLE t1;
|
Workaround can be like
1) Remove .cfg file and remove all secondary indexes from table
2) import the tablespace
3) ALTER TABLE … FORCE, ADD INDEX.. (add all secondary indexes)
Following test case in 10.4.18 throws the error:
ERROR 1808 (HY000): Schema mismatch (Number of indexes don't match, table has 1 indexes but the tablespace meta-data file has 2 indexes)
Test case:
--source include/have_innodb.inc
# FTS TABLE
CREATE TABLE t1(f1 CHAR(10), fulltext f_idx(f1))engine=innodb;
INSERT INTO t1 values("thiru");
ALTER TABLE t1 DROP INDEX f_idx;
FLUSH TABLE t1 FOR EXPORT;
let MYSQLD_DATADIR =`SELECT @@datadir`;
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_backup_tablespaces("test", "t1");
EOF
UNLOCK TABLES;
DROP TABLE t1;
# New table without FTS index
CREATE TABLE t1(f1 CHAR(10))Engine=InnoDB;
ALTER TABLE t1 DISCARD TABLESPACE;
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_discard_tablespaces("test", "t1");
ib_restore_tablespaces("test", "t1");
EOF
--disable_warnings
ALTER TABLE t1 IMPORT TABLESPACE;
--enable_warnings
SHOW CREATE TABLE t1;
SELECT COUNT(*) FROM t1;
DROP TABLE t1;
If we run the above test case in 10.4.22 :
'ALTER TABLE t1 IMPORT TABLESPACE' failed: 1808: Schema mismatch (Number of columns don't match, table has 4 columns but the tablespace meta-data file has 5 columns)
But in latest 10.4:
query 'ALTER TABLE t1 IMPORT TABLESPACE' failed: 1808: Schema mismatch (Number of indexes don't match, table has 1 indexes but the tablespace meta-data file has 2 indexes)
If we use the old .cfg file in latest 10.4 and 10.5 version then we get the same error:
MariaDB [test]> ALTER TABLE t1 IMPORT TABLESPACE;
ERROR 1808 (HY000): Schema mismatch (Number of indexes don't match, table has 1 indexes but the tablespace meta-data file has 2 indexes)
InnoDB can import the tablespace without .cfg file if the table doesn't have any secondary
index. (latest 10.4, latest 10.5)
--source include/have_innodb.inc
# FTS TABLE
CREATE TABLE t1(f1 CHAR(10), fulltext f_idx(f1))engine=innodb;
INSERT INTO t1 values("thiru");
ALTER TABLE t1 DROP INDEX f_idx;
FLUSH TABLE t1 FOR EXPORT;
let MYSQLD_DATADIR =`SELECT @@datadir`;
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_backup_tablespaces("test", "t1");
EOF
UNLOCK TABLES;
DROP TABLE t1;
# New table without FTS index
CREATE TABLE t1(f1 CHAR(10))Engine=InnoDB;
ALTER TABLE t1 DISCARD TABLESPACE;
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_discard_tablespaces("test", "t1");
ib_restore_tablespaces("test", "t1");
EOF
--echo # Remove .cfg file
--remove_file $MYSQLD_DATADIR/test/t1.cfg
--disable_warnings
ALTER TABLE t1 IMPORT TABLESPACE;
--enable_warnings
SHOW CREATE TABLE t1;
SELECT COUNT(*) FROM t1;
DROP TABLE t1;
Workaround can be like
1) Remove .cfg file and remove all secondary indexes from table
2) import the tablespace
3) ALTER TABLE … FORCE, ADD INDEX.. (add all secondary indexes)