Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wEg1Y-004HVz-1i for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Apr 2026 04:14:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wEg1W-000TBQ-1x for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Apr 2026 04:14:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wEg1W-000TBH-10 for pgsql-hackers@lists.postgresql.org; Mon, 20 Apr 2026 04:14:14 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wEg1S-000000024aP-1keX for pgsql-hackers@postgresql.org; Mon, 20 Apr 2026 04:14:14 +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 63K4E3x7100166; Mon, 20 Apr 2026 00:14:03 -0400 From: Tom Lane To: David Rowley cc: Chengpeng Yan , PostgreSQL-development Subject: Re: [PATCH] Fix hashed ScalarArrayOp semantics for NULL LHS with non-strict comparators In-reply-to: References: Comments: In-reply-to David Rowley message dated "Mon, 20 Apr 2026 15:46:10 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <100164.1776658443.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 20 Apr 2026 00:14:03 -0400 Message-ID: <100165.1776658443@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > I've attached a version that "probes" the equality function for its > NULL =3D NULL behaviour and its NULL =3D non-NULL behaviour and returns > whatever the result of the probe was at the appropriate time. > What I came up with does feel quite elaborate, so I'd quite like a 2nd o= pinion. > The patch does assume that the non-strict function will return the > same thing for NULL =3D non-NULL as it will for non-NULL =3D NULL. Meh. I think we assume that hashable equality functions satisfy the symmetric law, ie A =3D B if and only if B =3D A, so that part is fine. However, I do not care for the assumption that any random non-null input will produce the same answer. As a quick counter-example, consider a text-like datatype that tries to emulate Oracle's semantics that an empty string is the same as NULL. Your code would arrive at different results depending on whether the first non-null input chanced to be an empty string. (I've not read this whole thread, so I don't have a global opinion on what we ought to do here. I suspect it's a tricky subject.) regards, tom lane