[MDEV-10370] Check constraints on virtual columns fails on INSERT when column not specified Created: 2016-07-13  Updated: 2017-03-29  Resolved: 2017-03-29

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: Fixed Votes: 0
Labels: 10.2-ga

Issue Links:
Duplicate
duplicates MDEV-10371 Check constraints on INSERT on non-sp... Closed

 Description   

When having a check constraint on a virtual column, the column in question must be present in any insert statement and have a value that fulfills the check constraint, despite this value being overwritten by the virtual column formula later, like this:

CREATE TABLE tv1(c1 int, c2 int as (c1 + 1), CHECK (c2 > 2));

The following fails, which is correct (c2 is 2 which is wrong):

INSERT INTO tv1(c1) VALUES(1);

But the following also fails:

INSERT INTO tv1(c1) VALUES(2);

The following also fails (again as c2 is 2):

INSERT INTO tv1 VALUES(1,NULL);

But the following works:

INSERT INTO tv1 VALUES(2,NULL);

Which you would think is the same as:

INSERT INTO tv1(c1) VALUES(2);

But as shown above it is not


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