Commit a95268c5 authored by Daniel Black's avatar Daniel Black Committed by Sergei Golubchik

MDEV-29028 Queries using RANDOM_BYTES get stored in query cache

Mark the RANDOM_BYTES function as uncacheable.
parent 8b9ac5bf
......@@ -2239,3 +2239,28 @@ DROP TABLE t;
restore defaults
SET GLOBAL query_cache_type= default;
SET GLOBAL query_cache_size=@save_query_cache_size;
#
# MDEV-29028: Queries using RANDOM_BYTES get stored in query cache
#
set @qcache= @@global.query_cache_type;
set global query_cache_type= 1;
set query_cache_type= 1;
create table t1 (a int);
insert into t1 values (1000);
flush status;
select * from information_schema.global_status where variable_name in ('Qcache_inserts','Qcache_hits') order by variable_name;
VARIABLE_NAME VARIABLE_VALUE
QCACHE_HITS 0
QCACHE_INSERTS 0
select * from information_schema.global_status where variable_name in ('Qcache_inserts','Qcache_hits') order by variable_name;
VARIABLE_NAME VARIABLE_VALUE
QCACHE_HITS 0
QCACHE_INSERTS 0
select random_bytes(1024) = random_bytes(1024) as improbable;
improbable
0
drop table t1;
set global query_cache_type= @qcache;
#
# End of 10.10 tests
#
......@@ -1834,3 +1834,35 @@ DROP TABLE t;
--echo restore defaults
SET GLOBAL query_cache_type= default;
SET GLOBAL query_cache_size=@save_query_cache_size;
--echo #
--echo # MDEV-29028: Queries using RANDOM_BYTES get stored in query cache
--echo #
set @qcache= @@global.query_cache_type;
set global query_cache_type= 1;
set query_cache_type= 1;
create table t1 (a int);
insert into t1 values (1000);
flush status;
--let $v1 = `select hex(random_bytes(a)) from t1`
select * from information_schema.global_status where variable_name in ('Qcache_inserts','Qcache_hits') order by variable_name;
--let $v2 = `select hex(random_bytes(a)) from t1`
select * from information_schema.global_status where variable_name in ('Qcache_inserts','Qcache_hits') order by variable_name;
if ($v1 == $v2) {
--echo highly improbable $v1 = $v2
}
select random_bytes(1024) = random_bytes(1024) as improbable;
# Cleanup
drop table t1;
set global query_cache_type= @qcache;
--echo #
--echo # End of 10.10 tests
--echo #
......@@ -5003,6 +5003,7 @@ Create_func_random_bytes Create_func_random_bytes::s_singleton;
Item *Create_func_random_bytes::create_1_arg(THD *thd, Item *arg1)
{
thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
thd->lex->uncacheable(UNCACHEABLE_RAND);
return new (thd->mem_root) Item_func_random_bytes(thd, arg1);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment