diff options
author | Sergei Golubchik <serg@mariadb.org> | 2017-03-22 18:44:01 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2017-03-29 00:40:21 +0200 |
commit | 33ec4459759df66733ba73ca31e2ef094f9a864f (patch) | |
tree | 4d72209abcc8538ee27f717f55e5063e20a0da02 | |
parent | 1216244eb9a52c30c7ffe1b1c372bb9e7d86ddf1 (diff) | |
download | mariadb-git-33ec4459759df66733ba73ca31e2ef094f9a864f.tar.gz |
MDEV-10370 Check constraints on virtual columns fails on INSERT when column not specified
add columns needed for CHECK constraints not only to read_set,
but also to vcol_set.
-rw-r--r-- | mysql-test/r/check_constraint.result | 5 | ||||
-rw-r--r-- | mysql-test/t/check_constraint.test | 9 | ||||
-rw-r--r-- | sql/table.cc | 2 |
3 files changed, 16 insertions, 0 deletions
diff --git a/mysql-test/r/check_constraint.result b/mysql-test/r/check_constraint.result index db64eb7f89f..59fbb8adf57 100644 --- a/mysql-test/r/check_constraint.result +++ b/mysql-test/r/check_constraint.result @@ -131,3 +131,8 @@ t1 CREATE TABLE `t1` ( CONSTRAINT `CONSTRAINT_2` CHECK (`a` > `b`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; +create table t1(c1 int, c2 int as (c1 + 1), check (c2 > 2)); +insert into t1(c1) values(1); +ERROR 23000: CONSTRAINT `CONSTRAINT_1` failed for `test`.`t1` +insert into t1(c1) values(2); +drop table t1; diff --git a/mysql-test/t/check_constraint.test b/mysql-test/t/check_constraint.test index 8dd6fcc4f27..643ead2439b 100644 --- a/mysql-test/t/check_constraint.test +++ b/mysql-test/t/check_constraint.test @@ -69,3 +69,12 @@ create or replace table t1 (a int, b int, constraint CONSTRAINT_2 check (a>b)); show create table t1; drop table t1; + +# +# MDEV-10370 Check constraints on virtual columns fails on INSERT when column not specified +# +create table t1(c1 int, c2 int as (c1 + 1), check (c2 > 2)); +--error ER_CONSTRAINT_FAILED +insert into t1(c1) values(1); +insert into t1(c1) values(2); +drop table t1; diff --git a/sql/table.cc b/sql/table.cc index 404c43bef17..03117f8ec63 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -6605,6 +6605,8 @@ void TABLE::mark_columns_used_by_check_constraints(void) void TABLE::mark_check_constraint_columns_for_read(void) { bitmap_union(read_set, s->check_set); + if (vcol_set) + bitmap_union(vcol_set, s->check_set); } |