Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nc5rF-0000Ul-UW for pgsql-bugs@arkaria.postgresql.org; Wed, 06 Apr 2022 13:38:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nc5rD-0000bc-7w for pgsql-bugs@arkaria.postgresql.org; Wed, 06 Apr 2022 13:37:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nc5rC-0000Xz-Vp for pgsql-bugs@lists.postgresql.org; Wed, 06 Apr 2022 13:37:58 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nc5r9-0006BQ-TX for pgsql-bugs@lists.postgresql.org; Wed, 06 Apr 2022 13:37:57 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 236DbqAF3034595; Wed, 6 Apr 2022 09:37:53 -0400 From: Tom Lane To: Lukas Eder cc: pgsql-bugs@lists.postgresql.org Subject: Re: Wrong behaviour of array comparison when arrays contain nulls In-reply-to: References: Comments: In-reply-to Lukas Eder message dated "Wed, 06 Apr 2022 14:22:45 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3034593.1649252272.1@sss.pgh.pa.us> Date: Wed, 06 Apr 2022 09:37:52 -0400 Message-ID: <3034594.1649252272@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Lukas Eder writes: > For the following query: > SELECT array[1, NULL] = array[1, NULL] > H2 returns NULL whereas PostgreSQL returns TRUE. In my opinion and > intuition, as well as according to ISO/IEC 9075-2:2016(E) 8.2 predicate> GR 1) b) ii), H2 is right and PostgreSQL is wrong. If we don't impose a total order on array values, then we cannot build btree indexes on such columns. So yes, this is a deviation from the SQL standard, and no we are not going to change it. As for documentation, section 9.19 says The comparison operators compare the array contents element-by-element, using the default B-tree comparison function for the element data type, and sort based on the first difference. which implies this behavior but perhaps could be more explicit. regards, tom lane