summaryrefslogtreecommitdiff
path: root/sql/table.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2017-09-14 15:10:23 +0200
committerSergei Golubchik <serg@mariadb.org>2017-09-18 10:12:23 +0200
commit4c6c352138d8370784f87118dc172c54a2a7a6ca (patch)
tree8887b596772f4986faaf0d1ce582b4a4614b666b /sql/table.cc
parente6ce97a592858cf7274f045150e5208128e2c35a (diff)
downloadmariadb-git-4c6c352138d8370784f87118dc172c54a2a7a6ca.tar.gz
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.
Diffstat (limited to 'sql/table.cc')
-rw-r--r--sql/table.cc3
1 files changed, 2 insertions, 1 deletions
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,