Re: NULLS and User Input WAS Re: multimaster - Mailing list pgsql-general

From Lew
Subject Re: NULLS and User Input WAS Re: multimaster
Date
Msg-id UaSdnf_qHOnss_nbnZ2dnUVZ_qCmnZ2d@comcast.com
Whole thread Raw
In response to Re: NULLS and User Input WAS Re: multimaster  (Richard Huxton <dev@archonet.com>)
Responses Re: NULLS and User Input WAS Re: multimaster
List 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

pgsql-general by date:

Previous
From: "Erik Jones"
Date:
Subject: Re: Large Database \d: ERROR: cache lookup failed for relation ...
Next
From: "ARTEAGA Jose"
Date:
Subject: Limitations on 7.0.3?