1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
# ==== Purpose ====
#
# This test checks we can set GTID_PURGED from inside a SP even when
# is executed by a user with only privileges for execution.
#
# ==== Implementation ====
#
# 0. This test starts with 2 servers in a source->replica setup
# 1. We create a table on server 1 for check purposes and extract its id
# 2. On the replica create a storage procedure that uses the `root` user
# security context to SET GTID_PURGED
# 3. Create a user with only EXECUTE privileges.
# Make a connection with this user
# 4. Use the procedure to set GTID_PURGED.
# Check the value was set
# 5. Check replication is working as expected
# 6. Cleanup
#
# ==== References ====
#
# Bug#31571427 SET GTID_PURGED SHOULD BE EXECUTABLE FROM STORED ROUTINES
#
--source include/have_binlog_format_row.inc
--let $rpl_gtid_utils= 1
--source include/master-slave.inc
--echo #
--echo # 1. We create a table on server 1 for check purposes and extract its id
--source include/rpl_connection_master.inc
--let $source_uuid= `SELECT @@GLOBAL.SERVER_UUID`
CREATE TABLE t1 (a INT PRIMARY KEY);
--source include/sync_slave_sql_with_master.inc
--echo #
--echo # 2. On the replica create a storage procedure that uses the `root` user
--echo # security context to SET GTID_PURGED
DROP PROCEDURE IF EXISTS set_gtid_purged_sp;
DELIMITER |;
CREATE DEFINER = 'root'@'localhost' PROCEDURE set_gtid_purged_sp (IN gtid TEXT)
SQL SECURITY DEFINER
DETERMINISTIC
BEGIN
SET GLOBAL gtid_purged = gtid;
END|
DELIMITER ;|
--echo #
--echo # 3. Create a user with only EXECUTE privileges.
--echo # Make a connection with this user
CREATE USER 'no_priv_user'@localhost IDENTIFIED BY '';
GRANT EXECUTE ON test.* TO 'no_priv_user'@localhost;
--connect (no_priv_user_con, 127.0.0.1, no_priv_user, , test, $SLAVE_MYPORT,)
--let $rpl_connection_name= no_priv_user_con
--source include/rpl_connection.inc
--echo #
--echo # 4. Use the procedure to set GTID_PURGED.
--echo # Check the value was set
--replace_result $source_uuid SOURCE_UUID
--eval CALL set_gtid_purged_sp("$source_uuid:2");
--let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_PURGED, "$source_uuid:2")
--let $assert_text= @@GLOBAL.GTID_PURGED has changed
--source include/assert.inc
--echo #
--echo # 5. Check replication is working as expected
--source include/rpl_connection_master.inc
INSERT INTO t1 values (2);
INSERT INTO t1 values (3);
--source include/sync_slave_sql_with_master.inc
--let $assert_text= Only one transaction was replicated
--let $assert_cond = COUNT(*)=1 FROM t1
--source include/assert.inc
--echo #
--echo # 6. Cleanup
--source include/rpl_connection_master.inc
DROP TABLE t1;
--source include/rpl_connection_slave.inc
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'no_priv_user'@localhost;
DROP USER 'no_priv_user'@localhost;
DROP PROCEDURE set_gtid_purged_sp;
--source include/rpl_end.inc
|