Re: Check constraints do not seem to be working!!!

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: Check constraints do not seem to be working!!!
Дата
Msg-id CAFj8pRA2f3ttP8zUugwMjfyF7bc3RBAD6S_Sw-ZZPVziXRDnQg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Check constraints do not seem to be working!!!  (Chris Sterritt <chris.sterritt@yobota.xyz>)
Список pgsql-general


st 11. 11. 2020 v 9:38 odesílatel Chris Sterritt <chris.sterritt@yobota.xyz> napsal:


On 11/11/2020 06:44, Jitendra Loyal wrote:
Consider this table definition:
         create table t ( i serial, b bool, c bool,
                                constraint b_c check ( (b = true and c is not null ) or (b is distinct
from true and c is null) )
                                constraint b_c check ( (b = true and c is not null ) or (b = false and c
is null) or (b is null and c is null) )
                                );
Despite the above two constraints, the following rows get into the table:
     insert into t (b , c) values (null, true), (null, false); 


(b = TRUE AND c IS NOT NULL) evaluates to null when b is null

yes, constraint is violated only when result is false, no when it is null.

Regards

Pavel
Cheers, 
Chris Sterritt

В списке pgsql-general по дате отправления:

Предыдущее
От: Chris Sterritt
Дата:
Сообщение: Re: Check constraints do not seem to be working!!!
Следующее
От: Nikolay Samokhvalov
Дата:
Сообщение: Re: Check constraints do not seem to be working!!!