| 1 |
--source include/have_debug.inc |
| 2 |
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; |
| 3 |
mkdir $targetdir; |
| 4 |
|
| 5 |
CREATE TABLE t1(i int) ENGINE INNODB; |
| 6 |
INSERT into t1 values(1); |
| 7 |
|
| 8 |
CREATE TABLE t2(i int) ENGINE INNODB; |
| 9 |
INSERT INTO t2 values(2); |
| 10 |
|
| 11 |
CREATE TABLE t3(i int) ENGINE INNODB; |
| 12 |
CREATE TABLE t4(i int) ENGINE INNODB; |
| 13 |
CREATE TABLE t5(i int) ENGINE INNODB; |
| 14 |
INSERT INTO t5 VALUES(5); |
| 15 |
|
| 16 |
CREATE TABLE a(a int) ENGINE INNODB; |
| 17 |
INSERT INTO a values(1); |
| 18 |
CREATE TABLE b(b CHAR(1)) ENGINE INNODB; |
| 19 |
INSERT INTO b VALUES('b'); |
| 20 |
|
| 21 |
CREATE TABLE a1(a1 int) ENGINE INNODB; |
| 22 |
INSERT INTO a1 VALUES(1); |
| 23 |
|
| 24 |
CREATE TABLE b1(b1 CHAR(2)) ENGINE INNODB; |
| 25 |
INSERT INTO b1 VALUES('b1'); |
| 26 |
|
| 27 |
set global innodb_log_checkpoint_now = 1; |
| 28 |
|
| 29 |
# Test renames before of after copying tablespaces |
| 30 |
--let before_copy_test_t1=RENAME TABLE test.t1 TO test.t1_renamed |
| 31 |
--let after_copy_test_t2=RENAME TABLE test.t2 TO test.t2_renamed |
| 32 |
--let after_copy_test_t3=BEGIN NOT ATOMIC RENAME TABLE test.t3 TO test.t3_tmp; INSERT INTO test.t3_tmp VALUES(3); RENAME TABLE test.t3_tmp TO test.t3; END |
| 33 |
--let before_copy_test_t4=RENAME TABLE test.t4 TO test.t4_tmp |
| 34 |
--let after_copy_test_t4=RENAME TABLE test.t4_tmp TO test.t4 |
| 35 |
--let after_copy_test_t5=BEGIN NOT ATOMIC RENAME TABLE test.t5 TO test.t6; CREATE TABLE test.t5(i int) ENGINE INNODB; END |
| 36 |
|
| 37 |
# Test circular renames |
| 38 |
--let before_copy_test_b=RENAME TABLE test.a to test.tmp, test.b to test.a, test.tmp to test.b |
| 39 |
--let after_copy_test_b1=RENAME TABLE test.a1 to test.tmp, test.b1 to test.a1, test.tmp to test.b1 |
| 40 |
|
| 41 |
--disable_result_log |
| 42 |
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --dbug=+d,mariabackup_events; |
| 43 |
--enable_result_log |
| 44 |
|
| 45 |
--let before_copy_test_t1='' |
| 46 |
--let after_copy_test_t2='' |
| 47 |
--let before_copy_test_a='' |
| 48 |
--let after_copy_test_a1='' |
| 49 |
|
| 50 |
echo # xtrabackup prepare; |
| 51 |
--disable_result_log |
| 52 |
exec $XTRABACKUP --prepare --target-dir=$targetdir; |
| 53 |
-- source include/restart_and_restore.inc |
| 54 |
--enable_result_log |
| 55 |
|
| 56 |
# the table was renamed from t1 to t1_renamed |
| 57 |
# make sure t1 does not exist, and t1_renamed does. |
| 58 |
|
| 59 |
CREATE TABLE t1(i int); |
| 60 |
DROP TABLE t1; |
| 61 |
|
| 62 |
SELECT * from t1_renamed; |
| 63 |
DROP TABLE t1_renamed; |
| 64 |
|
| 65 |
|
| 66 |
CREATE TABLE t2(i int); |
| 67 |
DROP TABLE t2; |
| 68 |
|
| 69 |
SELECT * from t2_renamed; |
| 70 |
DROP TABLE t2_renamed; |
| 71 |
|
| 72 |
#rename to itself |
| 73 |
SELECT * from t3; |
| 74 |
DROP TABLE t3; |
| 75 |
|
| 76 |
SELECT * from t4; |
| 77 |
DROP TABLE t4; |
| 78 |
|
| 79 |
# For circular renames , make sure intermediate tables do not exist |
| 80 |
CREATE TABLE tmp(i int); |
| 81 |
DROP TABLE tmp; |
| 82 |
|
| 83 |
SELECT * FROM a; |
| 84 |
SELECT * FROM b; |
| 85 |
SELECT * FROM a1; |
| 86 |
SELECT * FROM b1; |
| 87 |
|
| 88 |
DROP TABLE a,b,a1,b1; |
| 89 |
SELECT * from t5; |
| 90 |
DROP TABLE t5; |
| 91 |
SELECT * from t6; |
| 92 |
DROP TABLE t6; |
| 93 |
rmdir $targetdir; |
| 94 |
|
| 95 |
--echo # |
| 96 |
--echo # MDEV-33011 mariabackup --backup: FATAL ERROR: ... Can't open datafile cool_down/t3 |
| 97 |
--echo # |
| 98 |
|
| 99 |
--disable_query_log |
| 100 |
call mtr.add_suppression("InnoDB: Cannot rename '.*t1.ibd' to '.*non_existing_db.*' because the target schema directory doesn't exist"); |
| 101 |
--enable_query_log |
| 102 |
|
| 103 |
mkdir $targetdir; |
| 104 |
|
| 105 |
--echo # Simulate zero initialized page to defer tablespace load after rename log is found |
| 106 |
SET @save_dbug = @@SESSION.debug_dbug; |
| 107 |
SET DEBUG_DBUG="+d,checkpoint_after_file_create"; |
| 108 |
CREATE TABLE t1(f1 INT NOT NULL)ENGINE=InnoDB; |
| 109 |
INSERT INTO t1 VALUES(1); |
| 110 |
|
| 111 |
--echo # RENAME that fails after redo log entry is written and flushed |
| 112 |
--replace_result "\\" "/" |
| 113 |
--error ER_ERROR_ON_RENAME |
| 114 |
RENAME TABLE t1 TO non_existing_db.t1; |
| 115 |
|
| 116 |
--disable_result_log |
| 117 |
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir; |
| 118 |
exec $XTRABACKUP --prepare --target-dir=$targetdir; |
| 119 |
--enable_result_log |
| 120 |
|
| 121 |
DROP TABLE t1; |
| 122 |
rmdir $targetdir; |