mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 02:51:44 +01:00
4e7ee166a9
When importing a tablespace, we must initialize dummy DEFAULT NULL values for any instantly added columns in order to avoid a debug assertion failure when PageConverter::update_records() invokes rec_get_offsets(). Finally, when the operation completes, we must evict and reload the table definition, so that the correct default values for instantly added columns will be loaded. ha_innobase::discard_or_import_tablespace(): On successful IMPORT TABLESPACE, evict and reload the table definition, so that btr_cur_instant_init() will load the correct metadata. PageConverter::update_index_page(): Fill in dummy DEFAULT NULL values for instantly added columns. These will be replaced upon the completion of the operation by evicting and reloading the metadata. row_discard_tablespace(): Invoke dict_table_t::remove_instant(). After DISCARD TABLESPACE, the table is no longer in "instant ALTER" format, because there is no data file attached.
52 lines
1.5 KiB
Text
52 lines
1.5 KiB
Text
--source include/have_innodb.inc
|
|
set default_storage_engine=innodb;
|
|
|
|
--echo #
|
|
--echo # MDEV-18295 IMPORT TABLESPACE fails with instant-altered tables
|
|
--echo #
|
|
|
|
create table t2 (x int, z int default 41);
|
|
alter table t2 discard tablespace;
|
|
|
|
create table t1 (x int);
|
|
insert into t1 values (1);
|
|
alter table t1 add z int default 42, algorithm instant;
|
|
select * from t1;
|
|
flush tables t1 for export;
|
|
--let $MYSQLD_DATADIR= `select @@datadir`
|
|
--move_file $MYSQLD_DATADIR/test/t1.cfg $MYSQLD_DATADIR/test/t2.cfg
|
|
--copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_DATADIR/test/t2.ibd
|
|
unlock tables;
|
|
|
|
--echo # The metadata has to be updated to instant ADD COLUMN.
|
|
alter table t2 import tablespace;
|
|
|
|
select * from t2;
|
|
insert into t2 set x=2;
|
|
select * from t2;
|
|
|
|
alter table t1 discard tablespace;
|
|
flush tables t2 for export;
|
|
--move_file $MYSQLD_DATADIR/test/t2.cfg $MYSQLD_DATADIR/test/t1.cfg
|
|
--copy_file $MYSQLD_DATADIR/test/t2.ibd $MYSQLD_DATADIR/test/t1.ibd
|
|
unlock tables;
|
|
|
|
--echo # Both the metadata and the data file used instant ADD COLUMN.
|
|
alter table t1 import tablespace;
|
|
select * from t1;
|
|
|
|
drop table t2;
|
|
create table t2 select * from t1;
|
|
|
|
alter table t1 discard tablespace;
|
|
flush tables t2 for export;
|
|
--move_file $MYSQLD_DATADIR/test/t2.cfg $MYSQLD_DATADIR/test/t1.cfg
|
|
--copy_file $MYSQLD_DATADIR/test/t2.ibd $MYSQLD_DATADIR/test/t1.ibd
|
|
unlock tables;
|
|
|
|
--echo # The instant ADD COLUMN has to be removed from the metadata.
|
|
alter table t1 import tablespace;
|
|
select * from t1;
|
|
|
|
drop table t2;
|
|
drop table t1;
|