Skip to content

Commit

Permalink
MDEV-29972 Crash emitting "Unsupported meta-data version number" erro…
Browse files Browse the repository at this point in the history
…r message

row_import_read_meta_data(): Use ER_NOT_SUPPORTED_YET instead of
ER_IO_READ_ERROR to have a matching error message pattern.
  • Loading branch information
dr-m authored and grooverdan committed Dec 12, 2023
1 parent 8dad514 commit bd01029
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 12 deletions.
Binary file added mysql-test/std_data/mysql80/t2.cfg
Binary file not shown.
Binary file added mysql-test/std_data/mysql80/t2.ibd
Binary file not shown.
14 changes: 13 additions & 1 deletion mysql-test/suite/innodb/r/innodb-wl5522-1.result
Expand Up @@ -808,6 +808,18 @@ call mtr.add_suppression("InnoDB: unsupported MySQL tablespace");
ALTER TABLE t1 IMPORT TABLESPACE;
ERROR 42000: Table 't1' uses an extension that doesn't exist in this MariaDB version
DROP TABLE t1;
#
# End of 10.3 tests
#
# MDEV-29972 crash after "Unsupported meta-data version number"
#
call mtr.add_suppression("Index for table 't2' is corrupt");
CREATE TABLE t2 (i INT PRIMARY KEY) ENGINE=InnoDB;
ALTER TABLE t2 DISCARD TABLESPACE;
ALTER TABLE t2 IMPORT TABLESPACE;
ERROR 42000: This version of MariaDB doesn't yet support 'meta-data version'
ALTER TABLE t2 IMPORT TABLESPACE;
ERROR HY000: Index for table 't2' is corrupt; try to repair it
SELECT * FROM t2;
ERROR HY000: Tablespace has been discarded for table `t2`
DROP TABLE t2;
# End of 10.4 tests
21 changes: 20 additions & 1 deletion mysql-test/suite/innodb/t/innodb-wl5522-1.test
Expand Up @@ -960,6 +960,25 @@ ALTER TABLE t1 IMPORT TABLESPACE;
DROP TABLE t1;
--remove_file $MYSQLTEST_VARDIR/tmp/t1.ibd

--echo #
--echo # End of 10.3 tests

--echo #
--echo # MDEV-29972 crash after "Unsupported meta-data version number"
--echo #

call mtr.add_suppression("Index for table 't2' is corrupt");

CREATE TABLE t2 (i INT PRIMARY KEY) ENGINE=InnoDB;
ALTER TABLE t2 DISCARD TABLESPACE;
--copy_file std_data/mysql80/t2.cfg $MYSQLD_DATADIR/test/t2.cfg
--copy_file std_data/mysql80/t2.ibd $MYSQLD_DATADIR/test/t2.ibd
--error ER_NOT_SUPPORTED_YET
ALTER TABLE t2 IMPORT TABLESPACE;
--remove_file $MYSQLD_DATADIR/test/t2.cfg
--error ER_NOT_KEYFILE
ALTER TABLE t2 IMPORT TABLESPACE;
--error ER_TABLESPACE_DISCARDED
SELECT * FROM t2;
DROP TABLE t2;

--echo # End of 10.4 tests
13 changes: 3 additions & 10 deletions storage/innobase/row/row0import.cc
Expand Up @@ -120,7 +120,6 @@ struct row_import {
row_import() UNIV_NOTHROW
:
m_table(NULL),
m_version(0),
m_hostname(NULL),
m_table_name(NULL),
m_autoinc(0),
Expand Down Expand Up @@ -199,8 +198,6 @@ struct row_import {

dict_table_t* m_table; /*!< Table instance */

ulint m_version; /*!< Version of config file */

byte* m_hostname; /*!< Hostname where the
tablespace was exported */
byte* m_table_name; /*!< Exporting instance table
Expand Down Expand Up @@ -3090,17 +3087,13 @@ row_import_read_meta_data(
return(DB_IO_ERROR);
}

cfg.m_version = mach_read_from_4(row);

/* Check the version number. */
switch (cfg.m_version) {
switch (mach_read_from_4(row)) {
case IB_EXPORT_CFG_VERSION_V1:

return(row_import_read_v1(file, thd, &cfg));
default:
ib_errf(thd, IB_LOG_LEVEL_ERROR, ER_IO_READ_ERROR,
"Unsupported meta-data version number (" ULINTPF "), "
"file ignored", cfg.m_version);
ib_senderrf(thd, IB_LOG_LEVEL_ERROR, ER_NOT_SUPPORTED_YET,
"meta-data version");
}

return(DB_ERROR);
Expand Down

0 comments on commit bd01029

Please sign in to comment.