1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +03:00

MDEV-13596 CHECK constraints disallow NULL to pass through, violating SQL

SQL Standard (4.23.3.4 Table check constraints, part 2, SQL:2016) says
that CHECK constraint rejects rows *only* if the condition is FALSE.
That is, both TRUE and NULL should be allowed.
This commit is contained in:
Sergei Golubchik
2017-09-14 15:10:23 +02:00
parent e6ce97a592
commit 4c6c352138
3 changed files with 23 additions and 1 deletions

View File

@@ -142,3 +142,13 @@ create table t1 (a int check (@b in (select user from mysql.user)));
ERROR HY000: Function or expression 'select ...' cannot be used in the CHECK clause of `a`
create table t1 (a int check (a > @b));
ERROR HY000: Function or expression '@b' cannot be used in the CHECK clause of `a`
create table t1 (a int check (a = 1));
insert t1 values (1);
insert t1 values (2);
ERROR 23000: CONSTRAINT `a` failed for `test`.`t1`
insert t1 values (NULL);
select * from t1;
a
1
NULL
drop table t1;