Skip to content

Commit 0e322b6

Browse files
committed
MDEV-37797 - main.information_schema_db fails sporadically
MDEV-20549 test output was affected by incompletely closed preceding connections. Fix for similar issue was attempted by f4eb095, it introduced wait_until_disconnected.inc. For an explanation of why it didn't work see bead24b commit comment. Another fix was attempted in bead24b. It didn't help either, because connection is removed from information_schema.processlist after COM_QUIT handling. Make test for MDEV-20549 agnostic to concurrent connections by querying information_schema.processlist only for connections that it uses.
1 parent ab8b424 commit 0e322b6

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

mysql-test/main/information_schema_db.result

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,8 @@ connection default;
215215
use test;
216216
drop view testdb_1.v1, v2, testdb_1.v3, v4;
217217
drop database testdb_1;
218-
connection testdb_1;
219218
disconnect testdb_1;
220-
connection testdb_2;
221219
disconnect testdb_2;
222-
connection default;
223220
drop user testdb_1@localhost;
224221
drop user testdb_2@localhost;
225222
#
@@ -251,18 +248,18 @@ ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table `
251248
connection default;
252249
drop user mysqltest_1@localhost;
253250
drop database testdb_1;
254-
connection user1;
255251
disconnect user1;
256-
connection default;
257252
set global sql_mode=default;
258253
#
259254
# MDEV-20549 SQL SECURITY DEFINER does not work for INFORMATION_SCHEMA tables
260255
#
261256
create user foo@localhost;
262257
grant select on test.* to foo@localhost;
258+
connect foo,localhost,foo;
259+
connection default;
263260
create procedure rootonly() select 1;
264-
create sql security definer view v1d as select current_user(),user from information_schema.processlist where command!='daemon';
265-
create sql security invoker view v1i as select current_user(),user from information_schema.processlist where command!='daemon';
261+
create sql security definer view v1d as select current_user(),user from information_schema.processlist where id in($default_id, $foo_id) order by user;
262+
create sql security invoker view v1i as select current_user(),user from information_schema.processlist where id in($default_id, $foo_id) order by user;
266263
create sql security definer view v2d as select table_name from information_schema.tables where table_schema='mysql' and table_name like '%user%';
267264
create sql security invoker view v2i as select table_name from information_schema.tables where table_schema='mysql' and table_name like '%user%';
268265
create sql security definer view v3d as select schema_name from information_schema.schemata where schema_name like '%mysql%';
@@ -271,7 +268,7 @@ create sql security definer view v4d as select routine_name from information_sch
271268
create sql security invoker view v4i as select routine_name from information_schema.routines where routine_schema='test';
272269
create sql security definer view v5d as select view_definition > '' from information_schema.views where table_name='v1d';
273270
create sql security invoker view v5i as select view_definition > '' from information_schema.views where table_name='v1d';
274-
connect foo,localhost,foo;
271+
connection foo;
275272
select * from v1d;
276273
current_user() user
277274
root@localhost root

mysql-test/main/information_schema_db.test

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,8 @@ connection default;
206206
use test;
207207
drop view testdb_1.v1, v2, testdb_1.v3, v4;
208208
drop database testdb_1;
209-
connection testdb_1;
210209
disconnect testdb_1;
211-
--source include/wait_until_disconnected.inc
212-
connection testdb_2;
213210
disconnect testdb_2;
214-
--source include/wait_until_disconnected.inc
215-
connection default;
216211
drop user testdb_1@localhost;
217212
drop user testdb_2@localhost;
218213

@@ -243,10 +238,7 @@ show create view testdb_1.v1;
243238
connection default;
244239
drop user mysqltest_1@localhost;
245240
drop database testdb_1;
246-
connection user1;
247241
disconnect user1;
248-
--source include/wait_until_disconnected.inc
249-
connection default;
250242

251243
set global sql_mode=default;
252244

@@ -256,9 +248,13 @@ set global sql_mode=default;
256248

257249
create user foo@localhost;
258250
grant select on test.* to foo@localhost;
251+
let $default_id= `select connection_id()`;
252+
connect foo,localhost,foo;
253+
let $foo_id= `select connection_id()`;
254+
connection default;
259255
create procedure rootonly() select 1;
260-
create sql security definer view v1d as select current_user(),user from information_schema.processlist where command!='daemon';
261-
create sql security invoker view v1i as select current_user(),user from information_schema.processlist where command!='daemon';
256+
evalp create sql security definer view v1d as select current_user(),user from information_schema.processlist where id in($default_id, $foo_id) order by user;
257+
evalp create sql security invoker view v1i as select current_user(),user from information_schema.processlist where id in($default_id, $foo_id) order by user;
262258
create sql security definer view v2d as select table_name from information_schema.tables where table_schema='mysql' and table_name like '%user%';
263259
create sql security invoker view v2i as select table_name from information_schema.tables where table_schema='mysql' and table_name like '%user%';
264260
create sql security definer view v3d as select schema_name from information_schema.schemata where schema_name like '%mysql%';
@@ -267,7 +263,7 @@ create sql security definer view v4d as select routine_name from information_sch
267263
create sql security invoker view v4i as select routine_name from information_schema.routines where routine_schema='test';
268264
create sql security definer view v5d as select view_definition > '' from information_schema.views where table_name='v1d';
269265
create sql security invoker view v5i as select view_definition > '' from information_schema.views where table_name='v1d';
270-
connect foo,localhost,foo;
266+
connection foo;
271267
select * from v1d;
272268
select * from v1i;
273269
select * from v2d;

0 commit comments

Comments
 (0)