mirror of
https://github.com/MariaDB/server.git
synced 2025-08-29 00:08:14 +03:00
Major replication test framework cleanup. This does the following: - Ensure that all tests clean up the replication state when they finish, by making check-testcase check the output of SHOW SLAVE STATUS. This implies: - Slave must not be running after test finished. This is good because it removes the risk for sporadic errors in subsequent tests when a test forgets to sync correctly. - Slave SQL and IO errors must be cleared when test ends. This is good because we will notice if a test gets an unexpected error in the slave threads near the end. - We no longer have to clean up before a test starts. - Ensure that all tests that wait for an error in one of the slave threads waits for a specific error. It is no longer possible to source wait_for_slave_[sql|io]_to_stop.inc when there is an error in one of the slave threads. This is good because: - If a test expects an error but there is a bug that causes another error to happen, or if it stops the slave thread without an error, then we will notice. - When developing tests, wait_for_*_to_[start|stop].inc will fail immediately if there is an error in the relevant slave thread. Before this patch, we had to wait for the timeout. - Remove duplicated and repeated code for setting up unusual replication topologies. Now, there is a single file that is capable of setting up arbitrary topologies (include/rpl_init.inc, but include/master-slave.inc is still available for the most common topology). Tests can now end with include/rpl_end.inc, which will clean up correctly no matter what topology is used. The topology can be changed with include/rpl_change_topology.inc. - Improved debug information when tests fail. This includes: - debug info is printed on all servers configured by include/rpl_init.inc - User can set $rpl_debug=1, which makes auxiliary replication files print relevant debug info. - Improved documentation for all auxiliary replication files. Now they describe purpose, usage, parameters, and side effects. - Many small code cleanups: - Made have_innodb.inc output a sensible error message. - Moved contents of rpl000017-slave.sh into rpl000017.test - Added mysqltest variables that expose the current state of disable_warnings/enable_warnings and friends. - Too many to list here: see per-file comments for details.
188 lines
5.7 KiB
Plaintext
188 lines
5.7 KiB
Plaintext
include/rpl_init.inc [topology=1->2->3]
|
|
include/rpl_connect.inc [creating master]
|
|
include/rpl_connect.inc [creating slave]
|
|
CREATE TABLE t1(c1 char(100));
|
|
CREATE VIEW test.v_user AS SELECT * FROM mysql.user WHERE User LIKE 'bug48321%';
|
|
CREATE VIEW test.v_tables_priv AS SELECT * FROM mysql.tables_priv WHERE User LIKE 'bug48321%';
|
|
CREATE VIEW test.v_procs_priv AS SELECT * FROM mysql.procs_priv WHERE User LIKE 'bug48321%';
|
|
CREATE VIEW test.v_event AS SELECT definer FROM mysql.event WHERE name = 'e1';
|
|
CREATE PROCEDURE p1() SELECT 1;
|
|
# bug48321_1-01234 has the max length(16) of user.
|
|
GRANT ALL PRIVILEGES ON *.* TO 'bug48321_1-01234'@'localhost' WITH GRANT OPTION;
|
|
|
|
# Make sure the max lengths of user and host
|
|
# the user name is too lengh
|
|
GRANT CREATE USER ON *.* TO '01234567890123456'@'fakehost';
|
|
ERROR HY000: String '01234567890123456' is too long for user name (should be no longer than 16)
|
|
# the host name is too lengh
|
|
GRANT CREATE USER ON *.* TO 'fakename'@'0123456789012345678901234567890123456789012345678901234567890';
|
|
ERROR HY000: String '0123456789012345678901234567890123456789012345678901234567890' is too long for host name (should be no longer than 60)
|
|
|
|
# User 'bug48321_1-01234' connects to master by conn1
|
|
# [On conn1]
|
|
# Verify 'REVOKE ALL' statement
|
|
REVOKE ALL PRIVILEGES, GRANT OPTION FROM CURRENT_USER();
|
|
include/rpl_sync.inc
|
|
include/diff_tables.inc [server_1:v_user, server_2:v_user, server_3:v_user]
|
|
|
|
# Verify 'GRANT ... ON TABLE ...' statement
|
|
GRANT CREATE, INSERT, SELECT ON TABLE test.t1 TO CURRENT_USER();
|
|
include/rpl_sync.inc
|
|
include/diff_tables.inc [server_1:v_tables_priv, server_2:v_tables_priv, server_3:v_tables_priv]
|
|
|
|
# Verify 'GRANT ... ON PROCEDURE...' statement
|
|
GRANT ALTER ROUTINE, EXECUTE ON PROCEDURE p1 TO CURRENT_USER();
|
|
include/rpl_sync.inc
|
|
include/diff_tables.inc [server_1:v_procs_priv, server_2:v_procs_priv, server_3:v_procs_priv]
|
|
|
|
# Verify 'GRANT ... ON *.* ...' statement
|
|
GRANT ALL PRIVILEGES ON *.* TO CURRENT_USER() WITH GRANT OPTION;
|
|
include/rpl_sync.inc
|
|
include/diff_tables.inc [server_1:v_procs_priv, server_2:v_procs_priv, server_3:v_procs_priv]
|
|
|
|
# Verify 'REVOKE ... ON TABLE ...' statement
|
|
REVOKE CREATE, INSERT, SELECT ON TABLE t1 FROM CURRENT_USER();
|
|
include/rpl_sync.inc
|
|
include/diff_tables.inc [server_1:v_tables_priv, server_2:v_tables_priv, server_3:v_tables_priv]
|
|
|
|
# Verify 'REVOKE ... ON PROCEDURE...' statement
|
|
REVOKE ALTER ROUTINE, EXECUTE ON PROCEDURE p1 FROM CURRENT_USER();
|
|
include/rpl_sync.inc
|
|
include/diff_tables.inc [server_1:v_procs_priv, server_2:v_procs_priv, server_3:v_procs_priv]
|
|
|
|
# Verify 'REVOKE ... ON *.* ...' statement
|
|
REVOKE ALL PRIVILEGES ON *.* FROM CURRENT_USER();
|
|
include/rpl_sync.inc
|
|
include/diff_tables.inc [server_1:v_user, server_2:v_user, server_3:v_user]
|
|
|
|
# Verify 'GRANT ...' statement in the procedure
|
|
CREATE PROCEDURE my_grant()
|
|
GRANT CREATE, INSERT, SELECT ON TABLE test.t1 TO CURRENT_USER();
|
|
call my_grant;
|
|
include/rpl_sync.inc
|
|
include/diff_tables.inc [server_1:v_tables_priv, server_2:v_tables_priv, server_3:v_tables_priv]
|
|
|
|
# Verify 'REVOKE ... ON TABLE ...' statement in the procedure
|
|
CREATE PROCEDURE my_revoke()
|
|
REVOKE CREATE, INSERT, SELECT ON TABLE t1 FROM CURRENT_USER();
|
|
call my_revoke;
|
|
include/rpl_sync.inc
|
|
include/diff_tables.inc [server_1:v_tables_priv, server_2:v_tables_priv, server_3:v_tables_priv]
|
|
|
|
# Verify 'RENAME USER ...' statement
|
|
RENAME USER CURRENT_USER TO 'bug48321_2'@'localhost';
|
|
include/rpl_sync.inc
|
|
include/diff_tables.inc [server_1:v_user, server_2:v_user, server_3:v_user]
|
|
|
|
# Verify 'DROP USER ...' statement
|
|
GRANT CREATE USER ON *.* TO 'bug48321_2'@'localhost';
|
|
DROP USER CURRENT_USER();
|
|
include/rpl_sync.inc
|
|
include/diff_tables.inc [server_1:v_user, server_2:v_user, server_3:v_user]
|
|
|
|
# Verify 'ALTER EVENT...' statement
|
|
CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT * FROM t1;
|
|
# Explicitly assign CURRENT_USER() to definer
|
|
ALTER DEFINER=CURRENT_USER() EVENT e1 ENABLE;
|
|
include/rpl_sync.inc
|
|
include/diff_tables.inc [server_1:v_event, server_2:v_event, server_3:v_event]
|
|
|
|
# Session user will be set as definer, if the statement does not assign
|
|
# a definer
|
|
ALTER EVENT e1 ENABLE;
|
|
include/rpl_sync.inc
|
|
include/diff_tables.inc [server_1:v_event, server_2:v_event, server_3:v_event]
|
|
|
|
# Verify that this patch does not affect the calling of CURRENT_USER()
|
|
# in the other statements
|
|
# [On master]
|
|
INSERT INTO t1 VALUES(CURRENT_USER()), ('1234');
|
|
Warnings:
|
|
Note 1592 Statement may not be safe to log in statement format.
|
|
SELECT * FROM t1;
|
|
c1
|
|
root@localhost
|
|
1234
|
|
# [On slave]
|
|
SELECT * FROM t1;
|
|
c1
|
|
@
|
|
1234
|
|
# [On server_3]
|
|
SELECT * FROM t1;
|
|
c1
|
|
@
|
|
1234
|
|
# [On master]
|
|
UPDATE t1 SET c1=CURRENT_USER() WHERE c1='1234';
|
|
Warnings:
|
|
Note 1592 Statement may not be safe to log in statement format.
|
|
SELECT * FROM t1;
|
|
c1
|
|
root@localhost
|
|
root@localhost
|
|
# [On slave]
|
|
SELECT * FROM t1;
|
|
c1
|
|
@
|
|
@
|
|
# [On server_3]
|
|
SELECT * FROM t1;
|
|
c1
|
|
@
|
|
@
|
|
# [On master]
|
|
DELETE FROM t1 WHERE c1=CURRENT_USER();
|
|
Warnings:
|
|
Note 1592 Statement may not be safe to log in statement format.
|
|
SELECT * FROM t1;
|
|
c1
|
|
# [On slave]
|
|
SELECT * FROM t1;
|
|
c1
|
|
# [On server_3]
|
|
SELECT * FROM t1;
|
|
c1
|
|
# [On master]
|
|
CREATE TABLE t2(c1 char(100));
|
|
CREATE FUNCTION my_user() RETURNS VARCHAR(64)
|
|
SQL SECURITY INVOKER
|
|
BEGIN
|
|
INSERT INTO t2 VALUES(CURRENT_USER());
|
|
RETURN CURRENT_USER();
|
|
END |
|
|
INSERT INTO t1 VALUES(my_user());
|
|
Warnings:
|
|
Note 1592 Statement may not be safe to log in statement format.
|
|
Note 1592 Statement may not be safe to log in statement format.
|
|
SELECT * FROM t1;
|
|
c1
|
|
root@localhost
|
|
SELECT * FROM t2;
|
|
c1
|
|
root@localhost
|
|
# [On slave]
|
|
SELECT * FROM t1;
|
|
c1
|
|
@
|
|
SELECT * FROM t2;
|
|
c1
|
|
@
|
|
# [On server_3]
|
|
SELECT * FROM t1;
|
|
c1
|
|
@
|
|
SELECT * FROM t2;
|
|
c1
|
|
@
|
|
|
|
# END
|
|
DROP TABLE t1, t2;
|
|
DROP VIEW v_user, v_tables_priv, v_procs_priv, v_event;
|
|
DROP PROCEDURE p1;
|
|
DROP PROCEDURE my_grant;
|
|
DROP PROCEDURE my_revoke;
|
|
DROP FUNCTION my_user;
|
|
DROP EVENT e1;
|
|
include/rpl_end.inc
|