mariadb/mysql-test/suite/period/t/i_s_notembedded.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

121 lines
4.1 KiB
Text

--source include/not_embedded.inc
--source include/platform.inc
select * from information_schema.periods;
create or replace table t1 (id int primary key, s timestamp(6), e timestamp(6),
period for mytime(s,e));
create or replace table t2 (id int primary key, s timestamp(6), e timestamp(6),
period for mytime(s,e),
vs timestamp(6) as row start,
ve timestamp(6) as row end,
period for system_time(vs, ve))
with system versioning;
show columns from t1;
--sorted_result
select * from information_schema.periods where table_schema = 'test';
create user periods_hidden@localhost;
# Give it a privilege to connect
grant create on test.nonexist to periods_hidden@localhost;
--connect (chopped,localhost,periods_hidden,,test)
--sorted_result
select * from information_schema.periods where table_schema = 'test';
--connection default
grant select(id) on test.t1 to periods_hidden@localhost;
--connection chopped
--sorted_result
--connection default
revoke select(id) on test.t1 from periods_hidden@localhost;
--connection chopped
--sorted_result
--connection default
grant update(id) on test.t1 to periods_hidden@localhost;
--connection chopped
--sorted_result
select * from information_schema.periods where table_schema = 'test';
--connection default
grant select(s) on test.t1 to periods_hidden@localhost;
--connection chopped
--sorted_result
select * from information_schema.periods where table_schema = 'test';
--connection default
grant select(e) on test.t2 to periods_hidden@localhost;
--connection chopped
--sorted_result
select * from information_schema.periods where table_schema = 'test';
--connection default
grant update on test.t2 to periods_hidden@localhost;
--connection chopped
--sorted_result
select * from information_schema.periods where table_schema = 'test';
--connection default
drop tables t1, t2;
--echo # MDEV-32503 Queries from KEY_PERIOD_USAGE don't obey case-sensitivity
create table t (a int, b date, c date, period for app(b,c),
unique idx(a, app without overlaps));
set names latin1 collate latin1_general_cs;
select table_name from information_schema.periods where table_schema = 'TEST';
select table_name from information_schema.key_period_usage where table_schema = 'TEST';
set names latin1 collate latin1_general_ci;
select table_name from information_schema.periods where table_schema = 'TEST';
select table_name from information_schema.key_period_usage where table_schema = 'TEST';
--echo # [DUPLICATE] MDEV-32504 Search by I_S.KEY_PERIOD_USAGE.CONSTRAINT_NAME
--echo # does not work
disable_warnings; # storage engine 'Innodb' is not found
select constraint_name from information_schema.key_period_usage where table_name = 't';
select constraint_name from information_schema.key_period_usage where constraint_name = 'idx';
enable_warnings;
drop table t;
--echo # MDEV-32501 KEY_PERIOD_USAGE reveals information to unprivileged user
create table t (a int, b date, c date, f int, period for app(b, c),
primary key(a, app without overlaps));
grant select (f) on t to periods_hidden@localhost;
--connection chopped
select period_name from information_schema.key_period_usage where table_name = 't';
--connection default
grant update (f) on t to periods_hidden@localhost;
--connection chopped
select 'can be seen', constraint_name, period_name from information_schema.key_period_usage where table_name = 't';
--connection default
revoke update (f) on t from periods_hidden@localhost;
--connection chopped
--error ER_TABLEACCESS_DENIED_ERROR
update t set f = 1;
select period_name from information_schema.key_period_usage where table_name = 't';
--connection default
grant alter on t to periods_hidden@localhost;
--connection chopped
select 'can be seen', constraint_name, period_name from information_schema.key_period_usage where table_name = 't';
--connection default
drop table t;
#
# End of 11.4 tests
#
# Global cleanup
--disconnect chopped
--connection default
--disable_warnings
drop user periods_hidden@localhost;
--enable_warnings