MDEV-29029 RANDOM_BYTES cannot be virtual column

This commit is contained in:
Daniel Black 2022-07-05 17:37:26 +10:00 committed by Sergei Golubchik
parent 3c2b0cac52
commit 8b9ac5bfe0
4 changed files with 44 additions and 0 deletions

View file

@ -247,3 +247,18 @@ create table t1 (a int);
alter table t1 add column r blob generated always
as (match(a) against ('' in boolean mode)) virtual;
drop table t1;
--echo #
--echo # MDEV-29029 Index corruption and/or assertion failure upon using RANDOM_BYTES for indexed virtual column
--echo #
create table t1 (a int);
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
alter table t1 add column b binary(32) generated always as (random_bytes(a));
alter table t1 add column b binary(32) default (random_bytes(a));
drop table t1;
--echo #
--echo #
--echo # End of 10.10 tests
--echo #

View file

@ -170,6 +170,18 @@ alter table t1 add column r blob generated always
as (match(a) against ('' in boolean mode)) virtual;
ERROR HY000: Function or expression 'match ... against()' cannot be used in the GENERATED ALWAYS AS clause of `r`
drop table t1;
#
# MDEV-29029 Index corruption and/or assertion failure upon using RANDOM_BYTES for indexed virtual column
#
create table t1 (a int);
alter table t1 add column b binary(32) generated always as (random_bytes(a));
ERROR HY000: Function or expression 'random_bytes()' cannot be used in the GENERATED ALWAYS AS clause of `b`
alter table t1 add column b binary(32) default (random_bytes(a));
drop table t1;
#
#
# End of 10.10 tests
#
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;

View file

@ -172,6 +172,18 @@ alter table t1 add column r blob generated always
as (match(a) against ('' in boolean mode)) virtual;
ERROR HY000: Function or expression 'match ... against()' cannot be used in the GENERATED ALWAYS AS clause of `r`
drop table t1;
#
# MDEV-29029 Index corruption and/or assertion failure upon using RANDOM_BYTES for indexed virtual column
#
create table t1 (a int);
alter table t1 add column b binary(32) generated always as (random_bytes(a));
ERROR HY000: Function or expression 'random_bytes()' cannot be used in the GENERATED ALWAYS AS clause of `b`
alter table t1 add column b binary(32) default (random_bytes(a));
drop table t1;
#
#
# End of 10.10 tests
#
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;

View file

@ -397,6 +397,11 @@ public:
static LEX_CSTRING name= {STRING_WITH_LEN("random_bytes")};
return name;
}
bool check_vcol_func_processor(void *arg) override
{
return mark_unsupported_function(func_name(), "()", arg,
VCOL_NON_DETERMINISTIC | VCOL_NOT_VIRTUAL);
}
Item *get_copy(THD *thd) override
{
return get_item_copy<Item_func_random_bytes>(thd, this);