Skip site navigation (1) Skip section navigation (2)

Re: Bug in check constraint?

From: "Luiz Gonzaga da Mata" <gonzaga(at)pbh(dot)gov(dot)br>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Bug in check constraint?
Date: 2005-01-16 22:00:01
Message-ID: 1219.201.19.109.189.1105912801.squirrel@www.pbh.gov.br (view raw or flat)
Thread:
Lists: pgsql-bugs
> transform_null_equals only catches the exact syntax "something = NULL". It
> does not touch "something <> NULL".  The latter is always going to yield
> NULL, by definition.

Yes, I saw this in parser_expr.c and the documentation.

1)In code "dtpagto IS NULL" is not the same thing that !(dtpagto IS NULL),
 or either, a condition bolean.

2) if "dtpagto <> NULL" is not a valid codification and not checked, he
would not be correct that a message of error while creating constraint.
The fact not to occur the error message, can delude the programmer of the
SGBD with in sample of test.


CONSTRAINT ttt CHECK (valorpg > 0::numeric AND dtpagto <> NULL::date OR
valorpg = 0::numeric AND dtpagto IS NULL)

) WITH OIDS;


ALTER TABLE cntpagit1 OWNER postgres;


-- Result of sql.

insert into cntpagit1 values(1, NULL);

Query returned successfully:  one row 20545 with OID inserted, 70 ms
execution times.

insert into cntpagit1 values(0, '20050115 ');

ERROR:  new row will be relation "cntpagit1" violates check constraint "ttt"

regards,

Luiz Gonzaga da Mata.

Brasil.




In response to

pgsql-bugs by date

Next:From: Josh BerkusDate: 2005-01-17 00:56:57
Subject: Error in 8.0 rc5 with repeat calls to array operator
Previous:From: Tom LaneDate: 2005-01-16 21:08:35
Subject: Re: BUG #1393: Adding 'LIMIT 1' to the query halts forever

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group