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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user