Commit bc013072 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 2aeaf76b
...@@ -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 = '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