Commit 773479f5 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

Add test for partial backup for partitioned table.

parent 2cf30866
......@@ -1469,7 +1469,7 @@ debug_sync_point(const char *name)
}
static std::vector<std::string> tables_for_export;
static std::set<std::string> tables_for_export;
static void append_export_table(const char *dbname, const char *tablename, bool is_remote)
{
......@@ -1481,7 +1481,15 @@ static void append_export_table(const char *dbname, const char *tablename, bool
char *p=strrchr(buf, '.');
if (p) *p=0;
tables_for_export.push_back(ut_get_name(0,buf));
std::string name=ut_get_name(0, buf);
/* Strip partition name comment from table name, if any */
if (ends_with(name.c_str(), "*/"))
{
size_t pos= name.rfind("/*");
if (pos != std::string::npos)
name.resize(pos);
}
tables_for_export.insert(name);
}
}
......@@ -1496,9 +1504,10 @@ static int create_bootstrap_file()
fputs("SET NAMES UTF8;\n",f);
enumerate_ibd_files(append_export_table);
for (size_t i= 0; i < tables_for_export.size(); i++)
for (std::set<std::string>::iterator it = tables_for_export.begin();
it != tables_for_export.end(); it++)
{
const char *tab = tables_for_export[i].c_str();
const char *tab = it->c_str();
fprintf(f,
"BEGIN NOT ATOMIC "
"DECLARE CONTINUE HANDLER FOR NOT FOUND,SQLEXCEPTION BEGIN END;"
......@@ -1528,7 +1537,7 @@ static int prepare_export()
snprintf(cmdline, sizeof cmdline,
IF_WIN("\"","") "\"%s\" --mysqld \"%s\" "
" --defaults-extra-file=./backup-my.cnf --defaults-group-suffix=%s --datadir=."
" --innodb --innodb-fast-shutdown=0"
" --innodb --innodb-fast-shutdown=0 --loose-partition"
" --innodb_purge_rseg_truncate_frequency=1 --innodb-buffer-pool-size=%llu"
" --console --skip-log-error --bootstrap < " BOOTSTRAP_FILENAME IF_WIN("\"",""),
mariabackup_exe,
......@@ -1540,7 +1549,7 @@ static int prepare_export()
sprintf(cmdline,
IF_WIN("\"","") "\"%s\" --mysqld"
" --defaults-file=./backup-my.cnf --defaults-group-suffix=%s --datadir=."
" --innodb --innodb-fast-shutdown=0"
" --innodb --innodb-fast-shutdown=0 --loose-partition"
" --innodb_purge_rseg_truncate_frequency=1 --innodb-buffer-pool-size=%llu"
" --console --log-error= --bootstrap < " BOOTSTRAP_FILENAME IF_WIN("\"",""),
mariabackup_exe,
......@@ -5851,7 +5860,6 @@ check_all_privileges()
mysql_free_result(result);
int check_result = PRIVILEGE_OK;
bool reload_checked = false;
/* FLUSH TABLES WITH READ LOCK */
if (!opt_no_lock)
......@@ -5859,7 +5867,6 @@ check_all_privileges()
check_result |= check_privilege(
granted_privileges,
"RELOAD", "*", "*");
reload_checked = true;
}
if (!opt_no_lock)
......
CREATE TABLE t1(i INT) ENGINE INNODB
PARTITION BY RANGE (i)
(PARTITION p1 VALUES LESS THAN (100),
PARTITION p2 VALUES LESS THAN (200),
PARTITION p3 VALUES LESS THAN (300),
PARTITION p4 VALUES LESS THAN (400));
INSERT INTO t1 VALUES (1), (101), (201), (301);
# xtrabackup backup
INSERT INTO t1 VALUES (1), (101), (201), (301);
# xtrabackup prepare
CREATE TABLE t1_placeholder (i INT) ENGINE INNODB;
ALTER TABLE t1_placeholder DISCARD TABLESPACE;
ALTER TABLE t1_placeholder IMPORT TABLESPACE;
ALTER TABLE t1 EXCHANGE PARTITION p4 WITH TABLE t1_placeholder;
ALTER TABLE t1_placeholder DISCARD TABLESPACE;
ALTER TABLE t1_placeholder IMPORT TABLESPACE;
ALTER TABLE t1 EXCHANGE PARTITION p3 WITH TABLE t1_placeholder;
ALTER TABLE t1_placeholder DISCARD TABLESPACE;
ALTER TABLE t1_placeholder IMPORT TABLESPACE;
ALTER TABLE t1 EXCHANGE PARTITION p2 WITH TABLE t1_placeholder;
ALTER TABLE t1_placeholder DISCARD TABLESPACE;
ALTER TABLE t1_placeholder IMPORT TABLESPACE;
ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t1_placeholder;
SELECT * FROM t1;
i
1
101
201
301
DROP TABLE t1;
DROP TABLE t1_placeholder;
#--source include/innodb_page_size.inc
# import partitioned table from table from partial backup
CREATE TABLE t1(i INT) ENGINE INNODB
PARTITION BY RANGE (i)
(PARTITION p1 VALUES LESS THAN (100),
PARTITION p2 VALUES LESS THAN (200),
PARTITION p3 VALUES LESS THAN (300),
PARTITION p4 VALUES LESS THAN (400));
INSERT INTO t1 VALUES (1), (101), (201), (301);
echo # xtrabackup backup;
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
--disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup "--tables=test.t1" --target-dir=$targetdir;
--enable_result_log
INSERT INTO t1 VALUES (1), (101), (201), (301);
echo # xtrabackup prepare;
--disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffix=.1 --prepare --export --target-dir=$targetdir;
--enable_result_log
let $MYSQLD_DATADIR= `select @@datadir`;
CREATE TABLE t1_placeholder (i INT) ENGINE INNODB;
let $i=4;
while($i)
{
eval ALTER TABLE t1_placeholder DISCARD TABLESPACE;
copy_file $targetdir/test/t1#P#p$i.cfg $MYSQLD_DATADIR/test/t1_placeholder.cfg;
copy_file $targetdir/test/t1#P#p$i.ibd $MYSQLD_DATADIR/test/t1_placeholder.ibd;
eval ALTER TABLE t1_placeholder IMPORT TABLESPACE;
eval ALTER TABLE t1 EXCHANGE PARTITION p$i WITH TABLE t1_placeholder;
dec $i;
}
SELECT * FROM t1;
DROP TABLE t1;
DROP TABLE t1_placeholder;
rmdir $targetdir;
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