mariadb/mysql-test/suite/roles/set_role-9614.result
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

100 lines
2.4 KiB
Text

#
# MDEV-9614 Roles and Users Longer than 6 characters
#
# This test case checks the edge case presented in the MDEV. The
# real issue is actually apparent when the username is longer than the
# rolename.
#
# We need a separate database not including test or test_% names. Due to
# default privileges given on these databases.
#
DROP DATABASE IF EXISTS `bug_db`;
Warnings:
Note 1008 Can't drop database 'bug_db'; database doesn't exist
#
# The first user did not show the bug as john's length is smaller
# than client. The bug is apparent most of the time for usertestjohn.
#
CREATE USER `john`@`%`;
CREATE USER `usertestjohn`@`%`;
CREATE ROLE `client`;
#
# Setup the required tables.
#
CREATE DATABASE `bug_db`;
CREATE TABLE `bug_db`.`t0`(`c0` INT);
#
# Setup select privileges only on the role. Setting the role should give
# select access to bug_db.t0.
#
GRANT SELECT ON `bug_db`.`t0` TO `client`;
GRANT `client` TO `john`@`%`;
GRANT `client` TO `usertestjohn`@`%`;
#
# Check to see grants are set.
#
SHOW GRANTS FOR `john`@`%`;
Grants for john@%
GRANT `client` TO `john`@`%`
GRANT USAGE ON *.* TO `john`@`%`
SHOW GRANTS FOR `usertestjohn`@`%`;
Grants for usertestjohn@%
GRANT `client` TO `usertestjohn`@`%`
GRANT USAGE ON *.* TO `usertestjohn`@`%`
SHOW GRANTS FOR `client`;
Grants for client
GRANT USAGE ON *.* TO `client`
GRANT SELECT ON `bug_db`.`t0` TO `client`
show databases;
Database
bug_db
information_schema
mtr
mysql
performance_schema
sys
test
#
# Try using the database as john.
#
connect john, localhost, john,,information_schema;
show databases;
Database
information_schema
set role client;
show databases;
Database
bug_db
information_schema
use bug_db;
#
# Try using the database as usertestjohn.
#
connect usertestjohn, localhost, usertestjohn,,information_schema;
show databases;
Database
information_schema
set role client;
show databases;
Database
bug_db
information_schema
show grants;
Grants for usertestjohn@%
GRANT `client` TO `usertestjohn`@`%`
GRANT USAGE ON *.* TO `usertestjohn`@`%`
GRANT USAGE ON *.* TO `client`
GRANT SELECT ON `bug_db`.`t0` TO `client`
use bug_db;
#
# Cleanup
#
connection default;
drop user john;
Warnings:
Note 4226 Dropped users ['john'@'%'] have active connections. Use KILL CONNECTION if they should not be used anymore.
drop user usertestjohn;
Warnings:
Note 4226 Dropped users ['usertestjohn'@'%'] have active connections. Use KILL CONNECTION if they should not be used anymore.
drop role client;
drop database bug_db;