From 6fe624b5acf51383d39eb0e547a03779d41cf4a8 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 3 Apr 2021 12:12:15 +0200 Subject: MDEV-25242 Server crashes in check_grant upon invoking function with userstat enabled also fix index_stats table. followup for 5a798071199 --- mysql-test/r/userstat.result | 2 ++ mysql-test/t/userstat.test | 2 ++ plugin/userstat/index_stats.cc | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/userstat.result b/mysql-test/r/userstat.result index 804d5451252..8aad76c3750 100644 --- a/mysql-test/r/userstat.result +++ b/mysql-test/r/userstat.result @@ -240,6 +240,8 @@ create function f() returns int return (select 1 from performance_schema.threads set global userstat= 1; select f() from information_schema.table_statistics; ERROR 21000: Subquery returns more than 1 row +select f() from information_schema.index_statistics; +ERROR 21000: Subquery returns more than 1 row set global userstat= 0; drop function f; # diff --git a/mysql-test/t/userstat.test b/mysql-test/t/userstat.test index cc7ddd58e11..6d486810db1 100644 --- a/mysql-test/t/userstat.test +++ b/mysql-test/t/userstat.test @@ -121,6 +121,8 @@ create function f() returns int return (select 1 from performance_schema.threads set global userstat= 1; --error ER_SUBQUERY_NO_1_ROW select f() from information_schema.table_statistics; +--error ER_SUBQUERY_NO_1_ROW +select f() from information_schema.index_statistics; set global userstat= 0; drop function f; diff --git a/plugin/userstat/index_stats.cc b/plugin/userstat/index_stats.cc index 87e6da63e38..1a7b0bbfcbd 100644 --- a/plugin/userstat/index_stats.cc +++ b/plugin/userstat/index_stats.cc @@ -26,7 +26,7 @@ static int index_stats_fill(THD *thd, TABLE_LIST *tables, COND *cond) tmp_table.grant.privilege= 0; if (check_access(thd, SELECT_ACL, tmp_table.db, &tmp_table.grant.privilege, NULL, 0, 1) || - check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1)) + check_grant(thd, SELECT_ACL, &tmp_table, 1, 1, 1)) continue; index_name= strend(tmp_table.table_name)+1; -- cgit v1.2.1