Re: Problem with rule and null value

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Marc Boucher <pgml(at)gmx(dot)net>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Problem with rule and null value
Date: 2004-10-22 23:07:24
Message-ID: 20065.1098486444@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Marc Boucher <pgml(at)gmx(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Gaetano Mendola 2004-10-23 22:08:22 Re: Question on the 8.0Beta Version
Previous Message Tom Lane 2004-10-22 23:02:07 Re: AT TIME ZONE INTERVAL and prepared statements