[MDEV-27273] Confusing column count in IMPORT TABLESPACE error message Created: 2021-12-15  Updated: 2022-04-26  Resolved: 2022-01-21

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.6.5
Fix Version/s: 10.2.42, 10.3.33, 10.4.23, 10.5.14, 10.6.6, 10.7.2

Type: Bug Priority: Critical
Reporter: Hartmut Holzgraefe Assignee: Eugene Kosov (Inactive)
Resolution: Fixed Votes: 0
Labels: 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;

      1. 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



 Comments   
Comment by Marko Mäkelä [ 2021-12-15 ]

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.)

Comment by Marko Mäkelä [ 2022-01-21 ]

kevg, your fix that would remove the confusing message and prevent a more useful and specific message from being issued, is OK to push.

Generated at Thu Feb 08 09:51:40 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.