• Yuchen Pei's avatar
    MDEV-26137 Improve import tablespace workflow. · 056c83cc
    Yuchen Pei authored
    Allow ALTER TABLE ... IMPORT TABLESPACE without creating the table
    followed by discarding the tablespace.
    
    That is, assuming we want to import table t1 to t2, instead of
    
    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;
    
    We can simply do
    
    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;
    
    We achieve this by creating a "stub" table in the second scenario
    while opening the table, where t2 does not exist but needs to import
    from t1. The "stub" table is similar to a table that is created but
    then instructed to discard its tablespace.
    
    We include tests with various row formats, encryption, with indexes
    and auto-increment.
    Signed-off-by: default avatarYuchen Pei <yuchen.pei@mariadb.com>
    056c83cc
sql_yacc.yy 588 KB