Re: NULL != text ? - Mailing list pgsql-general

From Tom Lane
Subject Re: NULL != text ?
Date
Msg-id 9351.1129817358@sss.pgh.pa.us
Whole thread Raw
In response to Re: NULL != text ?  (Alban Hertroys <alban@magproductions.nl>)
Responses 3-state logic (was: Re: NULL != text ?)
List pgsql-general
Alban Hertroys <alban@magproductions.nl> writes:
> Michael Glaesemann wrote:
>> if (OLD.value IS NOT NULL and NEW.value IS NOT NULL and OLD.value <>
>> NEW.value) or OLD.value IS NULL or NEW.value IS NULL
>>
>> But that's untested and I have a hard time thinking in three-value  logic.

> For completeness sake; Because of lazy evaluation, that boils down to:

> if (OLD.value IS NULL OR NEW.value IS NULL OR OLD.value <> NEW.value)

> The last part of the expression is only evaluated if both OLD.value and
> NEW.value aren't NULL.

Wrong.  SQL doesn't guarantee lazy evaluation.  The above will work,
but it's because TRUE OR NULL is TRUE, not because anything is promised
about evaluation order.

            regards, tom lane

pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: NEW in Rule makes another nextval call?
Next
From: Tom Lane
Date:
Subject: Re: server , client encoding issue