mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fixed bug mdev-354.
Virtual columns of ENUM and SET data types were not supported properly in the original patch that introduced virtual columns into MariaDB 5.2. The problem was that for any virtual column the patch used the interval_id field of the definition of the column in the frm file as a reference to the virtual column expression. The fix stores the optional interval_id of the virtual column in the extended header of the virtual column expression.
This commit is contained in:
@ -146,3 +146,39 @@ table_schema table_name column_name column_type extra
|
||||
test t2 a int(11)
|
||||
test t2 b int(11) VIRTUAL
|
||||
DROP TABLE t1,t2;
|
||||
create table t1 (
|
||||
a int not null, b char(2) not null,
|
||||
c enum('Y','N') as (case when b = 'aa' then 'Y' else 'N' end) persistent
|
||||
);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL,
|
||||
`b` char(2) NOT NULL,
|
||||
`c` enum('Y','N') AS (case when b = 'aa' then 'Y' else 'N' end) PERSISTENT
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
insert into t1(a,b) values (1,'bb'), (2,'aa'), (3,'cc');
|
||||
select * from t1;
|
||||
a b c
|
||||
1 bb N
|
||||
2 aa Y
|
||||
3 cc N
|
||||
create table t2 (
|
||||
a int, b int,
|
||||
c set("y","n")
|
||||
as (if(a=0,if(b=0,('n,n'),('n,y')),if(b=0,('y,n'),('y,y')))) persistent
|
||||
);
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) DEFAULT NULL,
|
||||
`c` set('y','n') AS (if(a=0,if(b=0,('n,n'),('n,y')),if(b=0,('y,n'),('y,y')))) PERSISTENT
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
insert into t2(a,b) values (7,0), (2,3), (0,1);
|
||||
select * from t2;
|
||||
a b c
|
||||
7 0 y,n
|
||||
2 3 y
|
||||
0 1 y,n
|
||||
drop table t1,t2;
|
||||
|
@ -154,3 +154,27 @@ SELECT table_schema, table_name, column_name, column_type, extra
|
||||
FROM information_schema.columns WHERE table_name = 't2';
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
|
||||
#
|
||||
# Bug mdev-354: virtual columns of ENUM and SET types
|
||||
#
|
||||
|
||||
create table t1 (
|
||||
a int not null, b char(2) not null,
|
||||
c enum('Y','N') as (case when b = 'aa' then 'Y' else 'N' end) persistent
|
||||
);
|
||||
show create table t1;
|
||||
insert into t1(a,b) values (1,'bb'), (2,'aa'), (3,'cc');
|
||||
select * from t1;
|
||||
|
||||
create table t2 (
|
||||
a int, b int,
|
||||
c set("y","n")
|
||||
as (if(a=0,if(b=0,('n,n'),('n,y')),if(b=0,('y,n'),('y,y')))) persistent
|
||||
);
|
||||
show create table t2;
|
||||
insert into t2(a,b) values (7,0), (2,3), (0,1);
|
||||
select * from t2;
|
||||
|
||||
drop table t1,t2;
|
||||
|
Reference in New Issue
Block a user