Skip to content

Commit

Permalink
bugfix: RAND is VCOL_SESSION_FUNC
Browse files Browse the repository at this point in the history
it's not "non deterministic", it's completely defined
by @@rand_seed1 and @@rand_seed2. And as a session func it needs
to be re-fixed at the beginning of every statement.
  • Loading branch information
vuvova committed Jul 29, 2022
1 parent 2521992 commit 6c7e3e5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
16 changes: 16 additions & 0 deletions mysql-test/suite/vcol/r/vcol_misc.result
Original file line number Diff line number Diff line change
Expand Up @@ -533,3 +533,19 @@ drop table t1;
#
# End of 10.2 tests
#
#
# RAND is session func
#
create table t1 (a int, b float default rand(1));
insert into t1 (a) values (1);
insert into t1 (a) values (2);
insert into t1 (a) values (3);
select * from t1;
a b
1 0.405404
2 0.405404
3 0.405404
drop table t1;
#
# End of 10.3 tests
#
13 changes: 13 additions & 0 deletions mysql-test/suite/vcol/t/vcol_misc.test
Original file line number Diff line number Diff line change
Expand Up @@ -506,3 +506,16 @@ drop table t1;
--echo # End of 10.2 tests
--echo #

--echo #
--echo # RAND is session func
--echo #
create table t1 (a int, b float default rand(1));
insert into t1 (a) values (1);
insert into t1 (a) values (2);
insert into t1 (a) values (3);
select * from t1;
drop table t1;

--echo #
--echo # End of 10.3 tests
--echo #
2 changes: 1 addition & 1 deletion sql/item_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,7 @@ class Item_func_rand :public Item_real_func
void cleanup() { first_eval= TRUE; Item_real_func::cleanup(); }
bool check_vcol_func_processor(void *arg)
{
return mark_unsupported_function(func_name(), "()", arg, VCOL_NON_DETERMINISTIC);
return mark_unsupported_function(func_name(), "()", arg, VCOL_SESSION_FUNC);
}
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_rand>(thd, this); }
Expand Down

0 comments on commit 6c7e3e5

Please sign in to comment.