summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2016-06-27 19:22:09 +0200
committerSergei Golubchik <serg@mariadb.org>2016-06-30 11:43:02 +0200
commit0a056c9b5302c24ee4eaa9cc92bd6697125f94b7 (patch)
tree30576f580f31b6564d26340c61f36d8e350955de
parent1b4f0962c14b3c827553e2a470c82afc419f9352 (diff)
downloadmariadb-git-0a056c9b5302c24ee4eaa9cc92bd6697125f94b7.tar.gz
better ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
-rw-r--r--mysql-test/r/default.result76
-rw-r--r--mysql-test/r/func_gconcat.result4
-rw-r--r--mysql-test/r/gis-debug.result2
-rw-r--r--mysql-test/r/win.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_gtid_basic.result2
-rw-r--r--mysql-test/suite/vcol/r/not_supported.result16
-rw-r--r--mysql-test/suite/vcol/r/vcol_blocked_sql_funcs.result150
-rw-r--r--mysql-test/t/default.test2
-rw-r--r--sql/field.cc2
-rw-r--r--sql/item.cc17
-rw-r--r--sql/item.h16
-rw-r--r--sql/item_func.cc13
-rw-r--r--sql/item_func.h47
-rw-r--r--sql/item_geofunc.h2
-rw-r--r--sql/item_strfunc.h6
-rw-r--r--sql/item_subselect.h2
-rw-r--r--sql/item_sum.cc6
-rw-r--r--sql/item_sum.h8
-rw-r--r--sql/item_timefunc.h18
-rw-r--r--sql/item_windowfunc.h2
-rw-r--r--sql/share/errmsg-utf8.txt4
-rw-r--r--sql/table.cc2
22 files changed, 213 insertions, 186 deletions
diff --git a/mysql-test/r/default.result b/mysql-test/r/default.result
index bfe51d10707..1ba63808105 100644
--- a/mysql-test/r/default.result
+++ b/mysql-test/r/default.result
@@ -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 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 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 default (a+1));
create or replace table t1 (a int default a);
@@ -441,9 +441,9 @@ drop table t1;
# Error handling
#
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)));
-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));
ERROR 21000: Operand should contain 1 column(s)
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
#
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)));
-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)));
-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));
ERROR 21000: Operand should contain 1 column(s)
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));
ERROR 01000: Expression for field `a` is refering to uninitialized field `b`
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);
-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'));
-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(*));
-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));
-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));
-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));
-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));
-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 ());
-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 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;
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);
ERROR 42S22: Unknown column 'par' in 'virtual column function'
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'
DROP PROCEDURE p1;
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 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);
-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;
#
# Prepared statements
@@ -1152,9 +1152,9 @@ DROP TABLE t1;
# Miscelaneous SQL standard <default option> variants
#
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);
-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
#
@@ -1401,27 +1401,27 @@ a>0
1
DROP TABLE t1;
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));
-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'));
-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'));
-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'));
-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));
-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());
-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());
-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));
-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'));
-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));
-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
#
@@ -1466,7 +1466,7 @@ a b c
01,5,2013 %d,%m,%Y 2013-05-01
DROP TABLE t1;
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
SET time_zone='-10:00';
SET timestamp=UNIX_TIMESTAMP('2001-01-01 23:59:59');
@@ -1901,9 +1901,9 @@ a b
2008-04-01 2
DROP TABLE t1;
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));
-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));
SHOW CREATE TABLE t1;
Table Create Table
@@ -2702,7 +2702,7 @@ bits v_on v_off v_separator number_of_bits x
327686 Y N 64 NYYNNNNNNNNNNNNNYNYNNNNNNNNNNN
DROP TABLE t1;
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
#
@@ -2992,7 +2992,7 @@ CREATE TABLE t1
id SERIAL PRIMARY KEY,
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());
SHOW CREATE TABLE t1;
Table Create Table
diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result
index b61abd1e749..4c4ad4da051 100644
--- a/mysql-test/r/func_gconcat.result
+++ b/mysql-test/r/func_gconcat.result
@@ -473,9 +473,9 @@ select collation(group_concat(a,_koi8r'test')) from t1;
collation(group_concat(a,_koi8r'test'))
cp1250_general_ci
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;
-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 t2;
CREATE TABLE t1 (a CHAR(10) CHARACTER SET cp850);
diff --git a/mysql-test/r/gis-debug.result b/mysql-test/r/gis-debug.result
index 13163b156ff..79adef34b98 100644
--- a/mysql-test/r/gis-debug.result
+++ b/mysql-test/r/gis-debug.result
@@ -301,7 +301,7 @@ POLYGON((9 9,5 2,4 5,9 9))
# MDEV-10134 Add full support for DEFAULT
#
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
#
diff --git a/mysql-test/r/win.result b/mysql-test/r/win.result
index a6b43788ffe..ad99453ea1c 100644
--- a/mysql-test/r/win.result
+++ b/mysql-test/r/win.result
@@ -456,7 +456,7 @@ pk, c,
row_number() over (partition by c order by pk
range between unbounded preceding and current row) as r
from t1;
-ERROR HY000: Window frame is not allowed with 'row_number'
+ERROR HY000: Window frame is not allowed with 'row_number('
select
pk, c,
rank() over w1 as r
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_basic.result b/mysql-test/suite/rpl/r/rpl_gtid_basic.result
index 5a0bd928f92..9fb4d043599 100644
--- a/mysql-test/suite/rpl/r/rpl_gtid_basic.result
+++ b/mysql-test/suite/rpl/r/rpl_gtid_basic.result
@@ -562,7 +562,7 @@ include/rpl_end.inc
# MDEV-10134 Add full support for DEFAULT
#
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
#
diff --git a/mysql-test/suite/vcol/r/not_supported.result b/mysql-test/suite/vcol/r/not_supported.result
index eecc7d63c17..fb03e3fdae3 100644
--- a/mysql-test/suite/vcol/r/not_supported.result
+++ b/mysql-test/suite/vcol/r/not_supported.result
@@ -4,22 +4,22 @@ set time_zone='+10:00';
set div_precision_increment=20;
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));
-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);
-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 (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));
-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);
-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)));
-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)));
-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')));
-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)));
insert t1 (a,b) values (1,2);
insert t8 (a,b) values (1234567890,2);
diff --git a/mysql-test/suite/vcol/r/vcol_blocked_sql_funcs.result b/mysql-test/suite/vcol/r/vcol_blocked_sql_funcs.result
index c80ed26b26e..369f0f902fc 100644
--- a/mysql-test/suite/vcol/r/vcol_blocked_sql_funcs.result
+++ b/mysql-test/suite/vcol/r/vcol_blocked_sql_funcs.result
@@ -2,68 +2,68 @@ SET @@session.storage_engine = 'MyISAM';
# RAND()
create or replace table t1 (b double as (rand()));
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()
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()
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
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);
-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
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);
-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
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);
-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()
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
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);
-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)
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);
-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()
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()
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()
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()
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()
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()
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
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()
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()
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()
create or replace table t1 (a varchar(64), b varchar(64) as (charset(a)) PERSISTENT);
# COERCIBILITY()
@@ -73,77 +73,77 @@ create or replace table t1 (a varchar(64), b varchar(64) as (collation(a)) PERSI
# CONNECTION_ID()
create or replace table t1 (a int as (connection_id()));
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
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);
-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);
-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()
create or replace table t1 (a varchar(32) as (database()));
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
create or replace table t1 (a varchar(1024), b varchar(1024) as (encrypt(a)) PERSISTENT);
# DATE_FORMAT()
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
create procedure p1()
begin
@@ -155,77 +155,77 @@ begin
return 1;
end //
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);
-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 function f1;
# Unknown functions
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
#
# AVG()
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()
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()
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()
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)
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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)));
-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")));
-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")));
-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
#
@@ -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 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;
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)));
-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
#
@@ -254,7 +254,7 @@ select sub1(1);
sub1(1)
2
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;
#
# Long expression
diff --git a/mysql-test/t/default.test b/mysql-test/t/default.test
index da43baf6cfc..dedb559d402 100644
--- a/mysql-test/t/default.test
+++ b/mysql-test/t/default.test
@@ -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 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 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 default (a+1));
diff --git a/sql/field.cc b/sql/field.cc
index 00f40fae748..054865c6513 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -9798,7 +9798,7 @@ bool Column_definition::check(THD *thd)
if (vcol_info)
{
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))
DBUG_RETURN(TRUE);
}
diff --git a/sql/item.cc b/sql/item.cc
index d8a282cc151..82c0ea7575c 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1422,6 +1422,16 @@ bool mark_unsupported_function(const char *where, void *store, uint result)
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
*****************************************************************************/
@@ -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()
{
want_privilege= original_privilege;
diff --git a/sql/item.h b/sql/item.h
index 41813e0a80f..4a5efad0048 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -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);
+/* 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 */
#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 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)
{
- 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_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;
public:
- bool check_vcol_func_processor(void *arg)
- {
- return mark_unsupported_function("trigger", arg, VCOL_IMPOSSIBLE);
- }
+ bool check_vcol_func_processor(void *arg);
};
diff --git a/sql/item_func.cc b/sql/item_func.cc
index bda3b76a8dd..c98630e0431 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -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)
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);
}
+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
{
@@ -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.
diff --git a/sql/item_func.h b/sql/item_func.h
index ddb56015224..474f7b802c0 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -614,7 +614,7 @@ public:
longlong val_int() { DBUG_ASSERT(fixed == 1); return value; }
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(); }
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:
void seed_random (Item * val);
@@ -1337,7 +1337,7 @@ public:
bool fix_fields(THD *thd, Item **ref);
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);
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();
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);
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 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 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;}
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;}
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_hybrid_func(thd, item),
m_var_entry(item->m_var_entry), name(item->name) { }
- bool check_vcol_func_processor(void *arg)
- {
- return mark_unsupported_function("user_var", arg, VCOL_IMPOSSIBLE);
- }
+ bool check_vcol_func_processor(void *arg);
};
@@ -1938,10 +1935,7 @@ public:
bool eq(const Item *item, bool binary_cmp) const;
void cleanup();
- bool check_vcol_func_processor(void *arg)
- {
- return mark_unsupported_function(func_name(), arg, VCOL_NON_DETERMINISTIC);
- }
+ bool check_vcol_func_processor(void *arg);
};
@@ -1989,7 +1983,7 @@ public:
void init_search(THD *thd, bool no_order);
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:
/**
@@ -2046,7 +2040,7 @@ public:
void fix_length_and_dec() { decimals=0; max_length=1; maybe_null=1;}
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;}
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; }
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;
}
- bool check_vcol_func_processor(void *arg)
- {
- return mark_unsupported_function(func_name(), arg, VCOL_IMPOSSIBLE);
- }
+ bool check_vcol_func_processor(void *arg);
bool limit_index_condition_pushdown_processor(void *opt_arg)
{
return TRUE;
@@ -2254,7 +2245,7 @@ public:
void fix_length_and_dec() { decimals= 0; maybe_null=0; }
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; }
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);
}
};
diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h
index d3b49b6e457..5a0a26ea779 100644
--- a/sql/item_geofunc.h
+++ b/sql/item_geofunc.h
@@ -618,7 +618,7 @@ class Item_func_gis_debug: public Item_int_func
longlong val_int();
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
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 623f33b1eca..b0f5064a190 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -763,7 +763,7 @@ public:
const char *func_name() const { return "binlog_gtid_pos"; }
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)
{
- 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 *);
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);
}
};
diff --git a/sql/item_subselect.h b/sql/item_subselect.h
index edbfc050971..bec04813bcf 100644
--- a/sql/item_subselect.h
+++ b/sql/item_subselect.h
@@ -222,7 +222,7 @@ public:
bool enumerate_field_refs_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.
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 90a9887f7f7..cc7a76213f0 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -579,6 +579,12 @@ Item *Item_sum::result_item(THD *thd, Field *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.
diff --git a/sql/item_sum.h b/sql/item_sum.h
index b5f7b1458be..4cb5529e1ce 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -547,11 +547,7 @@ public:
virtual void remove() { DBUG_ASSERT(0); }
virtual void cleanup();
- bool check_vcol_func_processor(void *arg)
- {
- return mark_unsupported_function(func_name(), arg, VCOL_IMPOSSIBLE);
- }
-
+ bool check_vcol_func_processor(void *arg);
virtual void setup_window_func(THD *thd, Window_spec *window_spec) {}
};
@@ -1555,7 +1551,7 @@ public:
void cleanup();
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 cmp_type () const { return STRING_RESULT; }
enum_field_types field_type() const
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index e5040d51b72..9f67a1dabe6 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -196,7 +196,7 @@ public:
}
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_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)
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();
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;
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;
bool check_vcol_func_processor(void *arg)
{
- return mark_unsupported_function(func_name(), arg,
+ return mark_unsupported_function(func_name(), "()", arg,
VCOL_TIME_FUNC);
}
};
@@ -691,7 +691,7 @@ public:
NOW is safe for replication as slaves will run with same time as
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 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);
}
@@ -737,7 +737,7 @@ public:
table_map used_tables() const { return RAND_TABLE_BIT; }
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);
}
virtual enum Functype functype() const { return SYSDATE_FUNC; }
@@ -776,7 +776,7 @@ public:
bool eq(const Item *item, bool binary_cmp) const;
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);
}
};
diff --git a/sql/item_windowfunc.h b/sql/item_windowfunc.h
index 56fa272ac45..9d2fa135e29 100644
--- a/sql/item_windowfunc.h
+++ b/sql/item_windowfunc.h
@@ -117,7 +117,7 @@ public:
}
const char*func_name() const
{
- return "row_number";
+ return "row_number(";
}
};
diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt
index ba75a6a9149..980055a7933 100644
--- a/sql/share/errmsg-utf8.txt
+++ b/sql/share/errmsg-utf8.txt
@@ -6970,7 +6970,7 @@ start-error-number 1900
ER_VCOL_BASED_ON_VCOL
eng "A computed column cannot be based on a computed column"
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
eng "Generated value for computed column '%s' cannot be converted to type '%s'"
ER_PRIMARY_KEY_BASED_ON_VIRTUAL_COLUMN
@@ -7209,7 +7209,7 @@ ER_CONSTRAINT_FAILED 23000
rus "проверка CONSTRAINT %`s для %`-.192s.%`-.192s провалилась"
ukr "Перевірка CONSTRAINT %`s для %`-.192s.%`-.192s не пройшла"
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
eng "Got an error evaluating stored expression %`s"
ER_CALCULATING_DEFAULT_VALUE
diff --git a/sql/table.cc b/sql/table.cc
index 98f2f755c02..20444114381 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -2614,7 +2614,7 @@ static bool fix_vcol_expr(THD *thd,
if (error || (res.errors & VCOL_IMPOSSIBLE))
{
my_error(ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED, MYF(0), res.name,
- field_name);
+ "???", field_name);
goto end;
}
#endif