From 4c6c352138d8370784f87118dc172c54a2a7a6ca Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 14 Sep 2017 15:10:23 +0200 Subject: 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. --- sql/table.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sql/table.cc') diff --git a/sql/table.cc b/sql/table.cc index 450e116080a..e80a938ee72 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -5090,7 +5090,8 @@ int TABLE::verify_constraints(bool ignore_failure) { for (Virtual_column_info **chk= check_constraints ; *chk ; chk++) { - if ((*chk)->expr->val_int() == 0) + /* yes! NULL is ok, see 4.23.3.4 Table check constraints, part 2, SQL:2016 */ + if ((*chk)->expr->val_int() == 0 && !(*chk)->expr->null_value) { my_error(ER_CONSTRAINT_FAILED, MYF(ignore_failure ? ME_JUST_WARNING : 0), (*chk)->name.str, -- cgit v1.2.1