Re: Problem with rule and null value - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Problem with rule and null value
Date
Msg-id 20065.1098486444@sss.pgh.pa.us
Whole thread Raw
In response to Problem with rule and null value  (Marc Boucher <pgml@gmx.net>)
List pgsql-bugs
Marc Boucher <pgml@gmx.net> writes:
> CREATE OR REPLACE RULE albed_updalb3_rl AS
>    ON UPDATE TO album WHERE new.pls_id != old.pls_id
>   DO
>    UPDATE album_edit SET pls_id=new.pls_id WHERE alb_id=new.id;

> It works until new.pls_id or old.pls_id is null. The rule is still called
> (based on my test), but the "DO" query is not executed correctly.

That's not a bug.  "foo != NULL" does not yield true, it yields NULL.
You could test for nulls with IS NULL, or possibly use the IS DISTINCT
FROM construct (does 7.3 have that?  I forget.)

            regards, tom lane

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: AT TIME ZONE INTERVAL and prepared statements
Next
From: H Chao
Date:
Subject: select() failed in statistics collector