summaryrefslogtreecommitdiff
path: root/mysql-test/t/create.test
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2014-11-08 19:54:42 +0100
committerSergei Golubchik <sergii@pisem.net>2014-11-08 19:54:42 +0100
commit360c49c1b92ac0a7eb4895da376ec8d53f25fc72 (patch)
tree6368fe2415c0a457330080e17bfe1dc514695aa0 /mysql-test/t/create.test
parentb99328bbf8f46c1e2892b7912392727cbab7c476 (diff)
downloadmariadb-git-360c49c1b92ac0a7eb4895da376ec8d53f25fc72.tar.gz
MDEV-6179: dynamic columns functions/cast()/convert() doesn't play nice with CREATE/ALTER TABLE
When parsing a field declaration, grab type information from LEX before it's overwritten by further rules. Pass type information through the parser stack to the rule that needs it.
Diffstat (limited to 'mysql-test/t/create.test')
-rw-r--r--mysql-test/t/create.test32
1 files changed, 32 insertions, 0 deletions
diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test
index 1fabb49138c..6de2c50ab36 100644
--- a/mysql-test/t/create.test
+++ b/mysql-test/t/create.test
@@ -2021,3 +2021,35 @@ connection default;
select * from t1;
unlock tables;
drop table t1,t2;
+
+--echo #
+--echo # MDEV-6179: dynamic columns functions/cast()/convert() doesn't
+--echo # play nice with CREATE/ALTER TABLE
+--echo #
+create table t1 (
+ color char(32) as (COLUMN_GET(dynamic_cols, 1 as char)) persistent,
+ cl char(32) as (COLUMN_GET(COLUMN_ADD(COLUMN_CREATE(1 , 'blue' as char), 2, 'ttt'), i as char)) persistent,
+ item_name varchar(32) primary key, -- A common attribute for all items
+ i int,
+ dynamic_cols blob -- Dynamic columns will be stored here
+);
+INSERT INTO t1(item_name, dynamic_cols, i) VALUES
+ ('MariaDB T-shirt', COLUMN_CREATE(1, 'blue', 2, 'XL'), 1);
+INSERT INTO t1(item_name, dynamic_cols, i) VALUES
+ ('Thinkpad Laptop', COLUMN_CREATE(1, 'black', 3, 500), 2);
+
+select item_name, color, cl from t1;
+show create table t1;
+
+drop table t1;
+
+create table t1 (
+ n int,
+ c char(32) as (convert(cast(n as char), char)) persistent
+);
+insert into t1(n) values (1),(2),(3);
+
+select * from t1;
+show create table t1;
+
+drop table t1;