Re: NULL != text ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alban Hertroys <alban(at)magproductions(dot)nl>
Cc: Michael Glaesemann <grzm(at)myrealbox(dot)com>, CSN <cool_screen_name90001(at)yahoo(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: NULL != text ?
Date: 2005-10-20 14:09:18
Message-ID: 9351.1129817358@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Alban Hertroys <alban(at)magproductions(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-10-20 14:12:10 Re: server , client encoding issue
Previous Message Tom Lane 2005-10-20 14:04:26 Re: doc typo sql-reindex.html psql vs. postgres