Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/MariaDB/mysql-test/main/   (MariaDB Server Version 8.1-8.4©)  Datei vom 1.9.2026 mit Größe 4 kB image not shown  

Quelle  kill-2.test  Sprache: unbekannt

 
Spracherkennung für: .test vermutete Sprache: SQL {SQL[108] VDM[72] VHDL[72]} [Methode: maximale Elemente, drei Dimensionen]

#
# 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
--source include/count_sessions.inc
--source include/check_ipv6.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,,)
let $con1_id= `select connection_id()`;

--connection default
evalp select user from information_schema.processlist where id=$con1_id;
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 #
let $default_id= `select connection_id()`;
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
let $b_id= `select connection_id()`;
--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
evalp select user from information_schema.processlist where id in (connection_id(), $b_id, $default_id) order by user;
--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 # End of 10.3 tests

--echo #
--echo # MDEV-40554 KILL checks user (not priv_user) and doesn't verify hostname
--echo #

create user u1@'::1' identified by 'pw1';
create user ''@'127.0.0.1';

connect u1_ipv6,::1,u1,pw1;
select current_user();
let $cid_sock=`select connection_id()`;

--echo # the reported case: same login name, but an anonymous account
connect u1_anon,127.0.0.1,u1,;
select user(), current_user();

--echo # anonymous users don't see the process list at all
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
show processlist;
select count(*) as `threads visible` from information_schema.processlist;
evalp select count(*) as `u1@'::1' visible`
     from information_schema.processlist where id=$cid_sock;
--replace_regex /thread [0-9]+/thread CID/
--error ER_KILL_DENIED_ERROR
evalp kill $cid_sock;
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
evalp show explain for $cid_sock;

# killing a non-matching user doesn't report an error to not disclose
# that the user exists. but doesn't kill either
kill user u1@'::1';
connection u1_ipv6;
select user(), current_user();
connection u1_anon;

connection default;
disconnect u1_anon;
drop user ''@'127.0.0.1';

--echo # same login name, a real account, but a different host
create user u1@'127.0.0.1' identified by 'pw2';
connect u1_ipv4,127.0.0.1,u1,pw2;
select current_user();
let $cid_tcp=`select connection_id()`;

--echo # u1@127.0.0.1 must not see u1@'::1' - same user name, other account
--replace_result Execute Query
--replace_column 1 # 3 # 4 # 6 # 7 # 8 # 9 #
show processlist;
evalp select count(*) as `u1@'::1' visible`
     from information_schema.processlist where id=$cid_sock;
--replace_regex /thread [0-9]+/thread CID/
--error ER_KILL_DENIED_ERROR
evalp kill $cid_sock;
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
evalp show explain for $cid_sock;

# doesn't report an error, doesn't kill
kill user u1@'::1';
connection u1_ipv6;
select user(), current_user();
connection u1_ipv4;

--echo # but another u1@127.0.0.1 connection is the same account, so it may
connect u1_tcp2,127.0.0.1,u1,pw2;
evalp select count(*) as `u1@127.0.0.1 visible`
     from information_schema.processlist where id=$cid_tcp;
evalp kill $cid_tcp;

--echo # u1@'::1' was not killed
connection u1_ipv6;
select 1;

connection default;
disconnect u1_ipv6;
#u1_ipv4 was killed, must not be disconnected
disconnect u1_tcp2;
--source include/wait_until_count_sessions.inc

drop user u1@'::1';
drop user u1@'127.0.0.1';

--echo # End of 10.11 tests

[Dauer der Verarbeitung: 0.20 Sekunden, vorverarbeitet 2026-10-08]