Skip to content

Commit dd63c6c

Browse files
committed
MDEV-29186 Query cache makes virtual column function RAND() non-random
1 parent 9fc124f commit dd63c6c

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#
2+
# MDEV-29186 Query cache makes virtual column function RAND() non-random
3+
#
4+
set global query_cache_type=1;
5+
set query_cache_type=1;
6+
set rand_seed1=1234567890, rand_seed2=20;
7+
create table t1 (a int, b float as (rand()));
8+
insert into t1 (a) values (1);
9+
select * from t1;
10+
a b
11+
1 0.449343
12+
select * from t1;
13+
a b
14+
1 0.797372
15+
set global query_cache_type=default;
16+
select * from t1;
17+
a b
18+
1 0.638829
19+
drop table t1;
20+
# End of 10.11 tests
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--echo #
2+
--echo # MDEV-29186 Query cache makes virtual column function RAND() non-random
3+
--echo #
4+
5+
set global query_cache_type=1;
6+
set query_cache_type=1;
7+
set rand_seed1=1234567890, rand_seed2=20;
8+
create table t1 (a int, b float as (rand()));
9+
insert into t1 (a) values (1);
10+
--disable_ps2_protocol
11+
select * from t1;
12+
select * from t1;
13+
set global query_cache_type=default;
14+
select * from t1;
15+
--enable_ps2_protocol
16+
drop table t1;
17+
18+
--echo # End of 10.11 tests

sql/item_func.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2857,6 +2857,7 @@ bool Item_func_rand::fix_fields(THD *thd,Item **ref)
28572857
if (Item_real_func::fix_fields(thd, ref))
28582858
return TRUE;
28592859
used_tables_cache|= RAND_TABLE_BIT;
2860+
thd->lex->safe_to_cache_query= 0;
28602861
if (arg_count)
28612862
{ // Only use argument once in query
28622863
/*

0 commit comments

Comments
 (0)