Skip to content

Commit faaecc8

Browse files
committed
MDEV-27273 Confusing column count in IMPORT TABLESPACE error message
It's misleading to compare and write to user number of columns and fields. Thus, it would be better to remove that check and let use see a subsequent error message about missing or mispaced column. row_import::match_schema(): remove misleading check
1 parent 991d5dc commit faaecc8

File tree

4 files changed

+56
-10
lines changed

4 files changed

+56
-10
lines changed

mysql-test/suite/innodb/r/innodb-wl5522.result

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ SELECT * FROM t1;
331331
ERROR HY000: Tablespace has been discarded for table `t1`
332332
restore: t1 .ibd and .cfg files
333333
ALTER TABLE t1 IMPORT TABLESPACE;
334-
ERROR HY000: Schema mismatch (Number of columns don't match, table has 6 columns but the tablespace meta-data file has 5 columns)
334+
ERROR HY000: Schema mismatch (Column c3 not found in tablespace.)
335335
unlink: t1.ibd
336336
unlink: t1.cfg
337337
DROP TABLE t1;
@@ -916,6 +916,22 @@ c1 c2
916916
15 1
917917
16 1
918918
DROP TABLE t1;
919+
CREATE TABLE t1 ( id INT NOT NULL, i1 INT, i2 INT, i3 INT, PRIMARY KEY (id)) engine=innodb;
920+
CREATE TABLE t2 ( id INT NOT NULL, i1 INT, i2 INT, PRIMARY KEY (id)) engine=innodb;
921+
ALTER TABLE t2 DISCARD TABLESPACE;
922+
FLUSH TABLES t1 FOR EXPORT;
923+
UNLOCK TABLES;
924+
ALTER TABLE t2 IMPORT TABLESPACE;
925+
ERROR HY000: Schema mismatch (Column DB_ROW_ID ordinal value mismatch, it's at 3 in the table and 4 in the tablespace meta-data file)
926+
DROP TABLE t1, t2;
927+
CREATE TABLE t1 ( id INT NOT NULL, i1 INT, i2 INT, PRIMARY KEY (id)) engine=innodb;
928+
CREATE TABLE t2 ( id INT NOT NULL, i1 INT, i2 INT, i3 INT, PRIMARY KEY (id)) engine=innodb;
929+
ALTER TABLE t2 DISCARD TABLESPACE;
930+
FLUSH TABLES t1 FOR EXPORT;
931+
UNLOCK TABLES;
932+
ALTER TABLE t2 IMPORT TABLESPACE;
933+
ERROR HY000: Schema mismatch (Column i3 not found in tablespace.)
934+
DROP TABLE t1, t2;
919935
call mtr.add_suppression("Got error -1 when reading table '.*'");
920936
call mtr.add_suppression("InnoDB: Error: tablespace id and flags in file '.*'");
921937
call mtr.add_suppression("InnoDB: The table .* doesn't have a corresponding tablespace, it was discarded");

mysql-test/suite/innodb/t/innodb-wl5522.test

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,44 @@ SELECT * FROM t1;
10571057

10581058
DROP TABLE t1;
10591059

1060+
1061+
CREATE TABLE t1 ( id INT NOT NULL, i1 INT, i2 INT, i3 INT, PRIMARY KEY (id)) engine=innodb;
1062+
CREATE TABLE t2 ( id INT NOT NULL, i1 INT, i2 INT, PRIMARY KEY (id)) engine=innodb;
1063+
1064+
ALTER TABLE t2 DISCARD TABLESPACE;
1065+
FLUSH TABLES t1 FOR EXPORT;
1066+
1067+
--copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_DATADIR/test/t2.ibd
1068+
--copy_file $MYSQLD_DATADIR/test/t1.cfg $MYSQLD_DATADIR/test/t2.cfg
1069+
1070+
UNLOCK TABLES;
1071+
--error ER_TABLE_SCHEMA_MISMATCH
1072+
ALTER TABLE t2 IMPORT TABLESPACE;
1073+
1074+
DROP TABLE t1, t2;
1075+
1076+
1077+
CREATE TABLE t1 ( id INT NOT NULL, i1 INT, i2 INT, PRIMARY KEY (id)) engine=innodb;
1078+
--remove_file $MYSQLD_DATADIR/test/t2.ibd
1079+
CREATE TABLE t2 ( id INT NOT NULL, i1 INT, i2 INT, i3 INT, PRIMARY KEY (id)) engine=innodb;
1080+
1081+
ALTER TABLE t2 DISCARD TABLESPACE;
1082+
FLUSH TABLES t1 FOR EXPORT;
1083+
1084+
--copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_DATADIR/test/t2.ibd
1085+
--copy_file $MYSQLD_DATADIR/test/t1.cfg $MYSQLD_DATADIR/test/t2.cfg
1086+
1087+
UNLOCK TABLES;
1088+
--error ER_TABLE_SCHEMA_MISMATCH
1089+
ALTER TABLE t2 IMPORT TABLESPACE;
1090+
1091+
--remove_file $MYSQLD_DATADIR/test/t2.ibd
1092+
--remove_file $MYSQLD_DATADIR/test/t2.cfg
1093+
1094+
1095+
DROP TABLE t1, t2;
1096+
1097+
10601098
call mtr.add_suppression("Got error -1 when reading table '.*'");
10611099
call mtr.add_suppression("InnoDB: Error: tablespace id and flags in file '.*'");
10621100
call mtr.add_suppression("InnoDB: The table .* doesn't have a corresponding tablespace, it was discarded");

mysql-test/suite/innodb_zip/r/wl5522_zip.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ SELECT * FROM t1;
317317
ERROR HY000: Tablespace has been discarded for table `t1`
318318
restore: t1 .ibd and .cfg files
319319
ALTER TABLE t1 IMPORT TABLESPACE;
320-
ERROR HY000: Schema mismatch (Number of columns don't match, table has 6 columns but the tablespace meta-data file has 5 columns)
320+
ERROR HY000: Schema mismatch (Column c3 not found in tablespace.)
321321
unlink: t1.ibd
322322
unlink: t1.cfg
323323
DROP TABLE t1;

storage/innobase/row/row0import.cc

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,14 +1320,6 @@ row_import::match_schema(
13201320
" .cfg file uses %s",
13211321
m_table->flags, m_flags, msg);
13221322

1323-
return(DB_ERROR);
1324-
} else if (m_table->n_cols != m_n_cols) {
1325-
ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_TABLE_SCHEMA_MISMATCH,
1326-
"Number of columns don't match, table has %u "
1327-
"columns but the tablespace meta-data file has "
1328-
ULINTPF " columns",
1329-
m_table->n_cols, m_n_cols);
1330-
13311323
return(DB_ERROR);
13321324
} else if (UT_LIST_GET_LEN(m_table->indexes) != m_n_indexes) {
13331325

0 commit comments

Comments
 (0)