summaryrefslogtreecommitdiff
path: root/sql/structs.h
diff options
context:
space:
mode:
authorYuchen Pei <yuchen.pei@mariadb.com>2023-03-22 10:31:26 +1100
committerYuchen Pei <yuchen.pei@mariadb.com>2023-03-30 10:33:03 +1100
commit2d36352c1383e000f39a9b73148067f113e49faf (patch)
treeddd5bf9eeec60d17c9063f0f506ff3cda066b57e /sql/structs.h
parent2b61ff8f2221745f0a96855a0feb0825c426f993 (diff)
downloadmariadb-git-bb-11.1-mdev-26137-squashed.tar.gz
MDEV-26137 Improve import tablespace workflow.bb-11.1-mdev-26137-squashed
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: Yuchen Pei <yuchen.pei@mariadb.com>
Diffstat (limited to 'sql/structs.h')
-rw-r--r--sql/structs.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/sql/structs.h b/sql/structs.h
index 214fcb242ff..53bf84f8e59 100644
--- a/sql/structs.h
+++ b/sql/structs.h
@@ -537,7 +537,8 @@ public:
OPT_OR_REPLACE_SLAVE_GENERATED= 32,// REPLACE was added on slave, it was
// not in the original query on master.
OPT_IF_EXISTS= 64,
- OPT_CREATE_SELECT= 128 // CREATE ... SELECT
+ OPT_CREATE_SELECT= 128, // CREATE ... SELECT
+ OPT_IMPORT_TABLESPACE= 256 // ALTER ... IMPORT TABLESPACE
};
private:
@@ -566,6 +567,7 @@ public:
bool like() const { return m_options & OPT_LIKE; }
bool if_exists() const { return m_options & OPT_IF_EXISTS; }
bool is_create_select() const { return m_options & OPT_CREATE_SELECT; }
+ bool import_tablespace() const { return m_options & OPT_IMPORT_TABLESPACE; }
void add(const DDL_options_st::Options other)
{