diff options
-rw-r--r-- | mysql-test/main/query_cache.result | 25 | ||||
-rw-r--r-- | mysql-test/main/query_cache.test | 32 | ||||
-rw-r--r-- | sql/item_create.cc | 1 |
3 files changed, 58 insertions, 0 deletions
diff --git a/mysql-test/main/query_cache.result b/mysql-test/main/query_cache.result index 3a81b648171..f78a6ccc388 100644 --- a/mysql-test/main/query_cache.result +++ b/mysql-test/main/query_cache.result @@ -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 +# diff --git a/mysql-test/main/query_cache.test b/mysql-test/main/query_cache.test index f8152945396..9baecbf90f6 100644 --- a/mysql-test/main/query_cache.test +++ b/mysql-test/main/query_cache.test @@ -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 # diff --git a/sql/item_create.cc b/sql/item_create.cc index bceff7fb43c..6deb2e9f400 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -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); } |