MDEV-34181 Instant table aborts after discard tablespace

- commit 85db5347 (MDEV-33400)
retains the instantness in the table definition after discard
tablespace. So there is no need to assign n_core_null_bytes
during instant table preparation unless they are not
initialized.
parent 48b256a7
...@@ -61,4 +61,30 @@ id ...@@ -61,4 +61,30 @@ id
4 4
5 5
DROP TABLE t2; DROP TABLE t2;
#
# MDEV-34181 Instant table aborts after discard tablespace
#
CREATE TABLE t1(c3 INT, c2 INT, c1 INT KEY)ENGINE=InnoDB;
INSERT INTO t1 VALUES(1, 1, 1), (2, 2, 2);
CREATE TABLE t2 (c1 INT KEY) ENGINE=InnoDB;
INSERT INTO t2 VALUES(1);
ALTER TABLE t2 ADD c2 INT;
FLUSH TABLES t1 FOR EXPORT;
UNLOCK TABLES;
ALTER TABLE t2 DISCARD TABLESPACE;
ALTER TABLE t2 ADD c3 INT FIRST;
Warnings:
Warning 1814 Tablespace has been discarded for table `t2`
ALTER TABLE t2 IMPORT TABLESPACE;
Warnings:
Warning 1810 IO Read error: (2, No such file or directory) Error opening './test/t2.cfg', will attempt to import without schema verification
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`c3` int(11) DEFAULT NULL,
`c1` int(11) NOT NULL,
`c2` int(11) DEFAULT NULL,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
DROP TABLE t2, t1;
# End of 10.5 tests # End of 10.5 tests
...@@ -78,4 +78,24 @@ INSERT INTO t2() VALUES(); ...@@ -78,4 +78,24 @@ INSERT INTO t2() VALUES();
SELECT * FROM t2 ORDER BY id; SELECT * FROM t2 ORDER BY id;
DROP TABLE t2; DROP TABLE t2;
--echo #
--echo # MDEV-34181 Instant table aborts after discard tablespace
--echo #
CREATE TABLE t1(c3 INT, c2 INT, c1 INT KEY)ENGINE=InnoDB;
INSERT INTO t1 VALUES(1, 1, 1), (2, 2, 2);
CREATE TABLE t2 (c1 INT KEY) ENGINE=InnoDB;
INSERT INTO t2 VALUES(1);
ALTER TABLE t2 ADD c2 INT;
FLUSH TABLES t1 FOR EXPORT;
let $datadir=`select @@datadir`;
--copy_file $datadir/test/t1.ibd $datadir/test/imp_t1.ibd
UNLOCK TABLES;
ALTER TABLE t2 DISCARD TABLESPACE;
ALTER TABLE t2 ADD c3 INT FIRST;
--copy_file $datadir/test/imp_t1.ibd $datadir/test/t2.ibd
--replace_regex /opening '.*\/test\//opening '.\/test\//
ALTER TABLE t2 IMPORT TABLESPACE;
SHOW CREATE TABLE t2;
DROP TABLE t2, t1;
--echo # End of 10.5 tests --echo # End of 10.5 tests
...@@ -374,10 +374,12 @@ inline void dict_table_t::prepare_instant(const dict_table_t& old, ...@@ -374,10 +374,12 @@ inline void dict_table_t::prepare_instant(const dict_table_t& old,
} }
} }
/* In case of discarded tablespace, InnoDB can't /* Discard tablespace doesn't remove the instantness
read the root page. So assign the null bytes based from the table definition. if n_core_null_bytes wasn't
on nullabled fields */ initialized then assign it based on nullable fields */
if (!oindex.table->space) { if (!oindex.table->space
&& oindex.n_core_null_bytes
== dict_index_t::NO_CORE_NULL_BYTES) {
oindex.n_core_null_bytes = static_cast<uint8_t>( oindex.n_core_null_bytes = static_cast<uint8_t>(
UT_BITS_IN_BYTES(unsigned(oindex.n_nullable))); UT_BITS_IN_BYTES(unsigned(oindex.n_nullable)));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment