Skip to content

Commit a6b327e

Browse files
committed
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.
1 parent 53e57a8 commit a6b327e

File tree

6 files changed

+15
-8
lines changed

6 files changed

+15
-8
lines changed

mysql-test/suite/gcol/inc/gcol_blocked_sql_funcs_main.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,3 +247,7 @@ create table t1 (a int);
247247
alter table t1 add column r blob generated always
248248
as (match(a) against ('' in boolean mode)) virtual;
249249
drop table t1;
250+
251+
--echo #
252+
--echo # End of 10.3 tests
253+
--echo #

mysql-test/suite/gcol/r/gcol_blocked_sql_funcs_innodb.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ alter table t1 add column r blob generated always
170170
as (match(a) against ('' in boolean mode)) virtual;
171171
ERROR HY000: Function or expression 'match ... against()' cannot be used in the GENERATED ALWAYS AS clause of `r`
172172
drop table t1;
173+
#
174+
# End of 10.3 tests
175+
#
173176
DROP VIEW IF EXISTS v1,v2;
174177
DROP TABLE IF EXISTS t1,t2,t3;
175178
DROP PROCEDURE IF EXISTS p1;

mysql-test/suite/gcol/r/gcol_blocked_sql_funcs_myisam.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ alter table t1 add column r blob generated always
172172
as (match(a) against ('' in boolean mode)) virtual;
173173
ERROR HY000: Function or expression 'match ... against()' cannot be used in the GENERATED ALWAYS AS clause of `r`
174174
drop table t1;
175+
#
176+
# End of 10.3 tests
177+
#
175178
DROP VIEW IF EXISTS v1,v2;
176179
DROP TABLE IF EXISTS t1,t2,t3;
177180
DROP PROCEDURE IF EXISTS p1;

sql/field.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10525,8 +10525,8 @@ bool check_expression(Virtual_column_info *vcol, LEX_CSTRING *name,
1052510525
uint filter= VCOL_IMPOSSIBLE;
1052610526
if (type != VCOL_GENERATED_VIRTUAL && type != VCOL_DEFAULT)
1052710527
filter|= VCOL_NOT_STRICTLY_DETERMINISTIC;
10528-
if (type == VCOL_GENERATED_VIRTUAL)
10529-
filter|= VCOL_NOT_VIRTUAL;
10528+
if (type != VCOL_DEFAULT)
10529+
filter|= VCOL_NEXTVAL;
1053010530

1053110531
if (unlikely(ret || (res.errors & filter)))
1053210532
{

sql/field.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,10 +528,10 @@ static inline const char *vcol_type_name(enum_vcol_info_type type)
528528
#define VCOL_FIELD_REF 1
529529
#define VCOL_NON_DETERMINISTIC 2
530530
#define VCOL_SESSION_FUNC 4 /* uses session data, e.g. USER or DAYNAME */
531-
#define VCOL_TIME_FUNC 8
531+
#define VCOL_TIME_FUNC 8 /* safe for SBR */
532532
#define VCOL_AUTO_INC 16
533533
#define VCOL_IMPOSSIBLE 32
534-
#define VCOL_NOT_VIRTUAL 64 /* Function can't be virtual */
534+
#define VCOL_NEXTVAL 64 /* NEXVAL is not implemented for vcols */
535535

536536
#define VCOL_NOT_STRICTLY_DETERMINISTIC \
537537
(VCOL_NON_DETERMINISTIC | VCOL_TIME_FUNC | VCOL_SESSION_FUNC)
@@ -4965,5 +4965,4 @@ ulonglong TABLE::vers_start_id() const
49654965
return static_cast<ulonglong>(vers_start_field()->val_int());
49664966
}
49674967

4968-
49694968
#endif /* FIELD_INCLUDED */

sql/item_func.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3159,9 +3159,7 @@ class Item_func_nextval :public Item_longlong_func
31593159
void print(String *str, enum_query_type query_type);
31603160
bool check_vcol_func_processor(void *arg)
31613161
{
3162-
return mark_unsupported_function(func_name(), "()", arg,
3163-
(VCOL_NON_DETERMINISTIC |
3164-
VCOL_NOT_VIRTUAL));
3162+
return mark_unsupported_function(func_name(), "()", arg, VCOL_NEXTVAL);
31653163
}
31663164
};
31673165

0 commit comments

Comments
 (0)