mariadb/mysql-test/main/nested_profiling.test
Dmitry Shulga eeb00ceffd MDEV-35617: DROP USER should leave no active session for that user
Follow-up patch with adjustments of test files and updates of result
files for tests.

Some of tests were rewritten slighlty. Everywhere where common
pattern used:
-----
  CREATE USER userA;
  --connect con1 ... userA ...
   <sql statements...>
  --disconnect con1
  DROP USER userA;
-----
the DROP USER statement has been eclosed into the directive
--disable_warnings
--enable_warnings

This change is caused by the race conddition between --disconnect
and DROP USER since a number of currently running sessions
established on behalf the user being dropped is counted by
holding the rw_lock THD_list_iterator::lock that is not acquired on
execution the DROP USER statement but the lock is taken as the last
step on handling disconnection (when the client is already sending
the next statement). Therefore, for the cases where the command
 --disconnect precedes the DROP USER statement
we hide the possible warnings about presence of active sessions
for the user being deleted to make tests deterministic.
2025-06-09 18:24:28 +07:00

46 lines
1.3 KiB
Text

# ==== Purpose ====
#
# Test verifies that "init_connect" and "init_slave" system variables work
# fine when "profiling=on".
#
# ==== Implementation ====
#
# Steps:
# 0 - Create regular user without super privilege so that "init_connect"
# variable is effective.
# 1 - Enable profiling.
# 2 - Start a new connection which will try to execute the statements
# specified in "init_connect". No assert should be reported.
# 3 - Execute SHOW PROFILES to verify that statements specified in
# "init_connect" are displayed as part of profiling.
#
# ==== References ====
#
# MDEV-22706: Assertion `!current' failed in PROFILING::start_new_query
#
--source include/not_embedded.inc
--source include/have_profiling.inc
SET @saved_profiling=@@GLOBAL.profiling;
SET @saved_init_connect=@@GLOBAL.init_connect;
SET GLOBAL init_connect="set @a=2;set @b=3";
SET GLOBAL profiling=on;
create user mysqltest1@localhost;
connect (con1,localhost,mysqltest1,,);
connection con1;
--disable_ps2_protocol
SELECT @a, @b;
--enable_ps2_protocol
--replace_column 2 #
SHOW PROFILES;
#========== Clean up ===========
connection default;
disconnect con1;
--disable_warnings
DROP USER mysqltest1@localhost;
--enable_warnings
SET GLOBAL profiling=@saved_profiling;
SET GLOBAL init_connect=@saved_init_connect;