Skip to content

Commit a631db3

Browse files
PS-9734 merge: Code refresh for 8.0.42-33 (main.mysqldump-tablespace-escape fix)
https://perconadev.atlassian.net/browse/PS-9734 This commit fixes a regression introduced by upstream in MySQL Server 8.0.42. Oracle backported a secirity fix along with an MTR test case for Bug# 37607195 "fprintf_string not using the actual quote parameter (mysql-trunk)" (commit mysql/mysql-server@8afeb980783) from 8.4 to 8.0. Unfortunatelly, this MTR test case relies on 'mysqldump' utility having '--init-command' command line option which is not the case in 8.0 (WL#15662 "Add options to mysqldump to skip views and utilize read ahead" has never been ported to 8.0). Fixed by simulating '--init-command' with setting '@@global.init_connect' system variable on the server side.
1 parent 85dbd96 commit a631db3

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

mysql-test/r/mysqldump-tablespace-escape.result

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ FOREIGN KEY (`'order'_'id'`) REFERENCES "orders"(order_id) ON DELETE CASCADE,
5757
FOREIGN KEY (`product'_'id`) REFERENCES "prod'ucts"("product`_`id") ON DELETE CASCADE,
5858
UNIQUE KEY (`'order'_'id'`, `product'_'id`)
5959
);
60+
CREATE USER 'dump_user'@'localhost';
61+
GRANT PROCESS, LOCK TABLES ON *.* TO 'dump_user'@'localhost';
62+
GRANT SELECT ON bug37607195.* TO 'dump_user'@'localhost';
63+
SET @saved_init_connect = @@global.init_connect;
64+
SET GLOBAL init_connect = "SET @@sql_mode='ANSI_QUOTES,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'";
65+
SET GLOBAL init_connect = @saved_init_connect;
66+
REVOKE SELECT ON bug37607195.* FROM 'dump_user'@'localhost';
67+
REVOKE PROCESS, LOCK TABLES ON *.* FROM 'dump_user'@'localhost';
68+
DROP USER 'dump_user'@'localhost';
6069
# Table 1: `'order'_'items'`
6170
# `qua\ntity` must be escaped
6271
Pattern found.

mysql-test/t/mysqldump-tablespace-escape.test

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,23 @@ CREATE TABLE `'order'_'items'` (
8484
UNIQUE KEY (`'order'_'id'`, `product'_'id`)
8585
);
8686

87-
--exec $MYSQL_DUMP bug37607195 --init-command="SET @@sql_mode='ANSI_QUOTES,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'" --result-file=$grep_file 2>&1
87+
# This part of the MTR test case was backported from 8.4 where 'mysqldump'
88+
# utility has additional '--init-command="..."' parameter which is
89+
# unfortunately unavailable in 8.0.
90+
# Here we simulate this missing command-line option with
91+
# '@@global.init_connect' server global system variable. However, as this
92+
# variable affects only non-administrative MySQL users, we also need to create
93+
# a new user 'dump_user' and grant her with enough privileges to do backups.
94+
CREATE USER 'dump_user'@'localhost';
95+
GRANT PROCESS, LOCK TABLES ON *.* TO 'dump_user'@'localhost';
96+
GRANT SELECT ON bug37607195.* TO 'dump_user'@'localhost';
97+
SET @saved_init_connect = @@global.init_connect;
98+
SET GLOBAL init_connect = "SET @@sql_mode='ANSI_QUOTES,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'";
99+
--exec $MYSQL_DUMP -u dump_user bug37607195 --result-file=$grep_file 2>&1
100+
SET GLOBAL init_connect = @saved_init_connect;
101+
REVOKE SELECT ON bug37607195.* FROM 'dump_user'@'localhost';
102+
REVOKE PROCESS, LOCK TABLES ON *.* FROM 'dump_user'@'localhost';
103+
DROP USER 'dump_user'@'localhost';
88104

89105
--echo # Table 1: `'order'_'items'`
90106
--echo # `qua\ntity` must be escaped

0 commit comments

Comments
 (0)