Skip to content

Commit 857edeb

Browse files
committed
WIP MDEV-14992 BACKUP SERVER
This introduces a basic driver Sql_cmd_backup and storage engine interfaces. TODO: Fully implement the storage engine interfaces. TODO: Implement locking.
1 parent d39b6f1 commit 857edeb

72 files changed

Lines changed: 462 additions & 53 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

libmysqld/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
154154
../sql/json_table.cc
155155
../sql/opt_histogram_json.cc
156156
../sql/sp_instr.cc
157+
../sql/sql_backup.cc
157158
${GEN_SOURCES}
158159
${MYSYS_LIBWRAP_SOURCE}
159160
)

mysql-test/collections/buildbot_suites.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ innodb,^
66
versioning,^
77
plugins,^
88
mariabackup,^
9+
backup,^
910
roles,^
1011
auth_gssapi,^
1112
mysql_sha2,^
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
BACKUP SERVER TO '$datadir/some_directory';
2+
ERROR HY000: Incorrect arguments to BACKUP SERVER TO
3+
BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory';
4+
BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory';
5+
ERROR HY000: Can't create directory 'MYSQLTEST_VARDIR/some_directory' (Errcode: 17 "File exists")
6+
BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory';

mysql-test/main/backup_server.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--let $datadir=`select @@datadir`
2+
--error ER_WRONG_ARGUMENTS
3+
evalp BACKUP SERVER TO '$datadir/some_directory';
4+
evalp BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory';
5+
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
6+
--error 21
7+
evalp BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory';
8+
--rmdir $MYSQLTEST_VARDIR/some_directory
9+
evalp BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory';
10+
--rmdir $MYSQLTEST_VARDIR/some_directory
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
CREATE USER user1@localhost IDENTIFIED BY '';
2+
connect con1,localhost,user1;
3+
BACKUP SERVER TO 'some_directory';
4+
ERROR 42000: Access denied; you need (at least one of) the RELOAD privilege(s) for this operation
5+
disconnect con1;
6+
connection default;
7+
GRANT SELECT ON test.* TO user1@localhost;
8+
connect con1,localhost,user1;
9+
BACKUP SERVER TO 'some_directory';
10+
ERROR 42000: Access denied; you need (at least one of) the RELOAD privilege(s) for this operation
11+
disconnect con1;
12+
connection default;
13+
GRANT RELOAD ON test.* TO user1@localhost;
14+
ERROR HY000: Incorrect usage of DB GRANT and GLOBAL PRIVILEGES
15+
GRANT RELOAD ON *.* TO user1@localhost;
16+
connect con1,localhost,user1;
17+
BACKUP SERVER TO 'some_directory';
18+
ERROR 42000: Access denied; you need (at least one of) the SELECT privilege(s) for this operation
19+
disconnect con1;
20+
connection default;
21+
GRANT SELECT ON *.* TO user1@localhost;
22+
connect con1,localhost,user1;
23+
BACKUP SERVER TO '$datadir/some_directory';
24+
ERROR HY000: Incorrect arguments to BACKUP SERVER TO
25+
disconnect con1;
26+
connection default;
27+
DROP USER user1@localhost;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--source include/not_embedded.inc
2+
CREATE USER user1@localhost IDENTIFIED BY '';
3+
--connect con1,localhost,user1
4+
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
5+
BACKUP SERVER TO 'some_directory';
6+
--disconnect con1
7+
--connection default
8+
GRANT SELECT ON test.* TO user1@localhost;
9+
--connect con1,localhost,user1
10+
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
11+
BACKUP SERVER TO 'some_directory';
12+
--disconnect con1
13+
--connection default
14+
--error ER_WRONG_USAGE
15+
GRANT RELOAD ON test.* TO user1@localhost;
16+
GRANT RELOAD ON *.* TO user1@localhost;
17+
--connect con1,localhost,user1
18+
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
19+
BACKUP SERVER TO 'some_directory';
20+
--disconnect con1
21+
--connection default
22+
GRANT SELECT ON *.* TO user1@localhost;
23+
--connect con1,localhost,user1
24+
--let $datadir=`select @@datadir`
25+
--error ER_WRONG_ARGUMENTS
26+
evalp BACKUP SERVER TO '$datadir/some_directory';
27+
--disconnect con1
28+
--connection default
29+
DROP USER user1@localhost;

mysql-test/main/mysqld--help.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1896,7 +1896,7 @@ performance-schema-max-socket-classes 10
18961896
performance-schema-max-socket-instances -1
18971897
performance-schema-max-sql-text-length 1024
18981898
performance-schema-max-stage-classes 160
1899-
performance-schema-max-statement-classes 222
1899+
performance-schema-max-statement-classes 223
19001900
performance-schema-max-statement-stack 10
19011901
performance-schema-max-table-handles -1
19021902
performance-schema-max-table-instances -1

mysql-test/mariadb-test-run.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ END
180180
main-
181181
archive-
182182
atomic-
183+
backup-
183184
binlog-
184185
binlog_encryption-
185186
client-
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
CREATE TABLE t(i INT PRIMARY KEY) ENGINE=INNODB;
2+
INSERT INTO t VALUES(1);
3+
BEGIN;
4+
DELETE FROM t;
5+
connect backup,localhost,root;
6+
BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory';
7+
disconnect backup;
8+
connection default;
9+
COMMIT;
10+
SELECT * FROM t;
11+
i
12+
# restart
13+
SELECT * FROM t;
14+
i
15+
DROP TABLE t;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--source include/have_innodb.inc
2+
3+
CREATE TABLE t(i INT PRIMARY KEY) ENGINE=INNODB;
4+
INSERT INTO t VALUES(1);
5+
BEGIN;
6+
DELETE FROM t;
7+
8+
--connect backup,localhost,root
9+
evalp BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory';
10+
--disconnect backup
11+
--connection default
12+
13+
COMMIT;
14+
SELECT * FROM t;
15+
16+
let $datadir=`SELECT @@datadir`;
17+
--source include/shutdown_mysqld.inc
18+
#--rmdir $datadir
19+
#--move_file $MYSQLTEST_VARDIR/some_directory $datadir
20+
--rmdir $MYSQLTEST_VARDIR/some_directory
21+
--source include/start_mysqld.inc
22+
23+
SELECT * FROM t;
24+
DROP TABLE t;

0 commit comments

Comments
 (0)