Commit 73be27c0 authored by Igor Babaev's avatar Igor Babaev

Fixed bug #604549.

There was no error thrown when creating a table with a virtual table
computed by an expression returning a row.
This caused a crash when inserting into the table.

Removed periods at the end of the error messages for virtual columns.
Adjusted output in test result files accordingly. 
parent 61973323
...@@ -75,9 +75,9 @@ SET SQL_MODE='IGNORE_BAD_TABLE_OPTIONS'; ...@@ -75,9 +75,9 @@ SET SQL_MODE='IGNORE_BAD_TABLE_OPTIONS';
#illegal value fixed #illegal value fixed
CREATE TABLE t1 (a int) ENGINE=example ULL=10000000000000000000 one_or_two='ttt' YESNO=SSS; CREATE TABLE t1 (a int) ENGINE=example ULL=10000000000000000000 one_or_two='ttt' YESNO=SSS;
Warnings: Warnings:
Warning 1651 Incorrect value '10000000000000000000' for option 'ULL' Warning 1652 Incorrect value '10000000000000000000' for option 'ULL'
Warning 1651 Incorrect value 'ttt' for option 'one_or_two' Warning 1652 Incorrect value 'ttt' for option 'one_or_two'
Warning 1651 Incorrect value 'SSS' for option 'YESNO' Warning 1652 Incorrect value 'SSS' for option 'YESNO'
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
......
...@@ -3,9 +3,9 @@ SET @OLD_SQL_MODE=@@SQL_MODE; ...@@ -3,9 +3,9 @@ SET @OLD_SQL_MODE=@@SQL_MODE;
SET SQL_MODE='IGNORE_BAD_TABLE_OPTIONS'; SET SQL_MODE='IGNORE_BAD_TABLE_OPTIONS';
create table t1 (a int fkey=vvv, key akey (a) dff=vvv) tkey1='1v1'; create table t1 (a int fkey=vvv, key akey (a) dff=vvv) tkey1='1v1';
Warnings: Warnings:
Warning 1650 Unknown option 'fkey' Warning 1651 Unknown option 'fkey'
Warning 1650 Unknown option 'dff' Warning 1651 Unknown option 'dff'
Warning 1650 Unknown option 'tkey1' Warning 1651 Unknown option 'tkey1'
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -16,10 +16,10 @@ drop table t1; ...@@ -16,10 +16,10 @@ drop table t1;
#reassiginig options in the same line #reassiginig options in the same line
create table t1 (a int fkey=vvv, key akey (a) dff=vvv) tkey1=1v1 TKEY1=DEFAULT tkey1=1v2 tkey2=2v1; create table t1 (a int fkey=vvv, key akey (a) dff=vvv) tkey1=1v1 TKEY1=DEFAULT tkey1=1v2 tkey2=2v1;
Warnings: Warnings:
Warning 1650 Unknown option 'fkey' Warning 1651 Unknown option 'fkey'
Warning 1650 Unknown option 'dff' Warning 1651 Unknown option 'dff'
Warning 1650 Unknown option 'tkey1' Warning 1651 Unknown option 'tkey1'
Warning 1650 Unknown option 'tkey2' Warning 1651 Unknown option 'tkey2'
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -29,7 +29,7 @@ t1 CREATE TABLE `t1` ( ...@@ -29,7 +29,7 @@ t1 CREATE TABLE `t1` (
#add option #add option
alter table t1 tkey4=4v1; alter table t1 tkey4=4v1;
Warnings: Warnings:
Warning 1650 Unknown option 'tkey4' Warning 1651 Unknown option 'tkey4'
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -39,8 +39,8 @@ t1 CREATE TABLE `t1` ( ...@@ -39,8 +39,8 @@ t1 CREATE TABLE `t1` (
#remove options #remove options
alter table t1 tkey3=DEFAULT tkey4=DEFAULT; alter table t1 tkey3=DEFAULT tkey4=DEFAULT;
Warnings: Warnings:
Warning 1650 Unknown option 'tkey3' Warning 1651 Unknown option 'tkey3'
Warning 1650 Unknown option 'tkey4' Warning 1651 Unknown option 'tkey4'
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -50,11 +50,11 @@ t1 CREATE TABLE `t1` ( ...@@ -50,11 +50,11 @@ t1 CREATE TABLE `t1` (
drop table t1; drop table t1;
create table t1 (a int fkey1=v1, key akey (a) kkey1=v1) tkey1=1v1 tkey1=1v2 TKEY1=DEFAULT tkey2=2v1 tkey3=3v1; create table t1 (a int fkey1=v1, key akey (a) kkey1=v1) tkey1=1v1 tkey1=1v2 TKEY1=DEFAULT tkey2=2v1 tkey3=3v1;
Warnings: Warnings:
Warning 1650 Unknown option 'fkey1' Warning 1651 Unknown option 'fkey1'
Warning 1650 Unknown option 'kkey1' Warning 1651 Unknown option 'kkey1'
Warning 1650 Unknown option 'TKEY1' Warning 1651 Unknown option 'TKEY1'
Warning 1650 Unknown option 'tkey2' Warning 1651 Unknown option 'tkey2'
Warning 1650 Unknown option 'tkey3' Warning 1651 Unknown option 'tkey3'
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -64,7 +64,7 @@ t1 CREATE TABLE `t1` ( ...@@ -64,7 +64,7 @@ t1 CREATE TABLE `t1` (
#change field with option with the same value #change field with option with the same value
alter table t1 change a a int `FKEY1`='v1'; alter table t1 change a a int `FKEY1`='v1';
Warnings: Warnings:
Warning 1650 Unknown option 'FKEY1' Warning 1651 Unknown option 'FKEY1'
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -74,7 +74,7 @@ t1 CREATE TABLE `t1` ( ...@@ -74,7 +74,7 @@ t1 CREATE TABLE `t1` (
#change field with option with a different value #change field with option with a different value
alter table t1 change a a int fkey1=v2; alter table t1 change a a int fkey1=v2;
Warnings: Warnings:
Warning 1650 Unknown option 'fkey1' Warning 1651 Unknown option 'fkey1'
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -93,7 +93,7 @@ t1 CREATE TABLE `t1` ( ...@@ -93,7 +93,7 @@ t1 CREATE TABLE `t1` (
#new key with options #new key with options
alter table t1 add key bkey (b) kkey2=v1; alter table t1 add key bkey (b) kkey2=v1;
Warnings: Warnings:
Warning 1650 Unknown option 'kkey2' Warning 1651 Unknown option 'kkey2'
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -105,8 +105,8 @@ t1 CREATE TABLE `t1` ( ...@@ -105,8 +105,8 @@ t1 CREATE TABLE `t1` (
#new column with options #new column with options
alter table t1 add column c int fkey1=v1 fkey2=v2; alter table t1 add column c int fkey1=v1 fkey2=v2;
Warnings: Warnings:
Warning 1650 Unknown option 'fkey1' Warning 1651 Unknown option 'fkey1'
Warning 1650 Unknown option 'fkey2' Warning 1651 Unknown option 'fkey2'
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -141,7 +141,7 @@ t1 CREATE TABLE `t1` ( ...@@ -141,7 +141,7 @@ t1 CREATE TABLE `t1` (
#add column with options after delete #add column with options after delete
alter table t1 add column b int fkey2=v1; alter table t1 add column b int fkey2=v1;
Warnings: Warnings:
Warning 1650 Unknown option 'fkey2' Warning 1651 Unknown option 'fkey2'
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -154,7 +154,7 @@ t1 CREATE TABLE `t1` ( ...@@ -154,7 +154,7 @@ t1 CREATE TABLE `t1` (
#add key #add key
alter table t1 add key bkey (b) kkey2=v2; alter table t1 add key bkey (b) kkey2=v2;
Warnings: Warnings:
Warning 1650 Unknown option 'kkey2' Warning 1651 Unknown option 'kkey2'
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -168,7 +168,7 @@ t1 CREATE TABLE `t1` ( ...@@ -168,7 +168,7 @@ t1 CREATE TABLE `t1` (
drop table t1; drop table t1;
create table t1 (a int) tkey1=100; create table t1 (a int) tkey1=100;
Warnings: Warnings:
Warning 1650 Unknown option 'tkey1' Warning 1651 Unknown option 'tkey1'
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
......
SET @@session.storage_engine = 'archive'; SET @@session.storage_engine = 'archive';
create table t1 (a int, b int as (a+1)); create table t1 (a int, b int as (a+1));
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns. ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
create table t1 (a int); create table t1 (a int);
alter table t1 add column b int as (a+1); alter table t1 add column b int as (a+1);
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns. ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
drop table t1; drop table t1;
SET @@session.storage_engine = 'blackhole'; SET @@session.storage_engine = 'blackhole';
create table t1 (a int, b int as (a+1)); create table t1 (a int, b int as (a+1));
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns. ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
create table t1 (a int); create table t1 (a int);
alter table t1 add column b int as (a+1); alter table t1 add column b int as (a+1);
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns. ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
drop table t1; drop table t1;
SET @@session.storage_engine = 'InnoDB'; SET @@session.storage_engine = 'InnoDB';
# RAND() # RAND()
create table t1 (b double as (rand())); create table t1 (b double as (rand()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# LOAD_FILE() # LOAD_FILE()
create table t1 (a varchar(64), b varchar(1024) as (load_file(a))); create table t1 (a varchar(64), b varchar(1024) as (load_file(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# CURDATE() # CURDATE()
create table t1 (a datetime as (curdate())); create table t1 (a datetime as (curdate()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# CURRENT_DATE(), CURRENT_DATE # CURRENT_DATE(), CURRENT_DATE
create table t1 (a datetime as (current_date)); create table t1 (a datetime as (current_date));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
create table t1 (a datetime as (current_date())); create table t1 (a datetime as (current_date()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# CURRENT_TIME(), CURRENT_TIME # CURRENT_TIME(), CURRENT_TIME
create table t1 (a datetime as (current_time)); create table t1 (a datetime as (current_time));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
create table t1 (a datetime as (current_time())); create table t1 (a datetime as (current_time()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP # CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP
create table t1 (a datetime as (current_timestamp())); create table t1 (a datetime as (current_timestamp()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
create table t1 (a datetime as (current_timestamp)); create table t1 (a datetime as (current_timestamp));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# CURTIME() # CURTIME()
create table t1 (a datetime as (curtime())); create table t1 (a datetime as (curtime()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# LOCALTIME(), LOCALTIME # LOCALTIME(), LOCALTIME
create table t1 (a datetime, b varchar(10) as (localtime())); create table t1 (a datetime, b varchar(10) as (localtime()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
create table t1 (a datetime, b varchar(10) as (localtime)); create table t1 (a datetime, b varchar(10) as (localtime));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# LOCALTIMESTAMP, LOCALTIMESTAMP()(v4.0.6) # LOCALTIMESTAMP, LOCALTIMESTAMP()(v4.0.6)
create table t1 (a datetime, b varchar(10) as (localtimestamp())); create table t1 (a datetime, b varchar(10) as (localtimestamp()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
create table t1 (a datetime, b varchar(10) as (localtimestamp)); create table t1 (a datetime, b varchar(10) as (localtimestamp));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# NOW() # NOW()
create table t1 (a datetime, b varchar(10) as (now())); create table t1 (a datetime, b varchar(10) as (now()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# SYSDATE() # SYSDATE()
create table t1 (a int, b varchar(10) as (sysdate())); create table t1 (a int, b varchar(10) as (sysdate()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# UNIX_TIMESTAMP() # UNIX_TIMESTAMP()
create table t1 (a datetime, b datetime as (unix_timestamp())); create table t1 (a datetime, b datetime as (unix_timestamp()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# UTC_DATE() # UTC_DATE()
create table t1 (a datetime, b datetime as (utc_date())); create table t1 (a datetime, b datetime as (utc_date()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# UTC_TIME() # UTC_TIME()
create table t1 (a datetime, b datetime as (utc_time())); create table t1 (a datetime, b datetime as (utc_time()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# UTC_TIMESTAMP() # UTC_TIMESTAMP()
create table t1 (a datetime, b datetime as (utc_timestamp())); create table t1 (a datetime, b datetime as (utc_timestamp()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# MATCH() # MATCH()
# BENCHMARK() # BENCHMARK()
create table t1 (a varchar(1024), b varchar(1024) as (benchmark(a,3))); create table t1 (a varchar(1024), b varchar(1024) as (benchmark(a,3)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# CONNECTION_ID() # CONNECTION_ID()
create table t1 (a int as (connection_id())); create table t1 (a int as (connection_id()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# CURRENT_USER(), CURRENT_USER # CURRENT_USER(), CURRENT_USER
create table t1 (a varchar(32) as (current_user())); create table t1 (a varchar(32) as (current_user()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
create table t1 (a varchar(32) as (current_user)); create table t1 (a varchar(32) as (current_user));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# DATABASE() # DATABASE()
create table t1 (a varchar(1024), b varchar(1024) as (database())); create table t1 (a varchar(1024), b varchar(1024) as (database()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# FOUND_ROWS() # FOUND_ROWS()
create table t1 (a varchar(1024), b varchar(1024) as (found_rows())); create table t1 (a varchar(1024), b varchar(1024) as (found_rows()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# GET_LOCK() # GET_LOCK()
create table t1 (a varchar(1024), b varchar(1024) as (get_lock(a,10))); create table t1 (a varchar(1024), b varchar(1024) as (get_lock(a,10)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# IS_FREE_LOCK() # IS_FREE_LOCK()
create table t1 (a varchar(1024), b varchar(1024) as (is_free_lock(a))); create table t1 (a varchar(1024), b varchar(1024) as (is_free_lock(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# IS_USED_LOCK() # IS_USED_LOCK()
create table t1 (a varchar(1024), b varchar(1024) as (is_used_lock(a))); create table t1 (a varchar(1024), b varchar(1024) as (is_used_lock(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# LAST_INSERT_ID() # LAST_INSERT_ID()
create table t1 (a int as (last_insert_id())); create table t1 (a int as (last_insert_id()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# MASTER_POS_WAIT() # MASTER_POS_WAIT()
create table t1 (a varchar(32), b int as (master_pos_wait(a,0,2))); create table t1 (a varchar(32), b int as (master_pos_wait(a,0,2)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# NAME_CONST() # NAME_CONST()
create table t1 (a varchar(32) as (name_const('test',1))); create table t1 (a varchar(32) as (name_const('test',1)));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# RELEASE_LOCK() # RELEASE_LOCK()
create table t1 (a varchar(32), b int as (release_lock(a))); create table t1 (a varchar(32), b int as (release_lock(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# ROW_COUNT() # ROW_COUNT()
create table t1 (a int as (row_count())); create table t1 (a int as (row_count()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# SCHEMA() # SCHEMA()
create table t1 (a varchar(32) as (schema())); create table t1 (a varchar(32) as (schema()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# SESSION_USER() # SESSION_USER()
create table t1 (a varchar(32) as (session_user())); create table t1 (a varchar(32) as (session_user()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# SLEEP() # SLEEP()
create table t1 (a int, b int as (sleep(a))); create table t1 (a int, b int as (sleep(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# SYSTEM_USER() # SYSTEM_USER()
create table t1 (a varchar(32) as (system_user())); create table t1 (a varchar(32) as (system_user()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# USER() # USER()
create table t1 (a varchar(1024), b varchar(1024) as (user())); create table t1 (a varchar(1024), b varchar(1024) as (user()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# UUID_SHORT() # UUID_SHORT()
create table t1 (a varchar(1024) as (uuid_short())); create table t1 (a varchar(1024) as (uuid_short()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# UUID() # UUID()
create table t1 (a varchar(1024) as (uuid())); create table t1 (a varchar(1024) as (uuid()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# VALUES() # VALUES()
create table t1 (a varchar(1024), b varchar(1024) as (values(a))); create table t1 (a varchar(1024), b varchar(1024) as (values(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# VERSION() # VERSION()
create table t1 (a varchar(1024), b varchar(1024) as (version())); create table t1 (a varchar(1024), b varchar(1024) as (version()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# ENCRYPT() # ENCRYPT()
create table t1 (a varchar(1024), b varchar(1024) as (encrypt(a))); create table t1 (a varchar(1024), b varchar(1024) as (encrypt(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# Stored procedures # Stored procedures
create procedure p1() create procedure p1()
begin begin
...@@ -137,77 +137,77 @@ begin ...@@ -137,77 +137,77 @@ begin
return 1; return 1;
end // end //
create table t1 (a int as (p1())); create table t1 (a int as (p1()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
create table t1 (a int as (f1())); create table t1 (a int as (f1()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
drop procedure p1; drop procedure p1;
drop function f1; drop function f1;
# Unknown functions # Unknown functions
create table t1 (a int as (f1())); create table t1 (a int as (f1()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# #
# GROUP BY FUNCTIONS # GROUP BY FUNCTIONS
# #
# AVG() # AVG()
create table t1 (a int, b int as (avg(a))); create table t1 (a int, b int as (avg(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# BIT_AND() # BIT_AND()
create table t1 (a int, b int as (bit_and(a))); create table t1 (a int, b int as (bit_and(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# BIT_OR() # BIT_OR()
create table t1 (a int, b int as (bit_or(a))); create table t1 (a int, b int as (bit_or(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# BIT_XOR() # BIT_XOR()
create table t1 (a int, b int as (bit_xor(a))); create table t1 (a int, b int as (bit_xor(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# COUNT(DISTINCT) # COUNT(DISTINCT)
create table t1 (a int, b int as (count(distinct a))); create table t1 (a int, b int as (count(distinct a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# COUNT() # COUNT()
create table t1 (a int, b int as (count(a))); create table t1 (a int, b int as (count(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# GROUP_CONCAT() # GROUP_CONCAT()
create table t1 (a varchar(32), b int as (group_concat(a,''))); create table t1 (a varchar(32), b int as (group_concat(a,'')));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# MAX() # MAX()
create table t1 (a int, b int as (max(a))); create table t1 (a int, b int as (max(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# MIN() # MIN()
create table t1 (a int, b int as (min(a))); create table t1 (a int, b int as (min(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# STD() # STD()
create table t1 (a int, b int as (std(a))); create table t1 (a int, b int as (std(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# STDDEV_POP() # STDDEV_POP()
create table t1 (a int, b int as (stddev_pop(a))); create table t1 (a int, b int as (stddev_pop(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# STDDEV_SAMP() # STDDEV_SAMP()
create table t1 (a int, b int as (stddev_samp(a))); create table t1 (a int, b int as (stddev_samp(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# STDDEV() # STDDEV()
create table t1 (a int, b int as (stddev(a))); create table t1 (a int, b int as (stddev(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# SUM() # SUM()
create table t1 (a int, b int as (sum(a))); create table t1 (a int, b int as (sum(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# VAR_POP() # VAR_POP()
create table t1 (a int, b int as (var_pop(a))); create table t1 (a int, b int as (var_pop(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# VAR_SAMP() # VAR_SAMP()
create table t1 (a int, b int as (var_samp(a))); create table t1 (a int, b int as (var_samp(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# VARIANCE() # VARIANCE()
create table t1 (a int, b int as (variance(a))); create table t1 (a int, b int as (variance(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# #
# XML FUNCTIONS # XML FUNCTIONS
# #
# ExtractValue() # ExtractValue()
create table t1 (a varchar(1024), b varchar(1024) as (ExtractValue(a,'//b[$@j]'))); create table t1 (a varchar(1024), b varchar(1024) as (ExtractValue(a,'//b[$@j]')));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# UpdateXML() # UpdateXML()
create table t1 (a varchar(1024), b varchar(1024) as (UpdateXML(a,'/a','<e>fff</e>'))); create table t1 (a varchar(1024), b varchar(1024) as (UpdateXML(a,'/a','<e>fff</e>')));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# #
# Sub-selects # Sub-selects
# #
...@@ -216,9 +216,9 @@ create table t2 (a int, b int as (select count(*) from t1)); ...@@ -216,9 +216,9 @@ create table t2 (a int, b int as (select count(*) from t1));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select count(*) from t1))' at line 1 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select count(*) from t1))' at line 1
drop table t1; drop table t1;
create table t1 (a int, b int as ((select 1))); create table t1 (a int, b int as ((select 1)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
create table t1 (a int, b int as (a+(select 1))); create table t1 (a int, b int as (a+(select 1)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# #
# SP functions # SP functions
# #
...@@ -229,7 +229,7 @@ select sub1(1); ...@@ -229,7 +229,7 @@ select sub1(1);
sub1(1) sub1(1)
2 2
create table t1 (a int, b int as (a+sub3(1))); create table t1 (a int, b int as (a+sub3(1)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
drop function sub1; drop function sub1;
# #
# Long expression # Long expression
...@@ -240,4 +240,4 @@ ERROR HY000: String 'concat(a,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ...@@ -240,4 +240,4 @@ ERROR HY000: String 'concat(a,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
# #
# Constant expression # Constant expression
create table t1 (a int as (PI())); create table t1 (a int as (PI()));
ERROR HY000: Constant expression in computed column function is not allowed. ERROR HY000: Constant expression in computed column function is not allowed
SET @@session.storage_engine = 'MyISAM'; SET @@session.storage_engine = 'MyISAM';
# RAND() # RAND()
create table t1 (b double as (rand())); create table t1 (b double as (rand()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# LOAD_FILE() # LOAD_FILE()
create table t1 (a varchar(64), b varchar(1024) as (load_file(a))); create table t1 (a varchar(64), b varchar(1024) as (load_file(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# CURDATE() # CURDATE()
create table t1 (a datetime as (curdate())); create table t1 (a datetime as (curdate()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# CURRENT_DATE(), CURRENT_DATE # CURRENT_DATE(), CURRENT_DATE
create table t1 (a datetime as (current_date)); create table t1 (a datetime as (current_date));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
create table t1 (a datetime as (current_date())); create table t1 (a datetime as (current_date()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# CURRENT_TIME(), CURRENT_TIME # CURRENT_TIME(), CURRENT_TIME
create table t1 (a datetime as (current_time)); create table t1 (a datetime as (current_time));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
create table t1 (a datetime as (current_time())); create table t1 (a datetime as (current_time()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP # CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP
create table t1 (a datetime as (current_timestamp())); create table t1 (a datetime as (current_timestamp()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
create table t1 (a datetime as (current_timestamp)); create table t1 (a datetime as (current_timestamp));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# CURTIME() # CURTIME()
create table t1 (a datetime as (curtime())); create table t1 (a datetime as (curtime()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# LOCALTIME(), LOCALTIME # LOCALTIME(), LOCALTIME
create table t1 (a datetime, b varchar(10) as (localtime())); create table t1 (a datetime, b varchar(10) as (localtime()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
create table t1 (a datetime, b varchar(10) as (localtime)); create table t1 (a datetime, b varchar(10) as (localtime));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# LOCALTIMESTAMP, LOCALTIMESTAMP()(v4.0.6) # LOCALTIMESTAMP, LOCALTIMESTAMP()(v4.0.6)
create table t1 (a datetime, b varchar(10) as (localtimestamp())); create table t1 (a datetime, b varchar(10) as (localtimestamp()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
create table t1 (a datetime, b varchar(10) as (localtimestamp)); create table t1 (a datetime, b varchar(10) as (localtimestamp));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# NOW() # NOW()
create table t1 (a datetime, b varchar(10) as (now())); create table t1 (a datetime, b varchar(10) as (now()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# SYSDATE() # SYSDATE()
create table t1 (a int, b varchar(10) as (sysdate())); create table t1 (a int, b varchar(10) as (sysdate()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# UNIX_TIMESTAMP() # UNIX_TIMESTAMP()
create table t1 (a datetime, b datetime as (unix_timestamp())); create table t1 (a datetime, b datetime as (unix_timestamp()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# UTC_DATE() # UTC_DATE()
create table t1 (a datetime, b datetime as (utc_date())); create table t1 (a datetime, b datetime as (utc_date()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# UTC_TIME() # UTC_TIME()
create table t1 (a datetime, b datetime as (utc_time())); create table t1 (a datetime, b datetime as (utc_time()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# UTC_TIMESTAMP() # UTC_TIMESTAMP()
create table t1 (a datetime, b datetime as (utc_timestamp())); create table t1 (a datetime, b datetime as (utc_timestamp()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# MATCH() # MATCH()
create table t1 (a varchar(32), b bool as (match a against ('sample text'))); create table t1 (a varchar(32), b bool as (match a against ('sample text')));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# BENCHMARK() # BENCHMARK()
create table t1 (a varchar(1024), b varchar(1024) as (benchmark(a,3))); create table t1 (a varchar(1024), b varchar(1024) as (benchmark(a,3)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# CONNECTION_ID() # CONNECTION_ID()
create table t1 (a int as (connection_id())); create table t1 (a int as (connection_id()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# CURRENT_USER(), CURRENT_USER # CURRENT_USER(), CURRENT_USER
create table t1 (a varchar(32) as (current_user())); create table t1 (a varchar(32) as (current_user()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
create table t1 (a varchar(32) as (current_user)); create table t1 (a varchar(32) as (current_user));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# DATABASE() # DATABASE()
create table t1 (a varchar(1024), b varchar(1024) as (database())); create table t1 (a varchar(1024), b varchar(1024) as (database()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# FOUND_ROWS() # FOUND_ROWS()
create table t1 (a varchar(1024), b varchar(1024) as (found_rows())); create table t1 (a varchar(1024), b varchar(1024) as (found_rows()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# GET_LOCK() # GET_LOCK()
create table t1 (a varchar(1024), b varchar(1024) as (get_lock(a,10))); create table t1 (a varchar(1024), b varchar(1024) as (get_lock(a,10)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# IS_FREE_LOCK() # IS_FREE_LOCK()
create table t1 (a varchar(1024), b varchar(1024) as (is_free_lock(a))); create table t1 (a varchar(1024), b varchar(1024) as (is_free_lock(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# IS_USED_LOCK() # IS_USED_LOCK()
create table t1 (a varchar(1024), b varchar(1024) as (is_used_lock(a))); create table t1 (a varchar(1024), b varchar(1024) as (is_used_lock(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# LAST_INSERT_ID() # LAST_INSERT_ID()
create table t1 (a int as (last_insert_id())); create table t1 (a int as (last_insert_id()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# MASTER_POS_WAIT() # MASTER_POS_WAIT()
create table t1 (a varchar(32), b int as (master_pos_wait(a,0,2))); create table t1 (a varchar(32), b int as (master_pos_wait(a,0,2)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# NAME_CONST() # NAME_CONST()
create table t1 (a varchar(32) as (name_const('test',1))); create table t1 (a varchar(32) as (name_const('test',1)));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# RELEASE_LOCK() # RELEASE_LOCK()
create table t1 (a varchar(32), b int as (release_lock(a))); create table t1 (a varchar(32), b int as (release_lock(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# ROW_COUNT() # ROW_COUNT()
create table t1 (a int as (row_count())); create table t1 (a int as (row_count()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# SCHEMA() # SCHEMA()
create table t1 (a varchar(32) as (schema())); create table t1 (a varchar(32) as (schema()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# SESSION_USER() # SESSION_USER()
create table t1 (a varchar(32) as (session_user())); create table t1 (a varchar(32) as (session_user()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# SLEEP() # SLEEP()
create table t1 (a int, b int as (sleep(a))); create table t1 (a int, b int as (sleep(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# SYSTEM_USER() # SYSTEM_USER()
create table t1 (a varchar(32) as (system_user())); create table t1 (a varchar(32) as (system_user()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# USER() # USER()
create table t1 (a varchar(1024), b varchar(1024) as (user())); create table t1 (a varchar(1024), b varchar(1024) as (user()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# UUID_SHORT() # UUID_SHORT()
create table t1 (a varchar(1024) as (uuid_short())); create table t1 (a varchar(1024) as (uuid_short()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# UUID() # UUID()
create table t1 (a varchar(1024) as (uuid())); create table t1 (a varchar(1024) as (uuid()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# VALUES() # VALUES()
create table t1 (a varchar(1024), b varchar(1024) as (values(a))); create table t1 (a varchar(1024), b varchar(1024) as (values(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# VERSION() # VERSION()
create table t1 (a varchar(1024), b varchar(1024) as (version())); create table t1 (a varchar(1024), b varchar(1024) as (version()));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# ENCRYPT() # ENCRYPT()
create table t1 (a varchar(1024), b varchar(1024) as (encrypt(a))); create table t1 (a varchar(1024), b varchar(1024) as (encrypt(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# Stored procedures # Stored procedures
create procedure p1() create procedure p1()
begin begin
...@@ -139,77 +139,77 @@ begin ...@@ -139,77 +139,77 @@ begin
return 1; return 1;
end // end //
create table t1 (a int as (p1())); create table t1 (a int as (p1()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
create table t1 (a int as (f1())); create table t1 (a int as (f1()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
drop procedure p1; drop procedure p1;
drop function f1; drop function f1;
# Unknown functions # Unknown functions
create table t1 (a int as (f1())); create table t1 (a int as (f1()));
ERROR HY000: Function or expression is not allowed for column 'a'. ERROR HY000: Function or expression is not allowed for column 'a'
# #
# GROUP BY FUNCTIONS # GROUP BY FUNCTIONS
# #
# AVG() # AVG()
create table t1 (a int, b int as (avg(a))); create table t1 (a int, b int as (avg(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# BIT_AND() # BIT_AND()
create table t1 (a int, b int as (bit_and(a))); create table t1 (a int, b int as (bit_and(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# BIT_OR() # BIT_OR()
create table t1 (a int, b int as (bit_or(a))); create table t1 (a int, b int as (bit_or(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# BIT_XOR() # BIT_XOR()
create table t1 (a int, b int as (bit_xor(a))); create table t1 (a int, b int as (bit_xor(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# COUNT(DISTINCT) # COUNT(DISTINCT)
create table t1 (a int, b int as (count(distinct a))); create table t1 (a int, b int as (count(distinct a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# COUNT() # COUNT()
create table t1 (a int, b int as (count(a))); create table t1 (a int, b int as (count(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# GROUP_CONCAT() # GROUP_CONCAT()
create table t1 (a varchar(32), b int as (group_concat(a,''))); create table t1 (a varchar(32), b int as (group_concat(a,'')));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# MAX() # MAX()
create table t1 (a int, b int as (max(a))); create table t1 (a int, b int as (max(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# MIN() # MIN()
create table t1 (a int, b int as (min(a))); create table t1 (a int, b int as (min(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# STD() # STD()
create table t1 (a int, b int as (std(a))); create table t1 (a int, b int as (std(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# STDDEV_POP() # STDDEV_POP()
create table t1 (a int, b int as (stddev_pop(a))); create table t1 (a int, b int as (stddev_pop(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# STDDEV_SAMP() # STDDEV_SAMP()
create table t1 (a int, b int as (stddev_samp(a))); create table t1 (a int, b int as (stddev_samp(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# STDDEV() # STDDEV()
create table t1 (a int, b int as (stddev(a))); create table t1 (a int, b int as (stddev(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# SUM() # SUM()
create table t1 (a int, b int as (sum(a))); create table t1 (a int, b int as (sum(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# VAR_POP() # VAR_POP()
create table t1 (a int, b int as (var_pop(a))); create table t1 (a int, b int as (var_pop(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# VAR_SAMP() # VAR_SAMP()
create table t1 (a int, b int as (var_samp(a))); create table t1 (a int, b int as (var_samp(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# VARIANCE() # VARIANCE()
create table t1 (a int, b int as (variance(a))); create table t1 (a int, b int as (variance(a)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# #
# XML FUNCTIONS # XML FUNCTIONS
# #
# ExtractValue() # ExtractValue()
create table t1 (a varchar(1024), b varchar(1024) as (ExtractValue(a,'//b[$@j]'))); create table t1 (a varchar(1024), b varchar(1024) as (ExtractValue(a,'//b[$@j]')));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# UpdateXML() # UpdateXML()
create table t1 (a varchar(1024), b varchar(1024) as (UpdateXML(a,'/a','<e>fff</e>'))); create table t1 (a varchar(1024), b varchar(1024) as (UpdateXML(a,'/a','<e>fff</e>')));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# #
# Sub-selects # Sub-selects
# #
...@@ -218,9 +218,9 @@ create table t2 (a int, b int as (select count(*) from t1)); ...@@ -218,9 +218,9 @@ create table t2 (a int, b int as (select count(*) from t1));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select count(*) from t1))' at line 1 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select count(*) from t1))' at line 1
drop table t1; drop table t1;
create table t1 (a int, b int as ((select 1))); create table t1 (a int, b int as ((select 1)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
create table t1 (a int, b int as (a+(select 1))); create table t1 (a int, b int as (a+(select 1)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
# #
# SP functions # SP functions
# #
...@@ -231,7 +231,7 @@ select sub1(1); ...@@ -231,7 +231,7 @@ select sub1(1);
sub1(1) sub1(1)
2 2
create table t1 (a int, b int as (a+sub3(1))); create table t1 (a int, b int as (a+sub3(1)));
ERROR HY000: Function or expression is not allowed for column 'b'. ERROR HY000: Function or expression is not allowed for column 'b'
drop function sub1; drop function sub1;
# #
# Long expression # Long expression
...@@ -242,4 +242,4 @@ ERROR HY000: String 'concat(a,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ...@@ -242,4 +242,4 @@ ERROR HY000: String 'concat(a,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
# #
# Constant expression # Constant expression
create table t1 (a int as (PI())); create table t1 (a int as (PI()));
ERROR HY000: Constant expression in computed column function is not allowed. ERROR HY000: Constant expression in computed column function is not allowed
SET @@session.storage_engine = 'CSV'; SET @@session.storage_engine = 'CSV';
create table t1 (a int, b int as (a+1)); create table t1 (a int, b int as (a+1));
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns. ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
create table t1 (a int not null); create table t1 (a int not null);
alter table t1 add column b int as (a+1); alter table t1 add column b int as (a+1);
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns. ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
drop table t1; drop table t1;
...@@ -25,8 +25,8 @@ a b c ...@@ -25,8 +25,8 @@ a b c
# INSERT INTO tbl_name VALUES... a non-NULL value is specified against vcols # INSERT INTO tbl_name VALUES... a non-NULL value is specified against vcols
insert into t1 values (1,2,3); insert into t1 values (1,2,3);
Warnings: Warnings:
Warning 1645 The value specified for computed column 'b' in table 't1' ignored. Warning 1645 The value specified for computed column 'b' in table 't1' ignored
Warning 1645 The value specified for computed column 'c' in table 't1' ignored. Warning 1645 The value specified for computed column 'c' in table 't1' ignored
select * from t1; select * from t1;
a b c a b c
1 -1 -1 1 -1 -1
...@@ -65,8 +65,8 @@ a b c ...@@ -65,8 +65,8 @@ a b c
# against vcols # against vcols
insert into t1 (a,b) values (1,3), (2,4); insert into t1 (a,b) values (1,3), (2,4);
Warnings: Warnings:
Warning 1645 The value specified for computed column 'b' in table 't1' ignored. Warning 1645 The value specified for computed column 'b' in table 't1' ignored
Warning 1645 The value specified for computed column 'b' in table 't1' ignored. Warning 1645 The value specified for computed column 'b' in table 't1' ignored
select * from t1; select * from t1;
a b c a b c
1 -1 -1 1 -1 -1
...@@ -107,8 +107,8 @@ a b c ...@@ -107,8 +107,8 @@ a b c
create table t2 like t1; create table t2 like t1;
insert into t2 select * from t1; insert into t2 select * from t1;
Warnings: Warnings:
Warning 1645 The value specified for computed column 'b' in table 't2' ignored. Warning 1645 The value specified for computed column 'b' in table 't2' ignored
Warning 1645 The value specified for computed column 'c' in table 't2' ignored. Warning 1645 The value specified for computed column 'c' in table 't2' ignored
select * from t1; select * from t1;
a b c a b c
2 -2 -2 2 -2 -2
...@@ -123,8 +123,8 @@ a b c ...@@ -123,8 +123,8 @@ a b c
create table t2 like t1; create table t2 like t1;
insert into t2 (a,b) select a,b from t1; insert into t2 (a,b) select a,b from t1;
Warnings: Warnings:
Warning 1645 The value specified for computed column 'b' in table 't2' ignored. Warning 1645 The value specified for computed column 'b' in table 't2' ignored
Warning 1645 The value specified for computed column 'b' in table 't2' ignored. Warning 1645 The value specified for computed column 'b' in table 't2' ignored
select * from t2; select * from t2;
a b c a b c
2 -2 -2 2 -2 -2
...@@ -159,7 +159,7 @@ a b c ...@@ -159,7 +159,7 @@ a b c
2 -2 -2 2 -2 -2
update t1 set c=3 where a=2; update t1 set c=3 where a=2;
Warnings: Warnings:
Warning 1645 The value specified for computed column 'c' in table 't1' ignored. Warning 1645 The value specified for computed column 'c' in table 't1' ignored
select * from t1; select * from t1;
a b c a b c
1 -1 -1 1 -1 -1
...@@ -189,7 +189,7 @@ a b c ...@@ -189,7 +189,7 @@ a b c
2 -2 -2 2 -2 -2
update t1 set c=3 where b=-2; update t1 set c=3 where b=-2;
Warnings: Warnings:
Warning 1645 The value specified for computed column 'c' in table 't1' ignored. Warning 1645 The value specified for computed column 'c' in table 't1' ignored
select * from t1; select * from t1;
a b c a b c
1 -1 -1 1 -1 -1
......
...@@ -25,8 +25,8 @@ a b c ...@@ -25,8 +25,8 @@ a b c
# INSERT INTO tbl_name VALUES... a non-NULL value is specified against vcols # INSERT INTO tbl_name VALUES... a non-NULL value is specified against vcols
insert into t1 values (1,2,3); insert into t1 values (1,2,3);
Warnings: Warnings:
Warning 1645 The value specified for computed column 'b' in table 't1' ignored. Warning 1645 The value specified for computed column 'b' in table 't1' ignored
Warning 1645 The value specified for computed column 'c' in table 't1' ignored. Warning 1645 The value specified for computed column 'c' in table 't1' ignored
select * from t1; select * from t1;
a b c a b c
1 -1 -1 1 -1 -1
...@@ -65,8 +65,8 @@ a b c ...@@ -65,8 +65,8 @@ a b c
# against vcols # against vcols
insert into t1 (a,b) values (1,3), (2,4); insert into t1 (a,b) values (1,3), (2,4);
Warnings: Warnings:
Warning 1645 The value specified for computed column 'b' in table 't1' ignored. Warning 1645 The value specified for computed column 'b' in table 't1' ignored
Warning 1645 The value specified for computed column 'b' in table 't1' ignored. Warning 1645 The value specified for computed column 'b' in table 't1' ignored
select * from t1; select * from t1;
a b c a b c
1 -1 -1 1 -1 -1
...@@ -107,8 +107,8 @@ a b c ...@@ -107,8 +107,8 @@ a b c
create table t2 like t1; create table t2 like t1;
insert into t2 select * from t1; insert into t2 select * from t1;
Warnings: Warnings:
Warning 1645 The value specified for computed column 'b' in table 't2' ignored. Warning 1645 The value specified for computed column 'b' in table 't2' ignored
Warning 1645 The value specified for computed column 'c' in table 't2' ignored. Warning 1645 The value specified for computed column 'c' in table 't2' ignored
select * from t1; select * from t1;
a b c a b c
2 -2 -2 2 -2 -2
...@@ -123,8 +123,8 @@ a b c ...@@ -123,8 +123,8 @@ a b c
create table t2 like t1; create table t2 like t1;
insert into t2 (a,b) select a,b from t1; insert into t2 (a,b) select a,b from t1;
Warnings: Warnings:
Warning 1645 The value specified for computed column 'b' in table 't2' ignored. Warning 1645 The value specified for computed column 'b' in table 't2' ignored
Warning 1645 The value specified for computed column 'b' in table 't2' ignored. Warning 1645 The value specified for computed column 'b' in table 't2' ignored
select * from t2; select * from t2;
a b c a b c
2 -2 -2 2 -2 -2
...@@ -159,7 +159,7 @@ a b c ...@@ -159,7 +159,7 @@ a b c
2 -2 -2 2 -2 -2
update t1 set c=3 where a=2; update t1 set c=3 where a=2;
Warnings: Warnings:
Warning 1645 The value specified for computed column 'c' in table 't1' ignored. Warning 1645 The value specified for computed column 'c' in table 't1' ignored
select * from t1; select * from t1;
a b c a b c
1 -1 -1 1 -1 -1
...@@ -189,7 +189,7 @@ a b c ...@@ -189,7 +189,7 @@ a b c
2 -2 -2 2 -2 -2
update t1 set c=3 where b=-2; update t1 set c=3 where b=-2;
Warnings: Warnings:
Warning 1645 The value specified for computed column 'c' in table 't1' ignored. Warning 1645 The value specified for computed column 'c' in table 't1' ignored
select * from t1; select * from t1;
a b c a b c
1 -1 -1 1 -1 -1
......
...@@ -7,7 +7,7 @@ SET @@session.storage_engine = 'InnoDB'; ...@@ -7,7 +7,7 @@ SET @@session.storage_engine = 'InnoDB';
# - CHECK (allowed but not used) # - CHECK (allowed but not used)
# UNIQUE # UNIQUE
create table t1 (a int, b int as (a*2) unique); create table t1 (a int, b int as (a*2) unique);
ERROR HY000: Key/Index cannot be defined on a non-stored computed column. ERROR HY000: Key/Index cannot be defined on a non-stored computed column
create table t1 (a int, b int as (a*2) persistent unique); create table t1 (a int, b int as (a*2) persistent unique);
show create table t1; show create table t1;
Table Create Table Table Create Table
...@@ -22,7 +22,7 @@ a int(11) YES NULL ...@@ -22,7 +22,7 @@ a int(11) YES NULL
b int(11) YES UNI NULL VIRTUAL b int(11) YES UNI NULL VIRTUAL
drop table t1; drop table t1;
create table t1 (a int, b int as (a*2), unique key (b)); create table t1 (a int, b int as (a*2), unique key (b));
ERROR HY000: Key/Index cannot be defined on a non-stored computed column. ERROR HY000: Key/Index cannot be defined on a non-stored computed column
create table t1 (a int, b int as (a*2) persistent, unique (b)); create table t1 (a int, b int as (a*2) persistent, unique (b));
show create table t1; show create table t1;
Table Create Table Table Create Table
...@@ -38,7 +38,7 @@ b int(11) YES UNI NULL VIRTUAL ...@@ -38,7 +38,7 @@ b int(11) YES UNI NULL VIRTUAL
drop table t1; drop table t1;
create table t1 (a int, b int as (a*2)); create table t1 (a int, b int as (a*2));
alter table t1 add unique key (b); alter table t1 add unique key (b);
ERROR HY000: Key/Index cannot be defined on a non-stored computed column. ERROR HY000: Key/Index cannot be defined on a non-stored computed column
drop table t1; drop table t1;
create table t1 (a int, b int as (a*2) persistent); create table t1 (a int, b int as (a*2) persistent);
alter table t1 add unique key (b); alter table t1 add unique key (b);
...@@ -50,9 +50,9 @@ drop table t1; ...@@ -50,9 +50,9 @@ drop table t1;
# #
# INDEX # INDEX
create table t1 (a int, b int as (a*2), index (b)); create table t1 (a int, b int as (a*2), index (b));
ERROR HY000: Key/Index cannot be defined on a non-stored computed column. ERROR HY000: Key/Index cannot be defined on a non-stored computed column
create table t1 (a int, b int as (a*2), index (a,b)); create table t1 (a int, b int as (a*2), index (a,b));
ERROR HY000: Key/Index cannot be defined on a non-stored computed column. ERROR HY000: Key/Index cannot be defined on a non-stored computed column
create table t1 (a int, b int as (a*2) persistent, index (b)); create table t1 (a int, b int as (a*2) persistent, index (b));
show create table t1; show create table t1;
Table Create Table Table Create Table
...@@ -81,9 +81,9 @@ b int(11) YES NULL VIRTUAL ...@@ -81,9 +81,9 @@ b int(11) YES NULL VIRTUAL
drop table t1; drop table t1;
create table t1 (a int, b int as (a*2)); create table t1 (a int, b int as (a*2));
alter table t1 add index (b); alter table t1 add index (b);
ERROR HY000: Key/Index cannot be defined on a non-stored computed column. ERROR HY000: Key/Index cannot be defined on a non-stored computed column
alter table t1 add index (a,b); alter table t1 add index (a,b);
ERROR HY000: Key/Index cannot be defined on a non-stored computed column. ERROR HY000: Key/Index cannot be defined on a non-stored computed column
drop table t1; drop table t1;
create table t1 (a int, b int as (a*2) persistent); create table t1 (a int, b int as (a*2) persistent);
alter table t1 add index (b); alter table t1 add index (b);
...@@ -103,27 +103,27 @@ drop table t1; ...@@ -103,27 +103,27 @@ drop table t1;
# Rejected FK options. # Rejected FK options.
create table t1 (a int, b int as (a+1) persistent, create table t1 (a int, b int as (a+1) persistent,
foreign key (b) references t2(a) on update set null); foreign key (b) references t2(a) on update set null);
ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a computed column. ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a computed column
create table t1 (a int, b int as (a+1) persistent, create table t1 (a int, b int as (a+1) persistent,
foreign key (b) references t2(a) on update cascade); foreign key (b) references t2(a) on update cascade);
ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a computed column. ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a computed column
create table t1 (a int, b int as (a+1) persistent, create table t1 (a int, b int as (a+1) persistent,
foreign key (b) references t2(a) on delete set null); foreign key (b) references t2(a) on delete set null);
ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a computed column. ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a computed column
create table t1 (a int, b int as (a+1) persistent); create table t1 (a int, b int as (a+1) persistent);
alter table t1 add foreign key (b) references t2(a) on update set null; alter table t1 add foreign key (b) references t2(a) on update set null;
ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a computed column. ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a computed column
alter table t1 add foreign key (b) references t2(a) on update cascade; alter table t1 add foreign key (b) references t2(a) on update cascade;
ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a computed column. ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a computed column
alter table t1 add foreign key (b) references t2(a) on delete set null; alter table t1 add foreign key (b) references t2(a) on delete set null;
ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a computed column. ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a computed column
drop table t1; drop table t1;
create table t1 (a int, b int as (a+1), create table t1 (a int, b int as (a+1),
foreign key (b) references t2(a)); foreign key (b) references t2(a));
ERROR HY000: Key/Index cannot be defined on a non-stored computed column. ERROR HY000: Key/Index cannot be defined on a non-stored computed column
create table t1 (a int, b int as (a+1)); create table t1 (a int, b int as (a+1));
alter table t1 add foreign key (b) references t2(a); alter table t1 add foreign key (b) references t2(a);
ERROR HY000: Key/Index cannot be defined on a non-stored computed column. ERROR HY000: Key/Index cannot be defined on a non-stored computed column
drop table t1; drop table t1;
# Allowed FK options. # Allowed FK options.
create table t2 (a int primary key, b char(5)); create table t2 (a int primary key, b char(5));
......
...@@ -7,7 +7,7 @@ SET @@session.storage_engine = 'MyISAM'; ...@@ -7,7 +7,7 @@ SET @@session.storage_engine = 'MyISAM';
# - CHECK (allowed but not used) # - CHECK (allowed but not used)
# UNIQUE # UNIQUE
create table t1 (a int, b int as (a*2) unique); create table t1 (a int, b int as (a*2) unique);
ERROR HY000: Key/Index cannot be defined on a non-stored computed column. ERROR HY000: Key/Index cannot be defined on a non-stored computed column
create table t1 (a int, b int as (a*2) persistent unique); create table t1 (a int, b int as (a*2) persistent unique);
show create table t1; show create table t1;
Table Create Table Table Create Table
...@@ -22,7 +22,7 @@ a int(11) YES NULL ...@@ -22,7 +22,7 @@ a int(11) YES NULL
b int(11) YES UNI NULL VIRTUAL b int(11) YES UNI NULL VIRTUAL
drop table t1; drop table t1;
create table t1 (a int, b int as (a*2), unique key (b)); create table t1 (a int, b int as (a*2), unique key (b));
ERROR HY000: Key/Index cannot be defined on a non-stored computed column. ERROR HY000: Key/Index cannot be defined on a non-stored computed column
create table t1 (a int, b int as (a*2) persistent, unique (b)); create table t1 (a int, b int as (a*2) persistent, unique (b));
show create table t1; show create table t1;
Table Create Table Table Create Table
...@@ -38,7 +38,7 @@ b int(11) YES UNI NULL VIRTUAL ...@@ -38,7 +38,7 @@ b int(11) YES UNI NULL VIRTUAL
drop table t1; drop table t1;
create table t1 (a int, b int as (a*2)); create table t1 (a int, b int as (a*2));
alter table t1 add unique key (b); alter table t1 add unique key (b);
ERROR HY000: Key/Index cannot be defined on a non-stored computed column. ERROR HY000: Key/Index cannot be defined on a non-stored computed column
drop table t1; drop table t1;
create table t1 (a int, b int as (a*2) persistent); create table t1 (a int, b int as (a*2) persistent);
alter table t1 add unique key (b); alter table t1 add unique key (b);
...@@ -50,9 +50,9 @@ drop table t1; ...@@ -50,9 +50,9 @@ drop table t1;
# #
# INDEX # INDEX
create table t1 (a int, b int as (a*2), index (b)); create table t1 (a int, b int as (a*2), index (b));
ERROR HY000: Key/Index cannot be defined on a non-stored computed column. ERROR HY000: Key/Index cannot be defined on a non-stored computed column
create table t1 (a int, b int as (a*2), index (a,b)); create table t1 (a int, b int as (a*2), index (a,b));
ERROR HY000: Key/Index cannot be defined on a non-stored computed column. ERROR HY000: Key/Index cannot be defined on a non-stored computed column
create table t1 (a int, b int as (a*2) persistent, index (b)); create table t1 (a int, b int as (a*2) persistent, index (b));
show create table t1; show create table t1;
Table Create Table Table Create Table
...@@ -81,9 +81,9 @@ b int(11) YES NULL VIRTUAL ...@@ -81,9 +81,9 @@ b int(11) YES NULL VIRTUAL
drop table t1; drop table t1;
create table t1 (a int, b int as (a*2)); create table t1 (a int, b int as (a*2));
alter table t1 add index (b); alter table t1 add index (b);
ERROR HY000: Key/Index cannot be defined on a non-stored computed column. ERROR HY000: Key/Index cannot be defined on a non-stored computed column
alter table t1 add index (a,b); alter table t1 add index (a,b);
ERROR HY000: Key/Index cannot be defined on a non-stored computed column. ERROR HY000: Key/Index cannot be defined on a non-stored computed column
drop table t1; drop table t1;
create table t1 (a int, b int as (a*2) persistent); create table t1 (a int, b int as (a*2) persistent);
alter table t1 add index (b); alter table t1 add index (b);
...@@ -110,27 +110,27 @@ drop table t1; ...@@ -110,27 +110,27 @@ drop table t1;
# Rejected FK options. # Rejected FK options.
create table t1 (a int, b int as (a+1) persistent, create table t1 (a int, b int as (a+1) persistent,
foreign key (b) references t2(a) on update set null); foreign key (b) references t2(a) on update set null);
ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a computed column. ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a computed column
create table t1 (a int, b int as (a+1) persistent, create table t1 (a int, b int as (a+1) persistent,
foreign key (b) references t2(a) on update cascade); foreign key (b) references t2(a) on update cascade);
ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a computed column. ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a computed column
create table t1 (a int, b int as (a+1) persistent, create table t1 (a int, b int as (a+1) persistent,
foreign key (b) references t2(a) on delete set null); foreign key (b) references t2(a) on delete set null);
ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a computed column. ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a computed column
create table t1 (a int, b int as (a+1) persistent); create table t1 (a int, b int as (a+1) persistent);
alter table t1 add foreign key (b) references t2(a) on update set null; alter table t1 add foreign key (b) references t2(a) on update set null;
ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a computed column. ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a computed column
alter table t1 add foreign key (b) references t2(a) on update cascade; alter table t1 add foreign key (b) references t2(a) on update cascade;
ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a computed column. ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a computed column
alter table t1 add foreign key (b) references t2(a) on delete set null; alter table t1 add foreign key (b) references t2(a) on delete set null;
ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a computed column. ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a computed column
drop table t1; drop table t1;
create table t1 (a int, b int as (a+1), create table t1 (a int, b int as (a+1),
foreign key (b) references t2(a)); foreign key (b) references t2(a));
ERROR HY000: Key/Index cannot be defined on a non-stored computed column. ERROR HY000: Key/Index cannot be defined on a non-stored computed column
create table t1 (a int, b int as (a+1)); create table t1 (a int, b int as (a+1));
alter table t1 add foreign key (b) references t2(a); alter table t1 add foreign key (b) references t2(a);
ERROR HY000: Key/Index cannot be defined on a non-stored computed column. ERROR HY000: Key/Index cannot be defined on a non-stored computed column
drop table t1; drop table t1;
# Allowed FK options. # Allowed FK options.
create table t2 (a int primary key, b char(5)); create table t2 (a int primary key, b char(5));
......
SET @@session.storage_engine = 'memory'; SET @@session.storage_engine = 'memory';
create table t1 (a int, b int as (a+1)); create table t1 (a int, b int as (a+1));
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns. ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
create table t1 (a int); create table t1 (a int);
alter table t1 add column b int as (a+1); alter table t1 add column b int as (a+1);
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns. ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
drop table t1; drop table t1;
...@@ -4,5 +4,5 @@ create table t2 (a int, b int as (a % 10)); ...@@ -4,5 +4,5 @@ create table t2 (a int, b int as (a % 10));
insert into t1 values (1,default); insert into t1 values (1,default);
insert into t2 values (2,default); insert into t2 values (2,default);
create table t3 (a int, b int as (a % 10)) engine=MERGE UNION=(t1,t2); create table t3 (a int, b int as (a % 10)) engine=MERGE UNION=(t1,t2);
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns. ERROR HY000: 'Specified storage engine' is not yet supported for computed columns
drop table t1,t2; drop table t1,t2;
...@@ -30,3 +30,8 @@ a b v ...@@ -30,3 +30,8 @@ a b v
5 50 6 5 50 6
8 80 9 8 80 9
drop table t1; drop table t1;
CREATE TABLE t1 (
a int NOT NULL DEFAULT '0',
v double AS ((1, a)) VIRTUAL
);
ERROR HY000: Expression for computed column cannot return a row
...@@ -76,7 +76,7 @@ drop table t1; ...@@ -76,7 +76,7 @@ drop table t1;
# Case 7. ALTER. Modify virtual stored -> virtual non-stored # Case 7. ALTER. Modify virtual stored -> virtual non-stored
create table t1 (a int, b int as (a % 2) persistent); create table t1 (a int, b int as (a % 2) persistent);
alter table t1 modify b int as (a % 2); alter table t1 modify b int as (a % 2);
ERROR HY000: 'Changing the STORED status' is not yet supported for computed columns. ERROR HY000: 'Changing the STORED status' is not yet supported for computed columns
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -87,7 +87,7 @@ drop table t1; ...@@ -87,7 +87,7 @@ drop table t1;
# Case 8. ALTER. Modify virtual non-stored -> virtual stored # Case 8. ALTER. Modify virtual non-stored -> virtual stored
create table t1 (a int, b int as (a % 2)); create table t1 (a int, b int as (a % 2));
alter table t1 modify b int as (a % 2) persistent; alter table t1 modify b int as (a % 2) persistent;
ERROR HY000: 'Changing the STORED status' is not yet supported for computed columns. ERROR HY000: 'Changing the STORED status' is not yet supported for computed columns
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
......
...@@ -76,7 +76,7 @@ drop table t1; ...@@ -76,7 +76,7 @@ drop table t1;
# Case 7. ALTER. Modify virtual stored -> virtual non-stored # Case 7. ALTER. Modify virtual stored -> virtual non-stored
create table t1 (a int, b int as (a % 2) persistent); create table t1 (a int, b int as (a % 2) persistent);
alter table t1 modify b int as (a % 2); alter table t1 modify b int as (a % 2);
ERROR HY000: 'Changing the STORED status' is not yet supported for computed columns. ERROR HY000: 'Changing the STORED status' is not yet supported for computed columns
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -87,7 +87,7 @@ drop table t1; ...@@ -87,7 +87,7 @@ drop table t1;
# Case 8. ALTER. Modify virtual non-stored -> virtual stored # Case 8. ALTER. Modify virtual non-stored -> virtual stored
create table t1 (a int, b int as (a % 2)); create table t1 (a int, b int as (a % 2));
alter table t1 modify b int as (a % 2) persistent; alter table t1 modify b int as (a % 2) persistent;
ERROR HY000: 'Changing the STORED status' is not yet supported for computed columns. ERROR HY000: 'Changing the STORED status' is not yet supported for computed columns
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
......
...@@ -19,3 +19,17 @@ update t1 set a=v order by b limit 1; ...@@ -19,3 +19,17 @@ update t1 set a=v order by b limit 1;
select * from t1 order by b; select * from t1 order by b;
drop table t1; drop table t1;
#
# Bug#604549: Expression for virtual column returns row
#
-- error ER_ROW_EXPR_FOR_VCOL
CREATE TABLE t1 (
a int NOT NULL DEFAULT '0',
v double AS ((1, a)) VIRTUAL
);
...@@ -6211,28 +6211,31 @@ ER_VCOL_BASED_ON_VCOL ...@@ -6211,28 +6211,31 @@ 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 is not allowed for column '%s'." eng "Function or expression is not allowed for column '%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
eng "Primary key cannot be defined upon a computed column." eng "Primary key cannot be defined upon a computed column"
ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
eng "Key/Index cannot be defined on a non-stored computed column." eng "Key/Index cannot be defined on a non-stored computed column"
ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN
eng "Cannot define foreign key with %s clause on a computed column." eng "Cannot define foreign key with %s clause on a computed column"
ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN
eng "The value specified for computed column '%s' in table '%s' ignored." eng "The value specified for computed column '%s' in table '%s' ignored"
ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
eng "'%s' is not yet supported for computed columns." eng "'%s' is not yet supported for computed columns"
ER_CONST_EXPR_IN_VCOL ER_CONST_EXPR_IN_VCOL
eng "Constant expression in computed column function is not allowed." eng "Constant expression in computed column function is not allowed"
ER_ROW_EXPR_FOR_VCOL
eng "Expression for computed column cannot return a row"
ER_DEBUG_SYNC_TIMEOUT ER_DEBUG_SYNC_TIMEOUT
eng "debug sync point wait timed out" eng "debug sync point wait timed out"
......
...@@ -1859,6 +1859,11 @@ bool fix_vcol_expr(THD *thd, ...@@ -1859,6 +1859,11 @@ bool fix_vcol_expr(THD *thd,
goto end; goto end;
} }
thd->where= save_where; thd->where= save_where;
if (unlikely(func_expr->result_type() == ROW_RESULT))
{
my_error(ER_ROW_EXPR_FOR_VCOL, MYF(0));
goto end;
}
#ifdef PARANOID #ifdef PARANOID
/* /*
Walk through the Item tree checking if all items are valid Walk through the Item tree checking if all items are valid
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment