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

From: Jitendra Loyal <jitendra(dot)loyal(at)gmail(dot)com>
To: Nikolay Samokhvalov <samokhvalov(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Check constraints do not seem to be working!!!
Date: 2020-11-11 09:06:32
Message-ID: CAGBkuscy+YehMzqAmhijQrQ37yhDAMSaWQ+rJJMmA1zWN_3ZaA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks Nikolay

I read that but is there a way to meet the above requirement. And I will
like to add that IS NULL and IS NOT NULL should evaluate to true/false.
These operators are made for this and should not be returning NULL.

Regards,
Jitendra

On Wed 11 Nov, 2020, 14:18 Nikolay Samokhvalov, <samokhvalov(at)gmail(dot)com>
wrote:

> On Wed, Nov 11, 2020 at 12:26 AM Jitendra Loyal <jitendra(dot)loyal(at)gmail(dot)com>
> wrote:
>
>> Despite the above two constraints, the following rows get into the table:
>> insert into t (b , c) values (null, true), (null, false);
>>
>
> This behavior is described in the docs
> https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-CHECK-CONSTRAINTS
> :
>
> > It should be noted that a check constraint is satisfied if the check
> expression evaluates to true or the null value. Since most expressions will
> evaluate to the null value if any operand is null, they will not prevent
> null values in the constrained columns. To ensure that a column does not
> contain null values, the not-null constraint described in the next section
> can be used.
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message RAJAMOHAN 2020-11-11 10:40:18 Need to place pgpool logs on separate directory
Previous Message Nikolay Samokhvalov 2020-11-11 08:48:36 Re: Check constraints do not seem to be working!!!