Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
10.6.5
-
None
Description
When importing into another table with different column count the column counts given in the error message do not match visible columns in the table.
Note that the tables below have 3 and 4 columns, respectively, but the error message says 6 and 7
noformat
MariaDB [test]> ALTER TABLE t2 IMPORT TABLESPACE;
ERROR 1808 (HY000): Schema mismatch (Number of columns don't match, table has 6 columns but the tablespace meta-data file has 7 columns)
noformat
How to reproduce
noformat
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
id INT NOT NULL,
i1 INT,
i2 INT,
i3 INT,
PRIMARY KEY (id)
) ENGINE=INNODB;
DROP TABLE IF EXISTS t2;
CREATE TABLE t2 (
id INT NOT NULL,
i1 INT,
i2 INT,
PRIMARY KEY (id)
) ENGINE=INNODB;
ALTER TABLE t2 DISCARD TABLESPACE;
FLUSH TABLES t1 FOR EXPORT;
-
-
- in other terminal
-
cd /var/lib/mysql/test
cp -vp t1.ibd t2.ibd
cp -vp t1.cfg t2.cfg
journalctl -u mariadb.service -f
###
UNLOCK TABLES;
ALTER TABLE t2 IMPORT TABLESPACE;
noformat
In the InnoDB clustered index, the system columns DB_TRX_ID and DB_ROLL_PTR will be materialized after the primary key fields. If there is no primary key, a DB_ROW_ID will be added. If the primary key includes column prefixes, then the full columns corresponding to the column prefixes will appear later in the index field list.
The message should refer to index fields, not columns. Because of the complex rules, it would only be confusing to try to subtract the internally added index fields from the column counts. (Someone could complain about confusing "Number of columns don’t match: 3 and 3" if there was a PRIMARY KEY defined in one of the tables.)