mariadb/mysql-test/main/grant_kill.test
Sergey Vojtovich 911e68c16b MDEV-38008 - main.grant_kill fails sporadically
Test output was affected by incompletely closed preceding connections.

Make test agnostic to concurrent connections by querying
information_schema.processlist only for connections that it uses.

With bead24b7f3 all 3 processlist queries were affected.
Before bead24b7f3 - only the first one.
2025-11-07 01:05:40 +04:00

86 lines
2.2 KiB
Text

-- source include/not_embedded.inc
--echo #
--echo # Start of 10.5 tests
--echo #
--echo #
--echo # MDEV-21743 Split up SUPER privilege to smaller privileges
--echo #
--disable_service_connection
--echo #
--echo # Test that KILL is not allowed without CONNECTION ADMIN or SUPER
--echo #
CREATE USER foo@localhost;
GRANT SELECT ON *.* TO foo@localhost;
CREATE USER bar@localhost;
GRANT ALL PRIVILEGES ON *.* TO bar@localhost;
REVOKE CONNECTION ADMIN, SUPER ON *.* FROM bar@localhost;
--connect (foo,localhost,foo,,)
let $id=`select connection_id()`;
--connect (bar,localhost,bar,,)
evalp SELECT user FROM information_schema.processlist WHERE id=$id;
--replace_result $id ID
--error ER_KILL_DENIED_ERROR
--eval KILL $id
--disconnect foo
--disconnect bar
--connection default
DROP USER foo@localhost;
DROP USER bar@localhost;
--echo #
--echo # Test that KILL is allowed with CONNECTION ADMIN
--echo #
CREATE USER foo@localhost;
GRANT SELECT ON *.* TO foo@localhost;
CREATE USER bar@localhost;
GRANT PROCESS, CONNECTION ADMIN ON *.* TO bar@localhost;
--connect (foo,localhost,foo,,)
let $id=`select connection_id()`;
--connect (bar,localhost,bar,,)
evalp SELECT user FROM information_schema.processlist WHERE id=$id;
--replace_result $id ID
--eval KILL $id
--connection default
let $wait_condition=
select count(*) = 0 from information_schema.processlist
where user = "foo";
--source include/wait_condition.inc
--disconnect foo
--disconnect bar
DROP USER foo@localhost;
DROP USER bar@localhost;
--echo #
--echo # Test that KILL is allowed with SUPER
--echo #
CREATE USER foo@localhost;
GRANT SELECT ON *.* TO foo@localhost;
CREATE USER bar@localhost;
GRANT PROCESS, SUPER ON *.* TO bar@localhost;
--connect (foo,localhost,foo,,)
let $id=`select connection_id()`;
--connect (bar,localhost,bar,,)
evalp SELECT user FROM information_schema.processlist WHERE id=$id;
--replace_result $id ID
--eval KILL $id
--connection default
let $wait_condition=
select count(*) = 0 from information_schema.processlist
where user = "foo";
--source include/wait_condition.inc
--disconnect foo
--disconnect bar
DROP USER foo@localhost;
DROP USER bar@localhost;
--enable_service_connection
--echo #
--echo # End of 10.5 tests
--echo #