Re: BUG #15297: Irregular comparison rules for NULLs in tuples

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: knz(at)thaumogen(dot)net
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #15297: Irregular comparison rules for NULLs in tuples
Date: 2018-07-26 14:03:56
Message-ID: 27390.1532613836@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

=?utf-8?q?PG_Bug_reporting_form?= <noreply(at)postgresql(dot)org> writes:
> The SQL standard mandates ternary logic for values that involve NULL, where
> NULL means "unknown".

Right.

> "select (1, (1, NULL::int)) > (1, (1, 2))" -> returns true !?

We insist on non-null record values being totally ordered, because without
that you can't build a working btree opclass for them. So the general
principle for comparing corresponding fields in two records is that nulls
sort after non-nulls and two nulls are treated as equal. The same goes
for elements in other container types such as arrays.

I don't know whether this behavior can be justified by chapter and verse
in the SQL standard, but it doesn't really matter; we will not change it.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Raphael 'kena' Poss 2018-07-26 14:08:54 Re: BUG #15297: Irregular comparison rules for NULLs in tuples
Previous Message PG Bug reporting form 2018-07-26 13:43:06 BUG #15298: Array-array comparisons when arrays contain NULLs