From a6b327e90a8d7c7fe7f64cd2e3ed8535282ff7ff Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 26 Nov 2022 13:39:25 +0100 Subject: [PATCH] cleanup: VCOL_NOT_VIRTUAL->VCOL_NEXTVAL rename to stress that is a specific hack for Item_func_nextval and should not be used for other items. If a vcol uses Item_func_nextval, a corresponding table for the sequence should be added to the prelocking list (in that sense NEXTVAL is not simply a function, but more like a subquery), see add_internal_tables() in DML_prelocking_strategy::handle_table(). At the moment it is only implemented for DEFAULT, not for GENERATED ALWAYS AS, thus the VCOL_NEXTVAL hack. --- mysql-test/suite/gcol/inc/gcol_blocked_sql_funcs_main.inc | 4 ++++ mysql-test/suite/gcol/r/gcol_blocked_sql_funcs_innodb.result | 3 +++ mysql-test/suite/gcol/r/gcol_blocked_sql_funcs_myisam.result | 3 +++ sql/field.cc | 4 ++-- sql/field.h | 5 ++--- sql/item_func.h | 4 +--- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/mysql-test/suite/gcol/inc/gcol_blocked_sql_funcs_main.inc b/mysql-test/suite/gcol/inc/gcol_blocked_sql_funcs_main.inc index 9435551ce6f..879e2fe857d 100644 --- a/mysql-test/suite/gcol/inc/gcol_blocked_sql_funcs_main.inc +++ b/mysql-test/suite/gcol/inc/gcol_blocked_sql_funcs_main.inc @@ -247,3 +247,7 @@ 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 # End of 10.3 tests +--echo # diff --git a/mysql-test/suite/gcol/r/gcol_blocked_sql_funcs_innodb.result b/mysql-test/suite/gcol/r/gcol_blocked_sql_funcs_innodb.result index fa8f2660aef..b9fe877b0f2 100644 --- a/mysql-test/suite/gcol/r/gcol_blocked_sql_funcs_innodb.result +++ b/mysql-test/suite/gcol/r/gcol_blocked_sql_funcs_innodb.result @@ -170,6 +170,9 @@ 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; +# +# End of 10.3 tests +# DROP VIEW IF EXISTS v1,v2; DROP TABLE IF EXISTS t1,t2,t3; DROP PROCEDURE IF EXISTS p1; diff --git a/mysql-test/suite/gcol/r/gcol_blocked_sql_funcs_myisam.result b/mysql-test/suite/gcol/r/gcol_blocked_sql_funcs_myisam.result index b777bb485de..23fdea42488 100644 --- a/mysql-test/suite/gcol/r/gcol_blocked_sql_funcs_myisam.result +++ b/mysql-test/suite/gcol/r/gcol_blocked_sql_funcs_myisam.result @@ -172,6 +172,9 @@ 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; +# +# End of 10.3 tests +# DROP VIEW IF EXISTS v1,v2; DROP TABLE IF EXISTS t1,t2,t3; DROP PROCEDURE IF EXISTS p1; diff --git a/sql/field.cc b/sql/field.cc index 43514347106..de92d1dea94 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -10525,8 +10525,8 @@ bool check_expression(Virtual_column_info *vcol, LEX_CSTRING *name, uint filter= VCOL_IMPOSSIBLE; if (type != VCOL_GENERATED_VIRTUAL && type != VCOL_DEFAULT) filter|= VCOL_NOT_STRICTLY_DETERMINISTIC; - if (type == VCOL_GENERATED_VIRTUAL) - filter|= VCOL_NOT_VIRTUAL; + if (type != VCOL_DEFAULT) + filter|= VCOL_NEXTVAL; if (unlikely(ret || (res.errors & filter))) { diff --git a/sql/field.h b/sql/field.h index 4ef4483a15a..757a6cc23d0 100644 --- a/sql/field.h +++ b/sql/field.h @@ -528,10 +528,10 @@ static inline const char *vcol_type_name(enum_vcol_info_type type) #define VCOL_FIELD_REF 1 #define VCOL_NON_DETERMINISTIC 2 #define VCOL_SESSION_FUNC 4 /* uses session data, e.g. USER or DAYNAME */ -#define VCOL_TIME_FUNC 8 +#define VCOL_TIME_FUNC 8 /* safe for SBR */ #define VCOL_AUTO_INC 16 #define VCOL_IMPOSSIBLE 32 -#define VCOL_NOT_VIRTUAL 64 /* Function can't be virtual */ +#define VCOL_NEXTVAL 64 /* NEXVAL is not implemented for vcols */ #define VCOL_NOT_STRICTLY_DETERMINISTIC \ (VCOL_NON_DETERMINISTIC | VCOL_TIME_FUNC | VCOL_SESSION_FUNC) @@ -4965,5 +4965,4 @@ ulonglong TABLE::vers_start_id() const return static_cast(vers_start_field()->val_int()); } - #endif /* FIELD_INCLUDED */ diff --git a/sql/item_func.h b/sql/item_func.h index 7268b56eb97..d7fd24d7fa2 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -3159,9 +3159,7 @@ public: void print(String *str, enum_query_type query_type); bool check_vcol_func_processor(void *arg) { - return mark_unsupported_function(func_name(), "()", arg, - (VCOL_NON_DETERMINISTIC | - VCOL_NOT_VIRTUAL)); + return mark_unsupported_function(func_name(), "()", arg, VCOL_NEXTVAL); } };