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

From: Alban Hertroys <alban(at)magproductions(dot)nl>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: 3-state logic (was: Re: NULL != text ?)
Date: 2005-10-20 15:35:30
Message-ID: 4357B942.3050803@magproductions.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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
think I understand why:

- TRUE OR "unknown" can only evaluate to TRUE again; "unknown" is not
relevant for the operation.
- FALSE OR "unknown" remains "unknown", because "unknown" may be TRUE or
it may not. If it is, then the result would be TRUE, but if it isn't it
would be FALSE, but we don't know...

This 3-state logic can have some interesting results...

--
Alban Hertroys
alban(at)magproductions(dot)nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
7500 AK Enschede

//Showing your Vision to the World//

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Sullivan 2005-10-20 15:52:40 Re: Select all invalid e-mail addresses
Previous Message Andrew Sullivan 2005-10-20 15:28:34 Re: [pgsql-advocacy] Oracle buys Innobase