Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1figs9-0002iS-Lc for pgsql-bugs@arkaria.postgresql.org; Thu, 26 Jul 2018 14:04:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1figs8-0003CO-2K for pgsql-bugs@arkaria.postgresql.org; Thu, 26 Jul 2018 14:04:04 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1figs7-0003CH-P5 for pgsql-bugs@lists.postgresql.org; Thu, 26 Jul 2018 14:04:03 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1figs1-0000lB-IM for pgsql-bugs@lists.postgresql.org; Thu, 26 Jul 2018 14:04:02 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w6QE3ua7027391; Thu, 26 Jul 2018 10:03:56 -0400 From: Tom Lane To: knz@thaumogen.net cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15297: Irregular comparison rules for NULLs in tuples In-reply-to: <153261212701.1395.18260320763646237974@wrigleys.postgresql.org> References: <153261212701.1395.18260320763646237974@wrigleys.postgresql.org> Comments: In-reply-to =?utf-8?q?PG_Bug_reporting_form?= message dated "Thu, 26 Jul 2018 13:35:27 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <27389.1532613836.1@sss.pgh.pa.us> Date: Thu, 26 Jul 2018 10:03:56 -0400 Message-ID: <27390.1532613836@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =?utf-8?q?PG_Bug_reporting_form?= 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