summaryrefslogtreecommitdiff
path: root/mysql-test/suite
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2012-06-18 22:32:17 -0700
committerIgor Babaev <igor@askmonty.org>2012-06-18 22:32:17 -0700
commit0c69f22032abd6f162829ee31c5ee7d34b84e107 (patch)
treee524ff3959bfbe1bb63324a8cbcb01c6087909d4 /mysql-test/suite
parent64aa1fcb1354ffa24999a1512258c897116b0928 (diff)
downloadmariadb-git-0c69f22032abd6f162829ee31c5ee7d34b84e107.tar.gz
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.
Diffstat (limited to 'mysql-test/suite')
-rw-r--r--mysql-test/suite/vcol/r/vcol_misc.result36
-rw-r--r--mysql-test/suite/vcol/t/vcol_misc.test24
2 files changed, 60 insertions, 0 deletions
diff --git a/mysql-test/suite/vcol/r/vcol_misc.result b/mysql-test/suite/vcol/r/vcol_misc.result
index d5061fa4d5f..a4b2cee4bf6 100644
--- a/mysql-test/suite/vcol/r/vcol_misc.result
+++ b/mysql-test/suite/vcol/r/vcol_misc.result
@@ -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;
diff --git a/mysql-test/suite/vcol/t/vcol_misc.test b/mysql-test/suite/vcol/t/vcol_misc.test
index 495432fdb4c..732003da992 100644
--- a/mysql-test/suite/vcol/t/vcol_misc.test
+++ b/mysql-test/suite/vcol/t/vcol_misc.test
@@ -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;