Skip to content

Commit 6c8a37f

Browse files
committed
WIP MDEV-39092: back up some non-InnoDB files
1 parent 5900319 commit 6c8a37f

7 files changed

Lines changed: 511 additions & 8 deletions

File tree

mysql-test/suite/backup/backup_innodb,debug.rdiff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--- backup_innodb.result
22
+++ backup_innodb,debug.result
3-
@@ -18,7 +18,13 @@
3+
@@ -22,7 +22,13 @@
44
BEGIN;
55
DELETE FROM t;
66
connect backup,localhost,root;

mysql-test/suite/backup/backup_innodb.result

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ CREATE TABLE t(a INT PRIMARY KEY, b CHAR(255) DEFAULT '' NOT NULL, INDEX(b))
22
ENGINE=INNODB;
33
BEGIN;
44
INSERT INTO t SET a=1;
5+
CREATE TABLE at1(i INTEGER) ENGINE=Aria TRANSACTIONAL=1;
6+
INSERT INTO at1 VALUES (2), (3), (5), (7);
7+
CREATE TABLE at0 (i INTEGER) ENGINE=Aria TRANSACTIONAL=0;
8+
INSERT INTO at0 VALUES (1), (1), (2), (3), (5);
59
BACKUP SERVER TO '$target_directory';
610
BACKUP SERVER TO '$target_directory' WITH '/bin/false';
711
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH '/bin/false'' at line 1
@@ -25,8 +29,34 @@ ROLLBACK;
2529
SELECT * FROM t;
2630
a b
2731
1
28-
# restart
32+
DELETE FROM t;
33+
DROP TABLE at0, at1;
34+
# restart: --defaults-file=MYSQLTEST_VARDIR/some_directory/backup.cnf --datadir=MYSQLTEST_VARDIR/some_directory
2935
SELECT * FROM t;
3036
a b
3137
1
38+
DELETE FROM t;
39+
ERROR HY000: Table 't' is read only
40+
SELECT * FROM at0;
41+
i
42+
1
43+
1
44+
2
45+
3
46+
5
47+
SELECT * FROM at1;
48+
i
49+
2
50+
3
51+
5
52+
7
53+
DROP TABLE t, at0, at1;
54+
ERROR HY000: Table 't' is read only
55+
SELECT * FROM at0;
56+
ERROR 42S02: Table 'test.at0' doesn't exist
57+
SELECT * FROM at1;
58+
ERROR 42S02: Table 'test.at1' doesn't exist
59+
# restart
60+
SELECT * FROM t;
61+
a b
3262
DROP TABLE t;

mysql-test/suite/backup/backup_innodb.test

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ ENGINE=INNODB;
77
BEGIN;
88
INSERT INTO t SET a=1;
99

10+
CREATE TABLE at1(i INTEGER) ENGINE=Aria TRANSACTIONAL=1;
11+
INSERT INTO at1 VALUES (2), (3), (5), (7);
12+
CREATE TABLE at0 (i INTEGER) ENGINE=Aria TRANSACTIONAL=0;
13+
INSERT INTO at0 VALUES (1), (1), (2), (3), (5);
14+
1015
--let $target_directory=/tmp/some_directory$MTR_COMBINATION_ARCHIVED
1116
# comment out the following line (and replace all "rmdir" with "exec rm -fr")
1217
# to test cross-filesystem copy
@@ -57,13 +62,42 @@ eval BACKUP SERVER TO '$target_directory' 4 CONCURRENT;
5762
--connection default
5863
ROLLBACK;
5964
SELECT * FROM t;
65+
DELETE FROM t;
66+
DROP TABLE at0, at1;
6067

61-
let $datadir=`SELECT @@datadir`;
62-
--source include/shutdown_mysqld.inc
63-
#--rmdir $datadir
64-
#--move_file $MYSQLTEST_VARDIR/some_directory $datadir
65-
--rmdir $MYSQLTEST_VARDIR/some_directory
66-
--source include/start_mysqld.inc
68+
if ($MARIADB_UPGRADE_EXE) {
69+
let target_directory=$target_directory;
70+
perl;
71+
open IN, "<", "$ENV{MYSQLTEST_VARDIR}/my.cnf";
72+
open OUT, ">>", "$ENV{target_directory}/backup.cnf";
73+
print OUT while (<IN>);
74+
close(IN);
75+
close(OUT);
76+
EOF
77+
}
78+
if (!$MARIADB_UPGRADE_EXE) {
79+
--exec cat $MYSQLTEST_VARDIR/my.cnf >> $target_directory/backup.cnf
80+
}
81+
--let $restart_parameters=--defaults-file=$target_directory/backup.cnf --datadir=$target_directory
82+
--source include/restart_mysqld.inc
6783

84+
SELECT * FROM t;
85+
# A nonzero innodb_log_recovery_target makes InnoDB read-only.
86+
--error ER_OPEN_AS_READONLY
87+
DELETE FROM t;
88+
# Non-InnoDB tables are read-write.
89+
SELECT * FROM at0;
90+
SELECT * FROM at1;
91+
--error ER_OPEN_AS_READONLY
92+
DROP TABLE t, at0, at1;
93+
--error ER_NO_SUCH_TABLE
94+
SELECT * FROM at0;
95+
--error ER_NO_SUCH_TABLE
96+
SELECT * FROM at1;
97+
98+
--let $restart_parameters=
99+
--source include/restart_mysqld.inc
68100
SELECT * FROM t;
69101
DROP TABLE t;
102+
103+
--rmdir $target_directory

storage/maria/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ SET(ARIA_SOURCES ma_init.c ma_open.c ma_extra.c ma_info.c ma_rkey.c
4545
ha_maria.h maria_def.h ma_recovery_util.c ma_servicethread.c
4646
ma_norec.c
4747
ma_crypt.c ma_backup.c
48+
ma_backup.cc ma_backup.h
4849
)
4950

5051
IF(APPLE)

storage/maria/ha_maria.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <myisampack.h>
2424
#include <my_bit.h>
2525
#include "ha_maria.h"
26+
#include "ma_backup.h"
2627
#include "trnman_public.h"
2728
#include "trnman.h"
2829

@@ -3942,6 +3943,9 @@ static int ha_maria_init(void *p)
39423943
maria_hton->prepare_for_backup= maria_prepare_for_backup;
39433944
maria_hton->end_backup= maria_end_backup;
39443945
maria_hton->update_optimizer_costs= aria_update_optimizer_costs;
3946+
maria_hton->backup_start= aria_backup_start;
3947+
maria_hton->backup_step= aria_backup_step;
3948+
maria_hton->backup_end= aria_backup_end;
39453949

39463950
/* TODO: decide if we support Maria being used for log tables */
39473951
maria_hton->flags= (HTON_CAN_RECREATE | HTON_SUPPORT_LOG_TABLES |

0 commit comments

Comments
 (0)