Commit 23422c45 authored by Yuchen Pei's avatar Yuchen Pei

Adding testcase

parent 15ec36a6
CREATE TABLE t1 (a int) ENGINE=InnoDB;
INSERT INTO t1 VALUES(42);
CREATE TABLE t2 LIKE t1;
ALTER TABLE t2 DISCARD TABLESPACE;
FLUSH TABLES t1 FOR EXPORT;
UNLOCK TABLES;
ALTER TABLE t2 IMPORT TABLESPACE;
SELECT * from t2;
a
42
DROP TABLE t1, t2;
#
# MDEV-26137 ALTER TABLE IMPORT enhancement
#
CREATE TABLE t1 (a int) ENGINE=InnoDB;
INSERT INTO t1 VALUES(42);
FLUSH TABLES t1 FOR EXPORT;
UNLOCK TABLES;
ALTER TABLE t2 IMPORT TABLESPACE;
SELECT * FROM t2;
a
42
DROP TABLE t1, t2;
CREATE TABLE t1 (a int) ENGINE=InnoDB;
INSERT INTO t1 VALUES(42);
FLUSH TABLES t1 FOR EXPORT;
UNLOCK TABLES;
DROP TABLE t1;
ALTER TABLE t2 IMPORT TABLESPACE;
SELECT * FROM t2;
a
42
DROP TABLE t2;
CREATE TABLE t1 (a int) ENGINE=InnoDB;
INSERT INTO t1 VALUES(42);
CREATE TABLE t2 LIKE t1;
FLUSH TABLES t1 FOR EXPORT;
UNLOCK TABLES;
DROP TABLE t1;
call mtr.add_suppression("InnoDB: Unable to import tablespace");
ALTER TABLE t2 IMPORT TABLESPACE;
ERROR HY000: Tablespace for table 'test/t2' exists. Please DISCARD the tablespace before IMPORT
SELECT * FROM t2;
a
DROP TABLE t2;
ALTER TABLE t2 IMPORT TABLESPACE;
ERROR 42S02: Table 'test.t2' doesn't exist
--source include/have_innodb.inc
let $MYSQLD_DATADIR = `SELECT @@datadir`;
# existing workflow
CREATE TABLE t1 (a int) ENGINE=InnoDB;
INSERT INTO t1 VALUES(42);
CREATE TABLE t2 LIKE t1;
ALTER TABLE t2 DISCARD TABLESPACE;
FLUSH TABLES t1 FOR EXPORT;
--copy_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;
ALTER TABLE t2 IMPORT TABLESPACE;
SELECT * from t2;
DROP TABLE t1, t2;
--echo #
--echo # MDEV-26137 ALTER TABLE IMPORT enhancement
--echo #
# enhanced workflow
CREATE TABLE t1 (a int) ENGINE=InnoDB;
INSERT INTO t1 VALUES(42);
FLUSH TABLES t1 FOR EXPORT;
--copy_file $MYSQLD_DATADIR/test/t1.cfg $MYSQLD_DATADIR/test/t2.cfg
--copy_file $MYSQLD_DATADIR/test/t1.frm $MYSQLD_DATADIR/test/t2.frm
--copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_DATADIR/test/t2.ibd
UNLOCK TABLES;
ALTER TABLE t2 IMPORT TABLESPACE;
SELECT * FROM t2;
DROP TABLE t1, t2;
# a variant of the previous case, but we drop t1 before importing t2
CREATE TABLE t1 (a int) ENGINE=InnoDB;
INSERT INTO t1 VALUES(42);
FLUSH TABLES t1 FOR EXPORT;
--copy_file $MYSQLD_DATADIR/test/t1.cfg $MYSQLD_DATADIR/test/t2.cfg
--copy_file $MYSQLD_DATADIR/test/t1.frm $MYSQLD_DATADIR/test/t2.frm
--copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_DATADIR/test/t2.ibd
UNLOCK TABLES;
DROP TABLE t1;
ALTER TABLE t2 IMPORT TABLESPACE;
SELECT * FROM t2;
DROP TABLE t2;
# created t2 but did not discard tablespace
CREATE TABLE t1 (a int) ENGINE=InnoDB;
INSERT INTO t1 VALUES(42);
CREATE TABLE t2 LIKE t1;
FLUSH TABLES t1 FOR EXPORT;
--copy_file $MYSQLD_DATADIR/test/t1.cfg $MYSQLD_DATADIR/test/t2.cfg
--error 1
--copy_file $MYSQLD_DATADIR/test/t1.frm $MYSQLD_DATADIR/test/t2.frm
--error 1
--copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_DATADIR/test/t2.ibd
UNLOCK TABLES;
DROP TABLE t1;
call mtr.add_suppression("InnoDB: Unable to import tablespace");
--error ER_TABLESPACE_EXISTS
ALTER TABLE t2 IMPORT TABLESPACE;
SELECT * FROM t2;
DROP TABLE t2;
# attempt to import when there's no tablespace
--error ER_NO_SUCH_TABLE
ALTER TABLE t2 IMPORT TABLESPACE;
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