Re: BUG #15297: Irregular comparison rules for NULLs in tuples - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #15297: Irregular comparison rules for NULLs in tuples
Date
Msg-id 27390.1532613836@sss.pgh.pa.us
Whole thread Raw
In response to BUG #15297: Irregular comparison rules for NULLs in tuples  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #15297: Irregular comparison rules for NULLs in tuples
List pgsql-bugs
=?utf-8?q?PG_Bug_reporting_form?= <noreply@postgresql.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


pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #15298: Array-array comparisons when arrays contain NULLs
Next
From: Raphael 'kena' Poss
Date:
Subject: Re: BUG #15297: Irregular comparison rules for NULLs in tuples