summaryrefslogtreecommitdiff
path: root/mysql-test/main/constraints.test
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2019-02-13 18:21:19 +0200
committerMonty <monty@mariadb.org>2019-02-13 18:21:19 +0200
commit438811b4b28fab6c775522bc35b53923c8e1e9c4 (patch)
tree38b66cc39cb7126abd3148559d9231a37e88972f /mysql-test/main/constraints.test
parent44898d28f0f2185a4a8ff109c58972d28b8cae95 (diff)
downloadmariadb-git-438811b4b28fab6c775522bc35b53923c8e1e9c4.tar.gz
Fixed two bugs related to column level constraints
- CREATE TABLE ... SELECT drops constraints for columns that are both in the create and select part. - Fixed by copying the constraint in Column_definiton::redefine_stage1_common() - If one has both a default expression and check constraint for a column, one can get the error "Expression for field `a` is refering to uninitialized field `a`. - Fixed by ignoring default expressions for current column when checking for CHECK constraint
Diffstat (limited to 'mysql-test/main/constraints.test')
-rw-r--r--mysql-test/main/constraints.test20
1 files changed, 20 insertions, 0 deletions
diff --git a/mysql-test/main/constraints.test b/mysql-test/main/constraints.test
index fe51e5060dc..c06f585d04f 100644
--- a/mysql-test/main/constraints.test
+++ b/mysql-test/main/constraints.test
@@ -102,3 +102,23 @@ SELECT * FROM long_enough_name AS tbl;
SHOW CREATE TABLE long_enough_name;
DROP TABLE long_enough_name;
+
+#
+# Check that we don't loose constraints as part of CREATE ... SELECT
+#
+
+create table t1 (a int check (a>10)) select 100 as 'a';
+show create table t1;
+drop table t1;
+
+#
+# Check that we constraints on field with default expressions work
+#
+
+create table t1 (a text default(length(now())) check (length(a) > 1));
+insert into t1 values ();
+insert into t1 values ("ccc");
+--error ER_CONSTRAINT_FAILED
+insert into t1 values ("");
+select * from t1;
+drop table t1;