1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

better ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED

This commit is contained in:
Sergei Golubchik
2016-06-27 19:22:09 +02:00
parent 1b4f0962c1
commit 0a056c9b53
22 changed files with 213 additions and 186 deletions

View File

@@ -403,7 +403,7 @@ create or replace table t1 (a int as (b), b int default 1);
create or replace table t1 (a int as (b), b int default (1+1)); create or replace table t1 (a int as (b), b int default (1+1));
create or replace table t1 (a int default 1, b int as (c), c int default (a+1)); create or replace table t1 (a int default 1, b int as (c), c int default (a+1));
create or replace table t1 (a int default (1+1), b int as (c), c int default (a+1)); create or replace table t1 (a int default (1+1), b int as (c), c int default (a+1));
create or replace table t1 (a VARCHAR(128) DEFAULT @@version); create or replace table t1 (a varchar(128) default @@version);
create or replace table t1 (a int not null, b int as (a)); create or replace table t1 (a int not null, b int as (a));
create or replace table t1 (a int not null, b int default (a+1)); create or replace table t1 (a int not null, b int default (a+1));
create or replace table t1 (a int default a); create or replace table t1 (a int default a);
@@ -441,9 +441,9 @@ drop table t1;
# Error handling # Error handling
# #
create or replace table t1 (a bigint default xxx()); create or replace table t1 (a bigint default xxx());
ERROR HY000: Function or expression '`xxx`' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression '`xxx`()' cannot be used in the DEFAULT clause of `a`
create or replace table t1 (a bigint default (select (1))); create or replace table t1 (a bigint default (select (1)));
ERROR HY000: Function or expression 'subselect' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'select ...' cannot be used in the DEFAULT clause of `a`
create or replace table t1 (a bigint default (1,2,3)); create or replace table t1 (a bigint default (1,2,3));
ERROR 21000: Operand should contain 1 column(s) ERROR 21000: Operand should contain 1 column(s)
create or replace table t1 (a bigint default ((1,2,3))); create or replace table t1 (a bigint default ((1,2,3)));
@@ -456,11 +456,11 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
# Invalid DEFAULT expressions # Invalid DEFAULT expressions
# #
CREATE TABLE t1 (a INT DEFAULT ((SELECT 1))); CREATE TABLE t1 (a INT DEFAULT ((SELECT 1)));
ERROR HY000: Function or expression 'subselect' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'select ...' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a INT DEFAULT (EXISTS (SELECT 1))); CREATE TABLE t1 (a INT DEFAULT (EXISTS (SELECT 1)));
ERROR HY000: Function or expression 'subselect' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'select ...' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a INT DEFAULT (1=ANY (SELECT 1))); CREATE TABLE t1 (a INT DEFAULT (1=ANY (SELECT 1)));
ERROR HY000: Function or expression 'subselect' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'select ...' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a INT DEFAULT ROW(1,1)); CREATE TABLE t1 (a INT DEFAULT ROW(1,1));
ERROR 21000: Operand should contain 1 column(s) ERROR 21000: Operand should contain 1 column(s)
CREATE TABLE t1 (a INT DEFAULT (1,1)); CREATE TABLE t1 (a INT DEFAULT (1,1));
@@ -474,29 +474,29 @@ Got one of the listed errors
CREATE TABLE t1 (a INT DEFAULT (b), b INT DEFAULT(a)); CREATE TABLE t1 (a INT DEFAULT (b), b INT DEFAULT(a));
ERROR 01000: Expression for field `a` is refering to uninitialized field `b` ERROR 01000: Expression for field `a` is refering to uninitialized field `b`
CREATE TABLE t1 (a INT DEFAULT @v); CREATE TABLE t1 (a INT DEFAULT @v);
ERROR HY000: Function or expression 'user_var' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression '@v' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a INT DEFAULT @v:=1); CREATE TABLE t1 (a INT DEFAULT @v:=1);
ERROR HY000: Function or expression 'user_var' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression '@v' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a INT DEFAULT(NAME_CONST('xxx', 'yyy')); CREATE TABLE t1 (a INT DEFAULT(NAME_CONST('xxx', 'yyy'));
ERROR HY000: Function or expression 'name_const' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'name_const()' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a INT DEFAULT COUNT(*)); CREATE TABLE t1 (a INT DEFAULT COUNT(*));
ERROR HY000: Function or expression 'count(' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'count()' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a INT DEFAULT COUNT(1)); CREATE TABLE t1 (a INT DEFAULT COUNT(1));
ERROR HY000: Function or expression 'count(' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'count()' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a INT DEFAULT AVG(1)); CREATE TABLE t1 (a INT DEFAULT AVG(1));
ERROR HY000: Function or expression 'avg(' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'avg()' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a INT DEFAULT MIN(1)); CREATE TABLE t1 (a INT DEFAULT MIN(1));
ERROR HY000: Function or expression 'min(' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'min()' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a INT DEFAULT GROUP_CONCAT(1)); CREATE TABLE t1 (a INT DEFAULT GROUP_CONCAT(1));
ERROR HY000: Function or expression 'group_concat' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'group_concat()' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a INT DEFAULT ROW_NUMBER() OVER ()); CREATE TABLE t1 (a INT DEFAULT ROW_NUMBER() OVER ());
ERROR HY000: Function or expression 'row_number' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'row_number()' cannot be used in the DEFAULT clause of `a`
CREATE FUNCTION f1() RETURNS INT RETURN 1; CREATE FUNCTION f1() RETURNS INT RETURN 1;
CREATE TABLE t1 (a INT DEFAULT f1()); CREATE TABLE t1 (a INT DEFAULT f1());
ERROR HY000: Function or expression '`f1`' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression '`f1`()' cannot be used in the DEFAULT clause of `a`
DROP FUNCTION f1; DROP FUNCTION f1;
CREATE PROCEDURE p1(par INT) CREATE TABLE t1 (a INT DEFAULT par); CREATE PROCEDURE p1(par INT) CREATE TABLE t1 (a INT DEFAULT par);
ERROR HY000: Function or expression '???' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'par' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a INT DEFAULT par); CREATE TABLE t1 (a INT DEFAULT par);
ERROR 42S22: Unknown column 'par' in 'virtual column function' ERROR 42S22: Unknown column 'par' in 'virtual column function'
CREATE PROCEDURE p1() CREATE TABLE t1 (a INT DEFAULT par); CREATE PROCEDURE p1() CREATE TABLE t1 (a INT DEFAULT par);
@@ -504,12 +504,12 @@ CALL p1;
ERROR 42S22: Unknown column 'par' in 'virtual column function' ERROR 42S22: Unknown column 'par' in 'virtual column function'
DROP PROCEDURE p1; DROP PROCEDURE p1;
CREATE TABLE t1 (a INT DEFAULT VALUES(a)); CREATE TABLE t1 (a INT DEFAULT VALUES(a));
ERROR HY000: Function or expression 'values' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'values()' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a INT); CREATE TABLE t1 (a INT);
CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW CREATE TABLE t2 (a INT DEFAULT NEW.a); CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW CREATE TABLE t2 (a INT DEFAULT NEW.a);
ERROR HY000: Function or expression 'trigger' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'NEW.a' cannot be used in the DEFAULT clause of `a`
CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW CREATE TEMPORARY TABLE t2 (a INT DEFAULT NEW.a); CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW CREATE TEMPORARY TABLE t2 (a INT DEFAULT NEW.a);
ERROR HY000: Function or expression 'trigger' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'NEW.a' cannot be used in the DEFAULT clause of `a`
DROP TABLE t1; DROP TABLE t1;
# #
# Prepared statements # Prepared statements
@@ -1152,9 +1152,9 @@ DROP TABLE t1;
# Miscelaneous SQL standard <default option> variants # Miscelaneous SQL standard <default option> variants
# #
CREATE TABLE t1 (a VARCHAR(30) DEFAULT CURRENT_USER); CREATE TABLE t1 (a VARCHAR(30) DEFAULT CURRENT_USER);
ERROR HY000: Function or expression 'current_user()' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'current_user()' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a VARCHAR(30) DEFAULT CURRENT_ROLE); CREATE TABLE t1 (a VARCHAR(30) DEFAULT CURRENT_ROLE);
ERROR HY000: Function or expression 'current_role()' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'current_role()' cannot be used in the DEFAULT clause of `a`
# #
# Other Item_func_sysconst derived functions # Other Item_func_sysconst derived functions
# #
@@ -1401,27 +1401,27 @@ a>0
1 1
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (a INT DEFAULT BENCHMARK(1,1)); CREATE TABLE t1 (a INT DEFAULT BENCHMARK(1,1));
ERROR HY000: Function or expression 'benchmark' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'benchmark()' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a INT DEFAULT GET_LOCK('a',1)); CREATE TABLE t1 (a INT DEFAULT GET_LOCK('a',1));
ERROR HY000: Function or expression 'get_lock' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'get_lock()' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a INT DEFAULT RELEASE_LOCK('a')); CREATE TABLE t1 (a INT DEFAULT RELEASE_LOCK('a'));
ERROR HY000: Function or expression 'release_lock' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'release_lock()' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a INT DEFAULT IS_USED_LOCK('a')); CREATE TABLE t1 (a INT DEFAULT IS_USED_LOCK('a'));
ERROR HY000: Function or expression 'is_used_lock' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'is_used_lock()' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a INT DEFAULT IS_FREE_LOCK('a')); CREATE TABLE t1 (a INT DEFAULT IS_FREE_LOCK('a'));
ERROR HY000: Function or expression 'is_free_lock' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'is_free_lock()' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a INT DEFAULT SLEEP(1)); CREATE TABLE t1 (a INT DEFAULT SLEEP(1));
ERROR HY000: Function or expression 'sleep' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'sleep()' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a INT DEFAULT ROW_COUNT()); CREATE TABLE t1 (a INT DEFAULT ROW_COUNT());
ERROR HY000: Function or expression 'row_count' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'row_count()' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a INT DEFAULT FOUND_ROWS()); CREATE TABLE t1 (a INT DEFAULT FOUND_ROWS());
ERROR HY000: Function or expression 'found_rows' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'found_rows()' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a INT DEFAULT MASTER_POS_WAIT('test',100)); CREATE TABLE t1 (a INT DEFAULT MASTER_POS_WAIT('test',100));
ERROR HY000: Function or expression 'master_pos_wait' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'master_pos_wait()' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a INT DEFAULT MASTER_GTID_WAIT('test')); CREATE TABLE t1 (a INT DEFAULT MASTER_GTID_WAIT('test'));
ERROR HY000: Function or expression 'master_gtid_wait' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'master_gtid_wait()' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a VARCHAR(30), b DOUBLE DEFAULT MATCH (a) AGAINST('bbbb' IN BOOLEAN MODE)); CREATE TABLE t1 (a VARCHAR(30), b DOUBLE DEFAULT MATCH (a) AGAINST('bbbb' IN BOOLEAN MODE));
ERROR HY000: Function or expression 'match' is not allowed for 'DEFAULT' of column/constraint 'b' ERROR HY000: Function or expression 'match ... against()' cannot be used in the DEFAULT clause of `b`
# #
# Temporal functions # Temporal functions
# #
@@ -1466,7 +1466,7 @@ a b c
01,5,2013 %d,%m,%Y 2013-05-01 01,5,2013 %d,%m,%Y 2013-05-01
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(30), b VARCHAR(30) DEFAULT DATE_FORMAT(a,'%W %M %Y')); CREATE TABLE t1 (a VARCHAR(30), b VARCHAR(30) DEFAULT DATE_FORMAT(a,'%W %M %Y'));
ERROR HY000: Function or expression 'date_format' is not allowed for 'DEFAULT' of column/constraint 'b' ERROR HY000: Function or expression 'date_format()' cannot be used in the DEFAULT clause of `b`
# Item_datefunc # Item_datefunc
SET time_zone='-10:00'; SET time_zone='-10:00';
SET timestamp=UNIX_TIMESTAMP('2001-01-01 23:59:59'); SET timestamp=UNIX_TIMESTAMP('2001-01-01 23:59:59');
@@ -1901,9 +1901,9 @@ a b
2008-04-01 2 2008-04-01 2
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (a DATE, b VARCHAR(30) DEFAULT DAYNAME(a)); CREATE TABLE t1 (a DATE, b VARCHAR(30) DEFAULT DAYNAME(a));
ERROR HY000: Function or expression 'dayname' is not allowed for 'DEFAULT' of column/constraint 'b' ERROR HY000: Function or expression 'dayname()' cannot be used in the DEFAULT clause of `b`
CREATE TABLE t1 (a DATE, b VARCHAR(30) DEFAULT MONTHNAME(a)); CREATE TABLE t1 (a DATE, b VARCHAR(30) DEFAULT MONTHNAME(a));
ERROR HY000: Function or expression 'monthname' is not allowed for 'DEFAULT' of column/constraint 'b' ERROR HY000: Function or expression 'monthname()' cannot be used in the DEFAULT clause of `b`
CREATE TABLE t1 (a DATE, b INT DEFAULT EXTRACT(YEAR FROM a)); CREATE TABLE t1 (a DATE, b INT DEFAULT EXTRACT(YEAR FROM a));
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
@@ -2702,7 +2702,7 @@ bits v_on v_off v_separator number_of_bits x
327686 Y N 64 NYYNNNNNNNNNNNNNYNYNNNNNNNNNNN 327686 Y N 64 NYYNNNNNNNNNNNNNYNYNNNNNNNNNNN
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(30), b BLOB DEFAULT LOAD_FILE(a)); CREATE TABLE t1 (a VARCHAR(30), b BLOB DEFAULT LOAD_FILE(a));
ERROR HY000: Function or expression 'load_file' is not allowed for 'DEFAULT' of column/constraint 'b' ERROR HY000: Function or expression 'load_file()' cannot be used in the DEFAULT clause of `b`
# #
# Predicates # Predicates
# #
@@ -2992,7 +2992,7 @@ CREATE TABLE t1
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,
b INT DEFAULT LAST_INSERT_ID() b INT DEFAULT LAST_INSERT_ID()
); );
ERROR HY000: Function or expression 'last_insert_id' is not allowed for 'DEFAULT' of column/constraint 'b' ERROR HY000: Function or expression 'last_insert_id()' cannot be used in the DEFAULT clause of `b`
CREATE TABLE t1 (a INT DEFAULT CONNECTION_ID()); CREATE TABLE t1 (a INT DEFAULT CONNECTION_ID());
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
Table Create Table Table Create Table

View File

@@ -473,9 +473,9 @@ select collation(group_concat(a,_koi8r'test')) from t1;
collation(group_concat(a,_koi8r'test')) collation(group_concat(a,_koi8r'test'))
cp1250_general_ci cp1250_general_ci
select collation(group_concat(a,_koi8r 0xC1C2)) from t1; select collation(group_concat(a,_koi8r 0xC1C2)) from t1;
ERROR HY000: Illegal mix of collations (cp1250_general_ci,IMPLICIT) and (koi8r_general_ci,COERCIBLE) for operation 'group_concat' ERROR HY000: Illegal mix of collations (cp1250_general_ci,IMPLICIT) and (koi8r_general_ci,COERCIBLE) for operation 'group_concat('
select collation(group_concat(a,b)) from t1; select collation(group_concat(a,b)) from t1;
ERROR HY000: Illegal mix of collations (cp1250_general_ci,IMPLICIT) and (koi8r_general_ci,IMPLICIT) for operation 'group_concat' ERROR HY000: Illegal mix of collations (cp1250_general_ci,IMPLICIT) and (koi8r_general_ci,IMPLICIT) for operation 'group_concat('
drop table t1; drop table t1;
drop table t2; drop table t2;
CREATE TABLE t1 (a CHAR(10) CHARACTER SET cp850); CREATE TABLE t1 (a CHAR(10) CHARACTER SET cp850);

View File

@@ -301,7 +301,7 @@ POLYGON((9 9,5 2,4 5,9 9))
# MDEV-10134 Add full support for DEFAULT # MDEV-10134 Add full support for DEFAULT
# #
CREATE TABLE t1 (a INT DEFAULT ST_GIS_DEBUG(1)); CREATE TABLE t1 (a INT DEFAULT ST_GIS_DEBUG(1));
ERROR HY000: Function or expression 'st_gis_debug' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'st_gis_debug()' cannot be used in the DEFAULT clause of `a`
# #
# End of 10.2 tests # End of 10.2 tests
# #

View File

@@ -456,7 +456,7 @@ pk, c,
row_number() over (partition by c order by pk row_number() over (partition by c order by pk
range between unbounded preceding and current row) as r range between unbounded preceding and current row) as r
from t1; from t1;
ERROR HY000: Window frame is not allowed with 'row_number' ERROR HY000: Window frame is not allowed with 'row_number('
select select
pk, c, pk, c,
rank() over w1 as r rank() over w1 as r

View File

@@ -562,7 +562,7 @@ include/rpl_end.inc
# MDEV-10134 Add full support for DEFAULT # MDEV-10134 Add full support for DEFAULT
# #
CREATE TABLE t1 (a VARCHAR(100) DEFAULT BINLOG_GTID_POS("master-bin.000001", 600)); CREATE TABLE t1 (a VARCHAR(100) DEFAULT BINLOG_GTID_POS("master-bin.000001", 600));
ERROR HY000: Function or expression 'binlog_gtid_pos' is not allowed for 'DEFAULT' of column/constraint 'a' ERROR HY000: Function or expression 'binlog_gtid_pos()' cannot be used in the DEFAULT clause of `a`
# #
# End of 10.2 tests # End of 10.2 tests
# #

View File

@@ -4,22 +4,22 @@ set time_zone='+10:00';
set div_precision_increment=20; set div_precision_increment=20;
create table t1 (a int, b int, v decimal(20,19) as (a/3)); create table t1 (a int, b int, v decimal(20,19) as (a/3));
create table t2 (a int, b int, v int as (a+@a)); create table t2 (a int, b int, v int as (a+@a));
ERROR HY000: Function or expression 'user_var' is not allowed for 'VIRTUAL' of column/constraint 'v' ERROR HY000: Function or expression '@a' cannot be used in the GENERATED ALWAYS AS clause of `v`
create table t2 (a int, b int, v int as (a+@a) PERSISTENT); create table t2 (a int, b int, v int as (a+@a) PERSISTENT);
ERROR HY000: Function or expression 'user_var' is not allowed for 'VIRTUAL' of column/constraint 'v' ERROR HY000: Function or expression '@a' cannot be used in the GENERATED ALWAYS AS clause of `v`
create table t3_ok (a int, b int, v int as (a+@@error_count)); create table t3_ok (a int, b int, v int as (a+@@error_count));
create table t3 (a int, b int, v int as (a+@@error_count) PERSISTENT); create table t3 (a int, b int, v int as (a+@@error_count) PERSISTENT);
ERROR HY000: Function or expression 'get_system_var' is not allowed for 'VIRTUAL' of column/constraint 'v' ERROR HY000: Function or expression '@@error_count' cannot be used in the GENERATED ALWAYS AS clause of `v`
create table t4 (a int, b int, v int as (@a:=a)); create table t4 (a int, b int, v int as (@a:=a));
ERROR HY000: Function or expression 'user_var' is not allowed for 'VIRTUAL' of column/constraint 'v' ERROR HY000: Function or expression '@a' cannot be used in the GENERATED ALWAYS AS clause of `v`
create table t4 (a int, b int, v int as (@a:=a) PERSISTENT); create table t4 (a int, b int, v int as (@a:=a) PERSISTENT);
ERROR HY000: Function or expression 'user_var' is not allowed for 'VIRTUAL' of column/constraint 'v' ERROR HY000: Function or expression '@a' cannot be used in the GENERATED ALWAYS AS clause of `v`
create table t5 (a int, b int, v varchar(100) as (monthname(a))); create table t5 (a int, b int, v varchar(100) as (monthname(a)));
ERROR HY000: Function or expression 'monthname' is not allowed for 'VIRTUAL' of column/constraint 'v' ERROR HY000: Function or expression 'monthname()' cannot be used in the GENERATED ALWAYS AS clause of `v`
create table t6 (a int, b int, v varchar(100) as (dayname(a))); create table t6 (a int, b int, v varchar(100) as (dayname(a)));
ERROR HY000: Function or expression 'dayname' is not allowed for 'VIRTUAL' of column/constraint 'v' ERROR HY000: Function or expression 'dayname()' cannot be used in the GENERATED ALWAYS AS clause of `v`
create table t7 (a int, b int, v varchar(100) as (date_format(a, '%W %a %M %b'))); create table t7 (a int, b int, v varchar(100) as (date_format(a, '%W %a %M %b')));
ERROR HY000: Function or expression 'date_format' is not allowed for 'VIRTUAL' of column/constraint 'v' ERROR HY000: Function or expression 'date_format()' cannot be used in the GENERATED ALWAYS AS clause of `v`
create table t8 (a int, b int, v varchar(100) as (from_unixtime(a))); create table t8 (a int, b int, v varchar(100) as (from_unixtime(a)));
insert t1 (a,b) values (1,2); insert t1 (a,b) values (1,2);
insert t8 (a,b) values (1234567890,2); insert t8 (a,b) values (1234567890,2);

View File

@@ -2,68 +2,68 @@ SET @@session.storage_engine = 'MyISAM';
# RAND() # RAND()
create or replace table t1 (b double as (rand())); create or replace table t1 (b double as (rand()));
create or replace table t1 (b double as (rand()) PERSISTENT); create or replace table t1 (b double as (rand()) PERSISTENT);
ERROR HY000: Function or expression 'rand' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'rand()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# LOAD_FILE() # LOAD_FILE()
create or replace table t1 (a varchar(64), b varchar(1024) as (load_file(a))); create or replace table t1 (a varchar(64), b varchar(1024) as (load_file(a)));
ERROR HY000: Function or expression 'load_file' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'load_file()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# CURDATE() # CURDATE()
create or replace table t1 (a datetime as (curdate()) PERSISTENT); create or replace table t1 (a datetime as (curdate()) PERSISTENT);
ERROR HY000: Function or expression 'curdate' is not allowed for 'VIRTUAL' of column/constraint 'a' ERROR HY000: Function or expression 'curdate()' cannot be used in the GENERATED ALWAYS AS clause of `a`
# CURRENT_DATE(), CURRENT_DATE # CURRENT_DATE(), CURRENT_DATE
create or replace table t1 (a datetime as (current_date) PERSISTENT); create or replace table t1 (a datetime as (current_date) PERSISTENT);
ERROR HY000: Function or expression 'curdate' is not allowed for 'VIRTUAL' of column/constraint 'a' ERROR HY000: Function or expression 'curdate()' cannot be used in the GENERATED ALWAYS AS clause of `a`
create or replace table t1 (a datetime as (current_date()) PERSISTENT); create or replace table t1 (a datetime as (current_date()) PERSISTENT);
ERROR HY000: Function or expression 'curdate' is not allowed for 'VIRTUAL' of column/constraint 'a' ERROR HY000: Function or expression 'curdate()' cannot be used in the GENERATED ALWAYS AS clause of `a`
# CURRENT_TIME(), CURRENT_TIME # CURRENT_TIME(), CURRENT_TIME
create or replace table t1 (a datetime as (current_time) PERSISTENT); create or replace table t1 (a datetime as (current_time) PERSISTENT);
ERROR HY000: Function or expression 'curtime' is not allowed for 'VIRTUAL' of column/constraint 'a' ERROR HY000: Function or expression 'curtime()' cannot be used in the GENERATED ALWAYS AS clause of `a`
create or replace table t1 (a datetime as (current_time()) PERSISTENT); create or replace table t1 (a datetime as (current_time()) PERSISTENT);
ERROR HY000: Function or expression 'curtime' is not allowed for 'VIRTUAL' of column/constraint 'a' ERROR HY000: Function or expression 'curtime()' cannot be used in the GENERATED ALWAYS AS clause of `a`
# CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP # CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP
create or replace table t1 (a datetime as (current_timestamp()) PERSISTENT); create or replace table t1 (a datetime as (current_timestamp()) PERSISTENT);
ERROR HY000: Function or expression 'now' is not allowed for 'VIRTUAL' of column/constraint 'a' ERROR HY000: Function or expression 'now()' cannot be used in the GENERATED ALWAYS AS clause of `a`
create or replace table t1 (a datetime as (current_timestamp) PERSISTENT); create or replace table t1 (a datetime as (current_timestamp) PERSISTENT);
ERROR HY000: Function or expression 'now' is not allowed for 'VIRTUAL' of column/constraint 'a' ERROR HY000: Function or expression 'now()' cannot be used in the GENERATED ALWAYS AS clause of `a`
# CURTIME() # CURTIME()
create or replace table t1 (a datetime as (curtime()) PERSISTENT); create or replace table t1 (a datetime as (curtime()) PERSISTENT);
ERROR HY000: Function or expression 'curtime' is not allowed for 'VIRTUAL' of column/constraint 'a' ERROR HY000: Function or expression 'curtime()' cannot be used in the GENERATED ALWAYS AS clause of `a`
# LOCALTIME(), LOCALTIME # LOCALTIME(), LOCALTIME
create or replace table t1 (a datetime, b varchar(10) as (localtime()) PERSISTENT); create or replace table t1 (a datetime, b varchar(10) as (localtime()) PERSISTENT);
ERROR HY000: Function or expression 'now' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'now()' cannot be used in the GENERATED ALWAYS AS clause of `b`
create or replace table t1 (a datetime, b varchar(10) as (localtime) PERSISTENT); create or replace table t1 (a datetime, b varchar(10) as (localtime) PERSISTENT);
ERROR HY000: Function or expression 'now' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'now()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# LOCALTIMESTAMP, LOCALTIMESTAMP()(v4.0.6) # LOCALTIMESTAMP, LOCALTIMESTAMP()(v4.0.6)
create or replace table t1 (a datetime, b varchar(10) as (localtimestamp()) PERSISTENT); create or replace table t1 (a datetime, b varchar(10) as (localtimestamp()) PERSISTENT);
ERROR HY000: Function or expression 'now' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'now()' cannot be used in the GENERATED ALWAYS AS clause of `b`
create or replace table t1 (a datetime, b varchar(10) as (localtimestamp) PERSISTENT); create or replace table t1 (a datetime, b varchar(10) as (localtimestamp) PERSISTENT);
ERROR HY000: Function or expression 'now' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'now()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# NOW() # NOW()
create or replace table t1 (a datetime, b varchar(10) as (now()) PERSISTENT); create or replace table t1 (a datetime, b varchar(10) as (now()) PERSISTENT);
ERROR HY000: Function or expression 'now' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'now()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# SYSDATE() # SYSDATE()
create or replace table t1 (a int, b varchar(10) as (sysdate()) PERSISTENT); create or replace table t1 (a int, b varchar(10) as (sysdate()) PERSISTENT);
ERROR HY000: Function or expression 'sysdate' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'sysdate()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# UNIX_TIMESTAMP() # UNIX_TIMESTAMP()
create or replace table t1 (a datetime, b datetime as (unix_timestamp()) PERSISTENT); create or replace table t1 (a datetime, b datetime as (unix_timestamp()) PERSISTENT);
ERROR HY000: Function or expression 'unix_timestamp' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'unix_timestamp()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# UTC_DATE() # UTC_DATE()
create or replace table t1 (a datetime, b datetime as (utc_date()) PERSISTENT); create or replace table t1 (a datetime, b datetime as (utc_date()) PERSISTENT);
ERROR HY000: Function or expression 'utc_date' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'utc_date()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# UTC_TIME() # UTC_TIME()
create or replace table t1 (a datetime, b datetime as (utc_time()) PERSISTENT); create or replace table t1 (a datetime, b datetime as (utc_time()) PERSISTENT);
ERROR HY000: Function or expression 'utc_time' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'utc_time()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# UTC_TIMESTAMP() # UTC_TIMESTAMP()
create or replace table t1 (a datetime, b datetime as (utc_timestamp()) PERSISTENT); create or replace table t1 (a datetime, b datetime as (utc_timestamp()) PERSISTENT);
ERROR HY000: Function or expression 'utc_timestamp' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'utc_timestamp()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# WEEK() - one argument version # WEEK() - one argument version
create or replace table t1 (a datetime, b datetime as (week(a)) PERSISTENT); create or replace table t1 (a datetime, b datetime as (week(a)) PERSISTENT);
ERROR HY000: Function or expression 'get_system_var' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression '@@default_week_format' cannot be used in the GENERATED ALWAYS AS clause of `b`
# MATCH() # MATCH()
create or replace table t1 (a varchar(32), b bool as (match a against ('sample text')) PERSISTENT); create or replace table t1 (a varchar(32), b bool as (match a against ('sample text')) PERSISTENT);
ERROR HY000: Function or expression 'match' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'match ... against()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# BENCHMARK() # BENCHMARK()
create or replace table t1 (a varchar(1024), b varchar(1024) as (benchmark(a,3))); create or replace table t1 (a varchar(1024), b varchar(1024) as (benchmark(a,3)));
ERROR HY000: Function or expression 'benchmark' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'benchmark()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# CHARSET() # CHARSET()
create or replace table t1 (a varchar(64), b varchar(64) as (charset(a)) PERSISTENT); create or replace table t1 (a varchar(64), b varchar(64) as (charset(a)) PERSISTENT);
# COERCIBILITY() # COERCIBILITY()
@@ -73,77 +73,77 @@ create or replace table t1 (a varchar(64), b varchar(64) as (collation(a)) PERSI
# CONNECTION_ID() # CONNECTION_ID()
create or replace table t1 (a int as (connection_id())); create or replace table t1 (a int as (connection_id()));
create or replace table t1 (a int as (connection_id()) PERSISTENT); create or replace table t1 (a int as (connection_id()) PERSISTENT);
ERROR HY000: Function or expression 'connection_id' is not allowed for 'VIRTUAL' of column/constraint 'a' ERROR HY000: Function or expression 'connection_id()' cannot be used in the GENERATED ALWAYS AS clause of `a`
# CURRENT_USER(), CURRENT_USER # CURRENT_USER(), CURRENT_USER
create or replace table t1 (a varchar(32) as (current_user())); create or replace table t1 (a varchar(32) as (current_user()));
ERROR HY000: Function or expression 'current_user()' is not allowed for 'VIRTUAL' of column/constraint 'a' ERROR HY000: Function or expression 'current_user()' cannot be used in the GENERATED ALWAYS AS clause of `a`
create or replace table t1 (a varchar(32) as (current_user()) PERSISTENT); create or replace table t1 (a varchar(32) as (current_user()) PERSISTENT);
ERROR HY000: Function or expression 'current_user()' is not allowed for 'VIRTUAL' of column/constraint 'a' ERROR HY000: Function or expression 'current_user()' cannot be used in the GENERATED ALWAYS AS clause of `a`
create or replace table t1 (a varchar(32) as (current_user) PERSISTENT); create or replace table t1 (a varchar(32) as (current_user) PERSISTENT);
ERROR HY000: Function or expression 'current_user()' is not allowed for 'VIRTUAL' of column/constraint 'a' ERROR HY000: Function or expression 'current_user()' cannot be used in the GENERATED ALWAYS AS clause of `a`
# DATABASE() # DATABASE()
create or replace table t1 (a varchar(32) as (database())); create or replace table t1 (a varchar(32) as (database()));
create or replace table t1 (a varchar(1024), b varchar(1024) as (database()) PERSISTENT); create or replace table t1 (a varchar(1024), b varchar(1024) as (database()) PERSISTENT);
ERROR HY000: Function or expression 'database()' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'database()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# FOUND_ROWS() # FOUND_ROWS()
create or replace table t1 (a varchar(1024), b varchar(1024) as (found_rows())); create or replace table t1 (a varchar(1024), b varchar(1024) as (found_rows()));
ERROR HY000: Function or expression 'found_rows' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'found_rows()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# GET_LOCK() # GET_LOCK()
create or replace table t1 (a varchar(1024), b varchar(1024) as (get_lock(a,10))); create or replace table t1 (a varchar(1024), b varchar(1024) as (get_lock(a,10)));
ERROR HY000: Function or expression 'get_lock' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'get_lock()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# IS_FREE_LOCK() # IS_FREE_LOCK()
create or replace table t1 (a varchar(1024), b varchar(1024) as (is_free_lock(a))); create or replace table t1 (a varchar(1024), b varchar(1024) as (is_free_lock(a)));
ERROR HY000: Function or expression 'is_free_lock' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'is_free_lock()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# IS_USED_LOCK() # IS_USED_LOCK()
create or replace table t1 (a varchar(1024), b varchar(1024) as (is_used_lock(a))); create or replace table t1 (a varchar(1024), b varchar(1024) as (is_used_lock(a)));
ERROR HY000: Function or expression 'is_used_lock' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'is_used_lock()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# LAST_INSERT_ID() # LAST_INSERT_ID()
create or replace table t1 (a int as (last_insert_id())); create or replace table t1 (a int as (last_insert_id()));
ERROR HY000: Function or expression 'last_insert_id' is not allowed for 'VIRTUAL' of column/constraint 'a' ERROR HY000: Function or expression 'last_insert_id()' cannot be used in the GENERATED ALWAYS AS clause of `a`
# MASTER_POS_WAIT() # MASTER_POS_WAIT()
create or replace table t1 (a varchar(32), b int as (master_pos_wait(a,0,2))); create or replace table t1 (a varchar(32), b int as (master_pos_wait(a,0,2)));
ERROR HY000: Function or expression 'master_pos_wait' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'master_pos_wait()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# NAME_CONST() # NAME_CONST()
create or replace table t1 (a varchar(32) as (name_const('test',1))); create or replace table t1 (a varchar(32) as (name_const('test',1)));
ERROR HY000: Function or expression 'name_const' is not allowed for 'VIRTUAL' of column/constraint 'a' ERROR HY000: Function or expression 'name_const()' cannot be used in the GENERATED ALWAYS AS clause of `a`
# RELEASE_LOCK() # RELEASE_LOCK()
create or replace table t1 (a varchar(32), b int as (release_lock(a))); create or replace table t1 (a varchar(32), b int as (release_lock(a)));
ERROR HY000: Function or expression 'release_lock' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'release_lock()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# ROW_COUNT() # ROW_COUNT()
create or replace table t1 (a int as (row_count())); create or replace table t1 (a int as (row_count()));
ERROR HY000: Function or expression 'row_count' is not allowed for 'VIRTUAL' of column/constraint 'a' ERROR HY000: Function or expression 'row_count()' cannot be used in the GENERATED ALWAYS AS clause of `a`
# SCHEMA() # SCHEMA()
create or replace table t1 (a varchar(32) as (schema()) PERSISTENT); create or replace table t1 (a varchar(32) as (schema()) PERSISTENT);
ERROR HY000: Function or expression 'database()' is not allowed for 'VIRTUAL' of column/constraint 'a' ERROR HY000: Function or expression 'database()' cannot be used in the GENERATED ALWAYS AS clause of `a`
# SESSION_USER() # SESSION_USER()
create or replace table t1 (a varchar(32) as (session_user()) PERSISTENT); create or replace table t1 (a varchar(32) as (session_user()) PERSISTENT);
ERROR HY000: Function or expression 'user()' is not allowed for 'VIRTUAL' of column/constraint 'a' ERROR HY000: Function or expression 'user()' cannot be used in the GENERATED ALWAYS AS clause of `a`
# SLEEP() # SLEEP()
create or replace table t1 (a int, b int as (sleep(a))); create or replace table t1 (a int, b int as (sleep(a)));
ERROR HY000: Function or expression 'sleep' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'sleep()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# SYSTEM_USER() # SYSTEM_USER()
create or replace table t1 (a varchar(32) as (system_user()) PERSISTENT); create or replace table t1 (a varchar(32) as (system_user()) PERSISTENT);
ERROR HY000: Function or expression 'user()' is not allowed for 'VIRTUAL' of column/constraint 'a' ERROR HY000: Function or expression 'user()' cannot be used in the GENERATED ALWAYS AS clause of `a`
# USER() # USER()
create or replace table t1 (a varchar(1024), b varchar(1024) as (user()) PERSISTENT); create or replace table t1 (a varchar(1024), b varchar(1024) as (user()) PERSISTENT);
ERROR HY000: Function or expression 'user()' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'user()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# UUID_SHORT() # UUID_SHORT()
create or replace table t1 (a varchar(1024) as (uuid_short()) PERSISTENT); create or replace table t1 (a varchar(1024) as (uuid_short()) PERSISTENT);
ERROR HY000: Function or expression 'uuid_short' is not allowed for 'VIRTUAL' of column/constraint 'a' ERROR HY000: Function or expression 'uuid_short()' cannot be used in the GENERATED ALWAYS AS clause of `a`
# UUID() # UUID()
create or replace table t1 (a varchar(1024) as (uuid()) PERSISTENT); create or replace table t1 (a varchar(1024) as (uuid()) PERSISTENT);
ERROR HY000: Function or expression 'uuid' is not allowed for 'VIRTUAL' of column/constraint 'a' ERROR HY000: Function or expression 'uuid()' cannot be used in the GENERATED ALWAYS AS clause of `a`
# VALUES() # VALUES()
create or replace table t1 (a varchar(1024), b varchar(1024) as (values(a))); create or replace table t1 (a varchar(1024), b varchar(1024) as (values(a)));
ERROR HY000: Function or expression 'values' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'values()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# VERSION() # VERSION()
create or replace table t1 (a varchar(1024), b varchar(1024) as (version()) PERSISTENT); create or replace table t1 (a varchar(1024), b varchar(1024) as (version()) PERSISTENT);
ERROR HY000: Function or expression 'version()' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'version()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# ENCRYPT() # ENCRYPT()
create or replace table t1 (a varchar(1024), b varchar(1024) as (encrypt(a)) PERSISTENT); create or replace table t1 (a varchar(1024), b varchar(1024) as (encrypt(a)) PERSISTENT);
# DATE_FORMAT() # DATE_FORMAT()
create or replace table t1 (a datetime, b varchar(64) as (date_format(a,'%W %M %D')); create or replace table t1 (a datetime, b varchar(64) as (date_format(a,'%W %M %D'));
ERROR HY000: Function or expression 'date_format' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'date_format()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# Stored procedures # Stored procedures
create procedure p1() create procedure p1()
begin begin
@@ -155,77 +155,77 @@ begin
return 1; return 1;
end // end //
create or replace table t1 (a int as (p1()) PERSISTENT); create or replace table t1 (a int as (p1()) PERSISTENT);
ERROR HY000: Function or expression '`p1`' is not allowed for 'VIRTUAL' of column/constraint 'a' ERROR HY000: Function or expression '`p1`()' cannot be used in the GENERATED ALWAYS AS clause of `a`
create or replace table t1 (a int as (f1()) PERSISTENT); create or replace table t1 (a int as (f1()) PERSISTENT);
ERROR HY000: Function or expression '`f1`' is not allowed for 'VIRTUAL' of column/constraint 'a' ERROR HY000: Function or expression '`f1`()' cannot be used in the GENERATED ALWAYS AS clause of `a`
drop procedure p1; drop procedure p1;
drop function f1; drop function f1;
# Unknown functions # Unknown functions
create or replace table t1 (a int as (f1()) PERSISTENT); create or replace table t1 (a int as (f1()) PERSISTENT);
ERROR HY000: Function or expression '`f1`' is not allowed for 'VIRTUAL' of column/constraint 'a' ERROR HY000: Function or expression '`f1`()' cannot be used in the GENERATED ALWAYS AS clause of `a`
# #
# GROUP BY FUNCTIONS # GROUP BY FUNCTIONS
# #
# AVG() # AVG()
create or replace table t1 (a int, b int as (avg(a))); create or replace table t1 (a int, b int as (avg(a)));
ERROR HY000: Function or expression 'avg(' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'avg()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# BIT_AND() # BIT_AND()
create or replace table t1 (a int, b int as (bit_and(a))); create or replace table t1 (a int, b int as (bit_and(a)));
ERROR HY000: Function or expression 'bit_and(' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'bit_and()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# BIT_OR() # BIT_OR()
create or replace table t1 (a int, b int as (bit_or(a))); create or replace table t1 (a int, b int as (bit_or(a)));
ERROR HY000: Function or expression 'bit_or(' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'bit_or()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# BIT_XOR() # BIT_XOR()
create or replace table t1 (a int, b int as (bit_xor(a))); create or replace table t1 (a int, b int as (bit_xor(a)));
ERROR HY000: Function or expression 'bit_xor(' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'bit_xor()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# COUNT(DISTINCT) # COUNT(DISTINCT)
create or replace table t1 (a int, b int as (count(distinct a))); create or replace table t1 (a int, b int as (count(distinct a)));
ERROR HY000: Function or expression 'count(distinct ' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'count(distinct )' cannot be used in the GENERATED ALWAYS AS clause of `b`
# COUNT() # COUNT()
create or replace table t1 (a int, b int as (count(a))); create or replace table t1 (a int, b int as (count(a)));
ERROR HY000: Function or expression 'count(' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'count()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# GROUP_CONCAT() # GROUP_CONCAT()
create or replace table t1 (a varchar(32), b int as (group_concat(a,''))); create or replace table t1 (a varchar(32), b int as (group_concat(a,'')));
ERROR HY000: Function or expression 'group_concat' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'group_concat()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# MAX() # MAX()
create or replace table t1 (a int, b int as (max(a))); create or replace table t1 (a int, b int as (max(a)));
ERROR HY000: Function or expression 'max(' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'max()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# MIN() # MIN()
create or replace table t1 (a int, b int as (min(a))); create or replace table t1 (a int, b int as (min(a)));
ERROR HY000: Function or expression 'min(' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'min()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# STD() # STD()
create or replace table t1 (a int, b int as (std(a))); create or replace table t1 (a int, b int as (std(a)));
ERROR HY000: Function or expression 'std(' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'std()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# STDDEV_POP() # STDDEV_POP()
create or replace table t1 (a int, b int as (stddev_pop(a))); create or replace table t1 (a int, b int as (stddev_pop(a)));
ERROR HY000: Function or expression 'std(' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'std()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# STDDEV_SAMP() # STDDEV_SAMP()
create or replace table t1 (a int, b int as (stddev_samp(a))); create or replace table t1 (a int, b int as (stddev_samp(a)));
ERROR HY000: Function or expression 'std(' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'std()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# STDDEV() # STDDEV()
create or replace table t1 (a int, b int as (stddev(a))); create or replace table t1 (a int, b int as (stddev(a)));
ERROR HY000: Function or expression 'std(' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'std()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# SUM() # SUM()
create or replace table t1 (a int, b int as (sum(a))); create or replace table t1 (a int, b int as (sum(a)));
ERROR HY000: Function or expression 'sum(' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'sum()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# VAR_POP() # VAR_POP()
create or replace table t1 (a int, b int as (var_pop(a))); create or replace table t1 (a int, b int as (var_pop(a)));
ERROR HY000: Function or expression 'variance(' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'variance()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# VAR_SAMP() # VAR_SAMP()
create or replace table t1 (a int, b int as (var_samp(a))); create or replace table t1 (a int, b int as (var_samp(a)));
ERROR HY000: Function or expression 'var_samp(' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'var_samp()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# VARIANCE() # VARIANCE()
create or replace table t1 (a int, b int as (variance(a))); create or replace table t1 (a int, b int as (variance(a)));
ERROR HY000: Function or expression 'variance(' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'variance()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# DAYNAME() # DAYNAME()
create or replace table t1 (a int, b varchar(10) as (dayname(a))); create or replace table t1 (a int, b varchar(10) as (dayname(a)));
ERROR HY000: Function or expression 'dayname' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'dayname()' cannot be used in the GENERATED ALWAYS AS clause of `b`
create or replace table t1 (a int, b varchar(10) as (monthname(a))); create or replace table t1 (a int, b varchar(10) as (monthname(a)));
ERROR HY000: Function or expression 'monthname' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'monthname()' cannot be used in the GENERATED ALWAYS AS clause of `b`
create or replace table t1 (a int, b varchar(10) as (date_format("1963-01-01","%d.%m.%Y"))); create or replace table t1 (a int, b varchar(10) as (date_format("1963-01-01","%d.%m.%Y")));
ERROR HY000: Function or expression 'date_format' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'date_format()' cannot be used in the GENERATED ALWAYS AS clause of `b`
create or replace table t1 (a int, b varchar(10) as (time_format(now(),"%d.%m.%Y"))); create or replace table t1 (a int, b varchar(10) as (time_format(now(),"%d.%m.%Y")));
ERROR HY000: Function or expression 'time_format' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'time_format()' cannot be used in the GENERATED ALWAYS AS clause of `b`
# #
# XML FUNCTIONS # XML FUNCTIONS
# #
@@ -238,12 +238,12 @@ create or replace table t1 (a varchar(1024), b varchar(1024) as (UpdateXML(a,'/a
# #
create or replace table t1 (a int); create or replace table t1 (a int);
create or replace table t2 (a int, b int as (select count(*) from t1)); create or replace table t2 (a int, b int as (select count(*) from t1));
ERROR HY000: Function or expression 'subselect' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'select ...' cannot be used in the GENERATED ALWAYS AS clause of `b`
drop table t1; drop table t1;
create or replace table t1 (a int, b int as ((select 1))); create or replace table t1 (a int, b int as ((select 1)));
ERROR HY000: Function or expression 'subselect' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'select ...' cannot be used in the GENERATED ALWAYS AS clause of `b`
create or replace table t1 (a int, b int as (a+(select 1))); create or replace table t1 (a int, b int as (a+(select 1)));
ERROR HY000: Function or expression 'subselect' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression 'select ...' cannot be used in the GENERATED ALWAYS AS clause of `b`
# #
# SP functions # SP functions
# #
@@ -254,7 +254,7 @@ select sub1(1);
sub1(1) sub1(1)
2 2
create or replace table t1 (a int, b int as (a+sub3(1))); create or replace table t1 (a int, b int as (a+sub3(1)));
ERROR HY000: Function or expression '`sub3`' is not allowed for 'VIRTUAL' of column/constraint 'b' ERROR HY000: Function or expression '`sub3`()' cannot be used in the GENERATED ALWAYS AS clause of `b`
drop function sub1; drop function sub1;
# #
# Long expression # Long expression

View File

@@ -288,7 +288,7 @@ create or replace table t1 (a int as (b), b int default 1);
create or replace table t1 (a int as (b), b int default (1+1)); create or replace table t1 (a int as (b), b int default (1+1));
create or replace table t1 (a int default 1, b int as (c), c int default (a+1)); create or replace table t1 (a int default 1, b int as (c), c int default (a+1));
create or replace table t1 (a int default (1+1), b int as (c), c int default (a+1)); create or replace table t1 (a int default (1+1), b int as (c), c int default (a+1));
create or replace table t1 (a VARCHAR(128) DEFAULT @@version); create or replace table t1 (a varchar(128) default @@version);
create or replace table t1 (a int not null, b int as (a)); create or replace table t1 (a int not null, b int as (a));
create or replace table t1 (a int not null, b int default (a+1)); create or replace table t1 (a int not null, b int default (a+1));

View File

@@ -9798,7 +9798,7 @@ bool Column_definition::check(THD *thd)
if (vcol_info) if (vcol_info)
{ {
vcol_info->set_field_type(sql_type); vcol_info->set_field_type(sql_type);
if (check_expression(vcol_info, "VIRTUAL", field_name, if (check_expression(vcol_info, "GENERATED ALWAYS AS", field_name,
vcol_info->stored_in_db)) vcol_info->stored_in_db))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }

View File

@@ -1422,6 +1422,16 @@ bool mark_unsupported_function(const char *where, void *store, uint result)
return false; return false;
} }
/* convenience helper for mark_unsupported_function() above */
bool mark_unsupported_function(const char *w1, const char *w2,
void *store, uint result)
{
char *ptr= (char*)current_thd->alloc(strlen(w1) + strlen(w2) + 1);
if (ptr)
strxmov(ptr, w1, w2, NullS);
return mark_unsupported_function(ptr, store, result);
}
/***************************************************************************** /*****************************************************************************
Item_sp_variable methods Item_sp_variable methods
*****************************************************************************/ *****************************************************************************/
@@ -8583,6 +8593,13 @@ void Item_trigger_field::print(String *str, enum_query_type query_type)
} }
bool Item_trigger_field::check_vcol_func_processor(void *arg)
{
const char *ver= row_version == NEW_ROW ? "NEW." : "OLD.";
return mark_unsupported_function(ver, field_name, arg, VCOL_IMPOSSIBLE);
}
void Item_trigger_field::cleanup() void Item_trigger_field::cleanup()
{ {
want_privilege= original_privilege; want_privilege= original_privilege;

View File

@@ -62,6 +62,9 @@ char_to_byte_length_safe(uint32 char_length_arg, uint32 mbmaxlen_arg)
bool mark_unsupported_function(const char *where, void *store, uint result); bool mark_unsupported_function(const char *where, void *store, uint result);
/* convenience helper for mark_unsupported_function() above */
bool mark_unsupported_function(const char *w1, const char *w2,
void *store, uint result);
/* Bits for the split_sum_func() function */ /* Bits for the split_sum_func() function */
#define SPLIT_SUM_SKIP_REGISTERED 1 /* Skip registered funcs */ #define SPLIT_SUM_SKIP_REGISTERED 1 /* Skip registered funcs */
@@ -2032,6 +2035,10 @@ public:
inline int save_in_field(Field *field, bool no_conversions); inline int save_in_field(Field *field, bool no_conversions);
inline bool send(Protocol *protocol, String *str); inline bool send(Protocol *protocol, String *str);
bool check_vcol_func_processor(void *arg)
{
return mark_unsupported_function(m_name.str, arg, VCOL_IMPOSSIBLE);
}
}; };
/***************************************************************************** /*****************************************************************************
@@ -2239,7 +2246,7 @@ public:
} }
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function("name_const", arg, VCOL_IMPOSSIBLE); return mark_unsupported_function("name_const()", arg, VCOL_IMPOSSIBLE);
} }
}; };
@@ -4936,7 +4943,7 @@ public:
bool check_partition_func_processor(void *int_arg) {return TRUE;} bool check_partition_func_processor(void *int_arg) {return TRUE;}
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function("values", arg, VCOL_IMPOSSIBLE); return mark_unsupported_function("values()", arg, VCOL_IMPOSSIBLE);
} }
}; };
@@ -5023,10 +5030,7 @@ private:
*/ */
bool read_only; bool read_only;
public: public:
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg);
{
return mark_unsupported_function("trigger", arg, VCOL_IMPOSSIBLE);
}
}; };

View File

@@ -4587,6 +4587,11 @@ longlong Item_func_sleep::val_int()
} }
bool Item_func_user_var::check_vcol_func_processor(void *arg)
{
return mark_unsupported_function("@", name.str, arg, VCOL_IMPOSSIBLE);
}
#define extra_size sizeof(double) #define extra_size sizeof(double)
user_var_entry *get_variable(HASH *hash, LEX_STRING &name, user_var_entry *get_variable(HASH *hash, LEX_STRING &name,
@@ -5847,6 +5852,10 @@ void Item_func_get_system_var::print(String *str, enum_query_type query_type)
str->append(name, name_length); str->append(name, name_length);
} }
bool Item_func_get_system_var::check_vcol_func_processor(void *arg)
{
return mark_unsupported_function("@@", var->name.str, arg, VCOL_NON_DETERMINISTIC);
}
enum Item_result Item_func_get_system_var::result_type() const enum Item_result Item_func_get_system_var::result_type() const
{ {
@@ -6850,6 +6859,10 @@ void Item_func_sp::update_used_tables()
} }
} }
bool Item_func_sp::check_vcol_func_processor(void *arg)
{
return mark_unsupported_function(func_name(), "()", arg, VCOL_IMPOSSIBLE);
}
/* /*
uuid_short handling. uuid_short handling.

View File

@@ -614,7 +614,7 @@ public:
longlong val_int() { DBUG_ASSERT(fixed == 1); return value; } longlong val_int() { DBUG_ASSERT(fixed == 1); return value; }
bool check_vcol_func_processor(void *arg) 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_NON_DETERMINISTIC);
} }
}; };
@@ -1041,7 +1041,7 @@ public:
void cleanup() { first_eval= TRUE; Item_real_func::cleanup(); } void cleanup() { first_eval= TRUE; Item_real_func::cleanup(); }
bool check_vcol_func_processor(void *arg) 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_NON_DETERMINISTIC);
} }
private: private:
void seed_random (Item * val); void seed_random (Item * val);
@@ -1337,7 +1337,7 @@ public:
bool fix_fields(THD *thd, Item **ref); bool fix_fields(THD *thd, Item **ref);
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(func_name(), arg, VCOL_IMPOSSIBLE); return mark_unsupported_function(func_name(), "()", arg, VCOL_IMPOSSIBLE);
} }
}; };
@@ -1354,7 +1354,7 @@ public:
virtual void print(String *str, enum_query_type query_type); virtual void print(String *str, enum_query_type query_type);
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(func_name(), arg, VCOL_IMPOSSIBLE); return mark_unsupported_function(func_name(), "()", arg, VCOL_IMPOSSIBLE);
} }
}; };
@@ -1376,7 +1376,7 @@ public:
longlong val_int(); longlong val_int();
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(func_name(), arg, VCOL_IMPOSSIBLE); return mark_unsupported_function(func_name(), "()", arg, VCOL_IMPOSSIBLE);
} }
}; };
@@ -1471,7 +1471,7 @@ public:
virtual void print(String *str, enum_query_type query_type); virtual void print(String *str, enum_query_type query_type);
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(func_name(), arg, VCOL_UNKNOWN); return mark_unsupported_function(func_name(), "()", arg, VCOL_UNKNOWN);
} }
}; };
@@ -1646,7 +1646,7 @@ class Item_func_get_lock :public Item_int_func
bool is_expensive() { return 1; } bool is_expensive() { return 1; }
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(func_name(), arg, VCOL_IMPOSSIBLE); return mark_unsupported_function(func_name(), "()", arg, VCOL_IMPOSSIBLE);
} }
}; };
@@ -1666,7 +1666,7 @@ public:
bool is_expensive() { return 1; } bool is_expensive() { return 1; }
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(func_name(), arg, VCOL_IMPOSSIBLE); return mark_unsupported_function(func_name(), "()", arg, VCOL_IMPOSSIBLE);
} }
}; };
@@ -1686,7 +1686,7 @@ public:
void fix_length_and_dec() { max_length=21; maybe_null=1;} void fix_length_and_dec() { max_length=21; maybe_null=1;}
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(func_name(), arg, VCOL_IMPOSSIBLE); return mark_unsupported_function(func_name(), "()", arg, VCOL_IMPOSSIBLE);
} }
}; };
@@ -1702,7 +1702,7 @@ public:
void fix_length_and_dec() { max_length=10+1+10+1+20+1; maybe_null=0;} void fix_length_and_dec() { max_length=10+1+10+1+20+1; maybe_null=0;}
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(func_name(), arg, VCOL_IMPOSSIBLE); return mark_unsupported_function(func_name(), "()", arg, VCOL_IMPOSSIBLE);
} }
}; };
@@ -1728,10 +1728,7 @@ public:
Item_func_user_var(THD *thd, Item_func_user_var *item) Item_func_user_var(THD *thd, Item_func_user_var *item)
:Item_hybrid_func(thd, item), :Item_hybrid_func(thd, item),
m_var_entry(item->m_var_entry), name(item->name) { } m_var_entry(item->m_var_entry), name(item->name) { }
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg);
{
return mark_unsupported_function("user_var", arg, VCOL_IMPOSSIBLE);
}
}; };
@@ -1938,10 +1935,7 @@ public:
bool eq(const Item *item, bool binary_cmp) const; bool eq(const Item *item, bool binary_cmp) const;
void cleanup(); void cleanup();
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg);
{
return mark_unsupported_function(func_name(), arg, VCOL_NON_DETERMINISTIC);
}
}; };
@@ -1989,7 +1983,7 @@ public:
void init_search(THD *thd, bool no_order); void init_search(THD *thd, bool no_order);
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(func_name(), arg, VCOL_IMPOSSIBLE); return mark_unsupported_function("match ... against()", arg, VCOL_IMPOSSIBLE);
} }
private: private:
/** /**
@@ -2046,7 +2040,7 @@ public:
void fix_length_and_dec() { decimals=0; max_length=1; maybe_null=1;} void fix_length_and_dec() { decimals=0; max_length=1; maybe_null=1;}
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(func_name(), arg, VCOL_IMPOSSIBLE); return mark_unsupported_function(func_name(), "()", arg, VCOL_IMPOSSIBLE);
} }
}; };
@@ -2060,7 +2054,7 @@ public:
void fix_length_and_dec() { decimals=0; max_length=10; maybe_null=1;} void fix_length_and_dec() { decimals=0; max_length=10; maybe_null=1;}
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(func_name(), arg, VCOL_IMPOSSIBLE); return mark_unsupported_function(func_name(), "()", arg, VCOL_IMPOSSIBLE);
} }
}; };
@@ -2110,7 +2104,7 @@ public:
void fix_length_and_dec() { decimals= 0; maybe_null=0; } void fix_length_and_dec() { decimals= 0; maybe_null=0; }
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(func_name(), arg, VCOL_IMPOSSIBLE); return mark_unsupported_function(func_name(), "()", arg, VCOL_IMPOSSIBLE);
} }
}; };
@@ -2234,10 +2228,7 @@ public:
return sp_result_field; return sp_result_field;
} }
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg);
{
return mark_unsupported_function(func_name(), arg, VCOL_IMPOSSIBLE);
}
bool limit_index_condition_pushdown_processor(void *opt_arg) bool limit_index_condition_pushdown_processor(void *opt_arg)
{ {
return TRUE; return TRUE;
@@ -2254,7 +2245,7 @@ public:
void fix_length_and_dec() { decimals= 0; maybe_null=0; } void fix_length_and_dec() { decimals= 0; maybe_null=0; }
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(func_name(), arg, VCOL_IMPOSSIBLE); return mark_unsupported_function(func_name(), "()", arg, VCOL_IMPOSSIBLE);
} }
}; };
@@ -2272,7 +2263,7 @@ public:
table_map used_tables() const { return RAND_TABLE_BIT; } table_map used_tables() const { return RAND_TABLE_BIT; }
bool check_vcol_func_processor(void *arg) 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_NON_DETERMINISTIC);
} }
}; };

View File

@@ -618,7 +618,7 @@ class Item_func_gis_debug: public Item_int_func
longlong val_int(); longlong val_int();
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(func_name(), arg, VCOL_IMPOSSIBLE); return mark_unsupported_function(func_name(), "()", arg, VCOL_IMPOSSIBLE);
} }
}; };
#endif #endif

View File

@@ -763,7 +763,7 @@ public:
const char *func_name() const { return "binlog_gtid_pos"; } const char *func_name() const { return "binlog_gtid_pos"; }
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(func_name(), arg, VCOL_IMPOSSIBLE); return mark_unsupported_function(func_name(), "()", arg, VCOL_IMPOSSIBLE);
} }
}; };
@@ -923,7 +923,7 @@ public:
} }
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(func_name(), arg, VCOL_IMPOSSIBLE); return mark_unsupported_function(func_name(), "()", arg, VCOL_IMPOSSIBLE);
} }
}; };
@@ -1191,7 +1191,7 @@ public:
String *val_str(String *); String *val_str(String *);
bool check_vcol_func_processor(void *arg) 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_NON_DETERMINISTIC);
} }
}; };

View File

@@ -222,7 +222,7 @@ public:
bool enumerate_field_refs_processor(void *arg); bool enumerate_field_refs_processor(void *arg);
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function("subselect", arg, VCOL_IMPOSSIBLE); return mark_unsupported_function("select ...", arg, VCOL_IMPOSSIBLE);
} }
/** /**
Callback to test if an IN predicate is expensive. Callback to test if an IN predicate is expensive.

View File

@@ -579,6 +579,12 @@ Item *Item_sum::result_item(THD *thd, Field *field)
return new (thd->mem_root) Item_field(thd, field); return new (thd->mem_root) Item_field(thd, field);
} }
bool Item_sum::check_vcol_func_processor(void *arg)
{
return mark_unsupported_function(func_name(), ")", arg, VCOL_IMPOSSIBLE);
}
/** /**
Compare keys consisting of single field that cannot be compared as binary. Compare keys consisting of single field that cannot be compared as binary.

View File

@@ -547,11 +547,7 @@ public:
virtual void remove() { DBUG_ASSERT(0); } virtual void remove() { DBUG_ASSERT(0); }
virtual void cleanup(); virtual void cleanup();
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg);
{
return mark_unsupported_function(func_name(), arg, VCOL_IMPOSSIBLE);
}
virtual void setup_window_func(THD *thd, Window_spec *window_spec) {} virtual void setup_window_func(THD *thd, Window_spec *window_spec) {}
}; };
@@ -1555,7 +1551,7 @@ public:
void cleanup(); void cleanup();
enum Sumfunctype sum_func () const {return GROUP_CONCAT_FUNC;} enum Sumfunctype sum_func () const {return GROUP_CONCAT_FUNC;}
const char *func_name() const { return "group_concat"; } const char *func_name() const { return "group_concat("; }
virtual Item_result result_type () const { return STRING_RESULT; } virtual Item_result result_type () const { return STRING_RESULT; }
virtual Item_result cmp_type () const { return STRING_RESULT; } virtual Item_result cmp_type () const { return STRING_RESULT; }
enum_field_types field_type() const enum_field_types field_type() const

View File

@@ -196,7 +196,7 @@ public:
} }
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(func_name(), arg, VCOL_IMPOSSIBLE); return mark_unsupported_function(func_name(), "()", arg, VCOL_IMPOSSIBLE);
} }
}; };
@@ -411,7 +411,7 @@ class Item_func_dayname :public Item_func_weekday
bool check_partition_func_processor(void *int_arg) {return TRUE;} bool check_partition_func_processor(void *int_arg) {return TRUE;}
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(func_name(), arg, VCOL_IMPOSSIBLE); return mark_unsupported_function(func_name(), "()", arg, VCOL_IMPOSSIBLE);
} }
}; };
@@ -464,7 +464,7 @@ public:
{ {
if (arg_count) if (arg_count)
return FALSE; return FALSE;
return mark_unsupported_function(func_name(), arg, VCOL_TIME_FUNC); return mark_unsupported_function(func_name(), "()", arg, VCOL_TIME_FUNC);
} }
longlong int_op(); longlong int_op();
my_decimal *decimal_op(my_decimal* buf); my_decimal *decimal_op(my_decimal* buf);
@@ -614,7 +614,7 @@ public:
virtual void store_now_in_TIME(THD *thd, MYSQL_TIME *now_time)=0; virtual void store_now_in_TIME(THD *thd, MYSQL_TIME *now_time)=0;
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(func_name(), arg, VCOL_TIME_FUNC); return mark_unsupported_function(func_name(), "()", arg, VCOL_TIME_FUNC);
} }
}; };
@@ -649,7 +649,7 @@ public:
virtual void store_now_in_TIME(THD *thd, MYSQL_TIME *now_time)=0; virtual void store_now_in_TIME(THD *thd, MYSQL_TIME *now_time)=0;
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(func_name(), arg, return mark_unsupported_function(func_name(), "()", arg,
VCOL_TIME_FUNC); VCOL_TIME_FUNC);
} }
}; };
@@ -691,7 +691,7 @@ public:
NOW is safe for replication as slaves will run with same time as NOW is safe for replication as slaves will run with same time as
master master
*/ */
return mark_unsupported_function(func_name(), arg, VCOL_TIME_FUNC); return mark_unsupported_function(func_name(), "()", arg, VCOL_TIME_FUNC);
} }
}; };
@@ -715,7 +715,7 @@ public:
virtual enum Functype functype() const { return NOW_UTC_FUNC; } virtual enum Functype functype() const { return NOW_UTC_FUNC; }
virtual bool check_vcol_func_processor(void *arg) virtual bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(func_name(), arg, return mark_unsupported_function(func_name(), "()", arg,
VCOL_TIME_FUNC | VCOL_NON_DETERMINISTIC); VCOL_TIME_FUNC | VCOL_NON_DETERMINISTIC);
} }
@@ -737,7 +737,7 @@ public:
table_map used_tables() const { return RAND_TABLE_BIT; } table_map used_tables() const { return RAND_TABLE_BIT; }
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(func_name(), arg, return mark_unsupported_function(func_name(), "()", arg,
VCOL_TIME_FUNC | VCOL_NON_DETERMINISTIC); VCOL_TIME_FUNC | VCOL_NON_DETERMINISTIC);
} }
virtual enum Functype functype() const { return SYSDATE_FUNC; } virtual enum Functype functype() const { return SYSDATE_FUNC; }
@@ -776,7 +776,7 @@ public:
bool eq(const Item *item, bool binary_cmp) const; bool eq(const Item *item, bool binary_cmp) const;
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(func_name(), arg, VCOL_IMPOSSIBLE); return mark_unsupported_function(func_name(), "()", arg, VCOL_IMPOSSIBLE);
} }
}; };

View File

@@ -117,7 +117,7 @@ public:
} }
const char*func_name() const const char*func_name() const
{ {
return "row_number"; return "row_number(";
} }
}; };

View File

@@ -6970,7 +6970,7 @@ start-error-number 1900
ER_VCOL_BASED_ON_VCOL ER_VCOL_BASED_ON_VCOL
eng "A computed column cannot be based on a computed column" eng "A computed column cannot be based on a computed column"
ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
eng "Function or expression '%s' is not allowed for '%s' of column/constraint '%s'" eng "Function or expression '%s' cannot be used in the %s clause of %`s"
ER_DATA_CONVERSION_ERROR_FOR_VIRTUAL_COLUMN ER_DATA_CONVERSION_ERROR_FOR_VIRTUAL_COLUMN
eng "Generated value for computed column '%s' cannot be converted to type '%s'" eng "Generated value for computed column '%s' cannot be converted to type '%s'"
ER_PRIMARY_KEY_BASED_ON_VIRTUAL_COLUMN ER_PRIMARY_KEY_BASED_ON_VIRTUAL_COLUMN
@@ -7209,7 +7209,7 @@ ER_CONSTRAINT_FAILED 23000
rus "проверка CONSTRAINT %`s для %`-.192s.%`-.192s провалилась" rus "проверка CONSTRAINT %`s для %`-.192s.%`-.192s провалилась"
ukr "Перевірка CONSTRAINT %`s для %`-.192s.%`-.192s не пройшла" ukr "Перевірка CONSTRAINT %`s для %`-.192s.%`-.192s не пройшла"
ER_EXPRESSION_IS_TOO_BIG ER_EXPRESSION_IS_TOO_BIG
eng "%s expression is too big for '%s'" eng "%s expression in the %s clause is too big"
ER_ERROR_EVALUATING_EXPRESSION ER_ERROR_EVALUATING_EXPRESSION
eng "Got an error evaluating stored expression %`s" eng "Got an error evaluating stored expression %`s"
ER_CALCULATING_DEFAULT_VALUE ER_CALCULATING_DEFAULT_VALUE

View File

@@ -2614,7 +2614,7 @@ static bool fix_vcol_expr(THD *thd,
if (error || (res.errors & VCOL_IMPOSSIBLE)) if (error || (res.errors & VCOL_IMPOSSIBLE))
{ {
my_error(ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED, MYF(0), res.name, my_error(ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED, MYF(0), res.name,
field_name); "???", field_name);
goto end; goto end;
} }
#endif #endif