1
0
mirror of https://github.com/MariaDB/server.git synced 2025-09-11 05:52:26 +03:00

MDEV-25242 Server crashes in check_grant upon invoking function with userstat enabled

use check_grant(..., number_of_tables=1, ...) if you only need
to check privileges for one table
This commit is contained in:
Sergei Golubchik
2021-03-24 23:12:16 +01:00
parent cdb86faf82
commit 5a79807119
3 changed files with 27 additions and 8 deletions

View File

@@ -1,4 +1,3 @@
DROP TABLE IF EXISTS t1;
select variable_value from information_schema.global_status where variable_name="handler_read_key" into @global_read_key;
show columns from information_schema.client_statistics;
Field Type Null Key Default Extra
@@ -234,3 +233,15 @@ select @@in_transaction;
0
drop table t1;
set @@global.general_log=@save_general_log;
#
# MDEV-25242 Server crashes in check_grant upon invoking function with userstat enabled
#
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
set global userstat= 0;
drop function f;
#
# End of 10.2 tests
#

View File

@@ -6,10 +6,6 @@
-- source include/have_innodb.inc
-- source include/have_log_bin.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
select variable_value from information_schema.global_status where variable_name="handler_read_key" into @global_read_key;
show columns from information_schema.client_statistics;
show columns from information_schema.user_statistics;
@@ -115,5 +111,18 @@ set @@autocommit=1;
select @@in_transaction;
drop table t1;
# Cleanup
set @@global.general_log=@save_general_log;
--echo #
--echo # MDEV-25242 Server crashes in check_grant upon invoking function with userstat enabled
--echo #
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;
set global userstat= 0;
drop function f;
--echo #
--echo # End of 10.2 tests
--echo #

View File

@@ -31,8 +31,7 @@ static int table_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;
table->field[0]->store(table_stats->table, schema_length,