mirror of
https://github.com/MariaDB/server.git
synced 2025-04-21 06:35:31 +02:00
try harder to reject not strictly deterministic vcols in indexes/stored
detect non-determinism in vcol of vcol, like: create table t1 (a int, b real as (rand()), c real as (b) stored);
This commit is contained in:
parent
ae53f684d3
commit
37bfe32c6d
4 changed files with 42 additions and 6 deletions
|
@ -42,3 +42,16 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
|
|||
#
|
||||
# End of 10.2 tests
|
||||
#
|
||||
create table t1 (a int, b real as (rand()), c real as (b) stored);
|
||||
ERROR HY000: Function or expression 'b' cannot be used in the GENERATED ALWAYS AS clause of `c`
|
||||
create table t1 (a int, b real as (rand()), c real as (b) unique);
|
||||
ERROR HY000: Function or expression 'b' cannot be used in the GENERATED ALWAYS AS clause of `c`
|
||||
create table t1 (a int auto_increment primary key,
|
||||
b int as (a+1), c int as (b+1) stored);
|
||||
ERROR HY000: Function or expression 'b' cannot be used in the GENERATED ALWAYS AS clause of `c`
|
||||
create table t1 (a int auto_increment primary key,
|
||||
b int as (a+1), c int as (b+1) unique);
|
||||
ERROR HY000: Function or expression 'b' cannot be used in the GENERATED ALWAYS AS clause of `c`
|
||||
#
|
||||
# End of 10.3 tests
|
||||
#
|
||||
|
|
|
@ -49,3 +49,18 @@ create table t1 (a int, b serial as (a+1));
|
|||
--echo #
|
||||
--echo # End of 10.2 tests
|
||||
--echo #
|
||||
|
||||
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b real as (rand()), c real as (b) stored);
|
||||
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b real as (rand()), c real as (b) unique);
|
||||
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int auto_increment primary key,
|
||||
b int as (a+1), c int as (b+1) stored);
|
||||
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int auto_increment primary key,
|
||||
b int as (a+1), c int as (b+1) unique);
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.3 tests
|
||||
--echo #
|
||||
|
|
11
sql/item.h
11
sql/item.h
|
@ -3184,12 +3184,13 @@ public:
|
|||
bool check_vcol_func_processor(void *arg)
|
||||
{
|
||||
context= 0;
|
||||
uint res= VCOL_FIELD_REF;
|
||||
if (field && (field->unireg_check == Field::NEXT_NUMBER))
|
||||
{
|
||||
// Auto increment fields are unsupported
|
||||
return mark_unsupported_function(field_name.str, arg, VCOL_FIELD_REF | VCOL_AUTO_INC);
|
||||
}
|
||||
return mark_unsupported_function(field_name.str, arg, VCOL_FIELD_REF);
|
||||
res|= VCOL_AUTO_INC;
|
||||
if (field && field->vcol_info &&
|
||||
field->vcol_info->flags & (VCOL_NOT_STRICTLY_DETERMINISTIC | VCOL_AUTO_INC))
|
||||
res|= VCOL_NON_DETERMINISTIC;
|
||||
return mark_unsupported_function(field_name.str, arg, res);
|
||||
}
|
||||
bool set_fields_as_dependent_processor(void *arg)
|
||||
{
|
||||
|
|
|
@ -3172,11 +3172,18 @@ bool Virtual_column_info::fix_and_check_expr(THD *thd, TABLE *table)
|
|||
pointer at that time
|
||||
*/
|
||||
myf warn= table->s->frm_version < FRM_VER_EXPRESSSIONS ? ME_JUST_WARNING : 0;
|
||||
my_error(ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED, MYF(warn),
|
||||
my_error(ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED, MYF(warn),
|
||||
"AUTO_INCREMENT", get_vcol_type_name(), res.name);
|
||||
if (!warn)
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
else if (vcol_type != VCOL_GENERATED_VIRTUAL && vcol_type != VCOL_DEFAULT &&
|
||||
res.errors & VCOL_NOT_STRICTLY_DETERMINISTIC)
|
||||
{
|
||||
my_error(ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED, MYF(0),
|
||||
res.name, get_vcol_type_name(), name.str);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
flags= res.errors;
|
||||
|
||||
if (!table->s->tmp_table && need_refix())
|
||||
|
|
Loading…
Add table
Reference in a new issue