mariadb/mysql-test/main/kill-2.test
Sergei Golubchik e3d9369774 cleanup: disconnect before DROP USER
let's always disconnect a user connection before dropping the said user.
MariaDB is traditionally very tolerant to active connections
of the dropped user, which isn't the case for most other databases.

Let's avoid unintentionally spreading incompatible behavior
and disconnect before drop.

Except in cases when the test specifically tests such a behavior.
2025-07-16 09:14:33 +07:00

58 lines
1.5 KiB
Text

#
# Test KILL and KILL QUERY statements.
#
# Killing a connection in an embedded server does not work like in a normal
# server, if it is waiting for a new statement. In an embedded server, the
# connection does not read() from a socket, but returns control to the
# application. 'mysqltest' does not handle the kill request.
#
-- source include/not_embedded.inc
--echo #
--echo # MDEV-6896 kill user command cause MariaDB crash!
--echo #
--disable_service_connection
create user foo@'127.0.0.1';
--connect (con1,127.0.0.1,foo,,)
--connection default
select user from information_schema.processlist;
kill user foo@'127.0.0.1';
let $wait_condition=
select count(*) = 0 from information_schema.processlist
where user = "foo";
--source include/wait_condition.inc
drop user foo@'127.0.0.1';
--enable_service_connection
--echo #
--echo # KILL USER and missing privileges
--echo #
create user a@'127.0.0.1';
create user b@'127.0.0.1';
grant process on *.* to a@'127.0.0.1';
grant select on *.* to b@'127.0.0.1';
--connect a,127.0.0.1,a
show grants;
--connect b,127.0.0.1,b
--replace_column 1 # 3 # 5 # 6 # 9 #
show processlist;
kill user a; # existing connection, but not visible to current_user
kill user x; # not existing connection
--connection a
--replace_column 1 # 3 # 5 # 6 # 7 # 8 # 9 #
show processlist;
--error ER_KILL_DENIED_ERROR
kill user b;
--connection default
--disconnect a
--disconnect b
drop user a@'127.0.0.1';
drop user b@'127.0.0.1';
--echo #
--echo # End of 10.3 tests
--echo #