← Back to team overview

maria-discuss team mailing list archive

Re: Virtual CHECK constraint using Virtual columns

 

My suggestion is for documenting existing functionality and a use case for
VIRTUAL columns.

When CHECK constraints are actually added, it will be obsolete of course
but still useful for those that use older versions (5, 10).


On Sun, Oct 16, 2016 at 3:51 PM, Peter Laursen <peter_laursen@xxxxxxxxxx>
wrote:

> Didn't CHECK CONSTRAINTS get introduced in MySQL 8? Then better port it
> from there into MariaDB I think.  -- Peter
>
>
>
On Sun, Oct 16, 2016 at 4:45 PM, Pantelis Theodosiou <ypercube@xxxxxxxxx>
> wrote:
>
>> Would this be good to be added in the documentation of VIRTUAL columns?
>>
>> Or as a separate page, as a way to enforce/emulate arbitrary CHECK
>> constraints?
>>
>> It can be slightly simplified (IF is not needed) and the BOOLEAN could be
>> BIT (not sure if that adds any complication):
>>
>> CREATE TABLE truth (t BIT PRIMARY KEY) ;
>> INSERT INTO truth (t) VALUES (TRUE) ;
>> -- and remove all write permissions to the table
>>
>> CREATE TABLE checker (
>>     i float,
>>     i_must_be_between_7_and_12 BIT
>>          AS (i BETWEEN 7 AND 12)                   -- whatever CHECK
>> constraint we want here
>>          PERSISTENT,
>>     CONSTRAINT check_i_must_be_between_7_and_12
>>     FOREIGN KEY (i_must_be_between_7_and_12)
>>       REFERENCES truth (t)
>>     );
>>
>> On Wed, Apr 6, 2016 at 6:46 PM, Pantelis Theodosiou <ypercube@xxxxxxxxx>
>> wrote:
>>
>>>
>>>
>>>
>>>
>>
>

References