Re: NULLS and User Input WAS Re: multimaster

From: Lew <lew(at)nospam(dot)lewscanon(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: NULLS and User Input WAS Re: multimaster
Date: 2007-06-04 15:23:28
Message-ID: UaSdnf_qHOnss_nbnZ2dnUVZ_qCmnZ2d@comcast.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Richard Huxton wrote:
PFC wrote:
>>> NULL usually means "unknown" or "not applicable"

Andrew Sullivan wrote:
>> Aaaargh! No, it doesn't. It means NULL. Nothing else.
>> If it meant unknown or not applicable or anything else, then
>> SELECT * FROM nulltbl a, othernulltbl b
>> WHERE a.nullcol = b.nullcol
>>
>> would return rows where a.nullcol contained NULL and b.nullcol
>> contained NULL. But it doesn't, because !(NULL = NULL).

(a == b) <=> ( (a -> b) AND (b -> a))

| a | b | a->b | b->a | a==b |
|----|-----|------|------|------|
| F | F | T | T | T |
| F | T | T | F | F |
| F | U | U | U | U |
| T | F | F | T | F |
| T | T | T | T | T |
| T | U | U | T | U |
| U | F | U | U | U |
| U | T | T | U | U |
| U | U | U | U | U |

Ergo, (UNKNOWN = UNKNOWN) is UNKNOWN. Similarly for (UNKNOWN != UNKNOWN).

Where NULL differs is that (NULL = NULL) is FALSE, and (NULL != NULL) is FALSE.

The similarity is that with NULL, SQL is not exactly saying (NULL = NULL) is
FALSE so much as that it's not TRUE.

NULL follows Zen-valued logic, not 3-valued, and that seems somehow
appropriate to me.

--
Lew

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Frank Wittig 2007-06-04 15:23:55 Re: warm standby server stops doingcheckpointsafterawhile
Previous Message Rhys Stewart 2007-06-04 15:18:38 Re: what to do when pg_cancel_backend() doesnt work?