Check constraints do not seem to be working!!!

From: Jitendra Loyal <jitendra(dot)loyal(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Check constraints do not seem to be working!!!
Date: 2020-11-11 06:44:35
Message-ID: CAGBkusdqR7ZuovjZmqCwN913=PRCTmnUjT3KdEyXCr3z74BNoQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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);

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Chris Sterritt 2020-11-11 08:38:28 Re: Check constraints do not seem to be working!!!
Previous Message Peter Coppens 2020-11-11 05:51:36 Re: Execution plan does not use index