[MDEV-10371] Check constraints on INSERT on non-specified virtual columns not checked when NULL is allowed Created: 2016-07-13  Updated: 2017-03-22  Resolved: 2017-03-22

Status: Closed
Project: MariaDB Server
Component/s: Virtual Columns
Affects Version/s: 10.2.1
Fix Version/s: 10.2.5

Type: Bug Priority: Major
Reporter: Anders Karlsson Assignee: Sergei Golubchik
Resolution: Duplicate Votes: 0
Labels: 10.2-ga

Issue Links:
Duplicate
is duplicated by MDEV-10370 Check constraints on virtual columns ... Closed

 Description   

When there is a CHECK constraint on a virtual column that allows NULL and the column is not specified in an INSERT, then the constraint is not checked:

CREATE TABLE tv2(c1 int, c2 int AS (c1 + 1) VIRTUAL, CHECK (c2 is null or c2 > 2));

The following fails, which is correct:

INSERT INTO tv2 VALUES(1,1);

The following succeeds, which is also correct:

INSERT INTO tv2 VALUES(2,1);

The following though is also successful, which is incorrect (c2 will have the value 2):

INSERT INTO tv2(c1) VALUES(1);



 Comments   
Comment by Sergei Golubchik [ 2017-03-22 ]

Same as MDEV-10370

Generated at Thu Feb 08 07:41:43 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.