Re: [GENERAL] NULL != text ?

2005-10-20 Thread Jan Wieck
On 10/20/2005 6:10 AM, Alban Hertroys wrote: 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;

Re: [GENERAL] NULL != text ?

2005-10-20 Thread Tom Lane
CSN <[EMAIL PROTECTED]> writes: > BTW, it (the SQL spec I presume) has always seemed > contradictory to me that you can't do: > select * from table where field=null; > but can do: > update table set field=null; This only seems contradictory if you fail to make the distinction between "=" used as a

Re: [GENERAL] NULL != text ?

2005-10-20 Thread CSN
BTW, it (the SQL spec I presume) has always seemed contradictory to me that you can't do: select * from table where field=null; but can do: update table set field=null; (as opposed to 'update table set field to null' or similar). CSN __

Re: [GENERAL] NULL != text ?

2005-10-20 Thread Michael Glaesemann
On Oct 20, 2005, at 23:45 , Michael Fuhr wrote: On Thu, Oct 20, 2005 at 03:57:41PM +0900, Michael Glaesemann wrote: On Oct 20, 2005, at 15:44 , Michael Fuhr wrote: expression IS DISTINCT FROM expression For non-null inputs this is the same as the <> operator. However, when both inputs

3-state logic (was: Re: [GENERAL] NULL != text ?)

2005-10-20 Thread Alban Hertroys
Tom Lane wrote: 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. Learned something new again, then. I also noticed FALSE OR NULL is NULL, which went against my intuition. I thin

Re: [GENERAL] NULL != text ?

2005-10-20 Thread Michael Fuhr
On Thu, Oct 20, 2005 at 03:57:41PM +0900, Michael Glaesemann wrote: > On Oct 20, 2005, at 15:44 , Michael Fuhr wrote: > > expression IS DISTINCT FROM expression > > > > For non-null inputs this is the same as the <> operator. However, > > when both inputs are null it will return false, and when

Re: [GENERAL] NULL != text ?

2005-10-20 Thread Tom Lane
Alban Hertroys <[EMAIL PROTECTED]> 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 completen

Re: [GENERAL] NULL != text ?

2005-10-20 Thread Alban Hertroys
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

Re: [GENERAL] NULL != text ?

2005-10-20 Thread Michael Glaesemann
On Oct 20, 2005, at 15:44 , Michael Fuhr wrote: expression IS DISTINCT FROM expression For non-null inputs this is the same as the <> operator. However, when both inputs are null it will return false, and when just one input is null it will return true. Thus it effectively acts as

Re: [GENERAL] NULL != text ?

2005-10-19 Thread Michael Fuhr
On Wed, Oct 19, 2005 at 11:04:36PM -0700, CSN wrote: > So, does NULL != 'abc' always evaluate to false? It never evaluates to false -- it evaluates to NULL. http://www.postgresql.org/docs/8.0/interactive/functions-comparison.html The ordinary comparison operators yield null (signifying "unknow

Re: [GENERAL] NULL != text ?

2005-10-19 Thread Michael Glaesemann
On Oct 20, 2005, at 15:04 , CSN wrote: So, does NULL != 'abc' always evaluate to false? The manual (http://www.postgresql.org/docs/8.0/interactive/functions- comparison.html) states don't compare NULL values using =, but nothing about using != The SQL standard way of checking for NULL is us

[GENERAL] NULL != text ?

2005-10-19 Thread CSN
I was trying this: IF (OLD.value != NEW.value) THEN -- END IF; and couldn't get the condition to evaluate to true at all if OLD.value was NULL. I also tried: IF (OLD.value NOT LIKE NEW.value) THEN -- END IF; with the same result. But this works: IF ((OLD.value is NULL and NEW.value is NOT NU