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 1wFliv-005Wfr-32 for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Apr 2026 04:31:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wFliu-00GrVW-2d for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Apr 2026 04:31:32 +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 1wFliu-00GrVO-1O for pgsql-hackers@lists.postgresql.org; Thu, 23 Apr 2026 04:31:32 +0000 Received: from mail-japanwestazolkn19010018.outbound.protection.outlook.com ([52.103.66.18] helo=OS0P286CU011.outbound.protection.outlook.com) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wFlis-00000002aNS-1W1t for pgsql-hackers@postgresql.org; Thu, 23 Apr 2026 04:31:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Opd8ltmFEpe+fxJgo3TL1IWXkYnx/0a0qw7pXsrTHVo75J73haDtxPghLGbh9ISwDF+CJqcWeL74oE7xnDqe+ae/Pljwk49P99Ml50i1HQD/2aRVaB3sNLr9zUAD4Ij113Yflk/o1Hq8DSrE3CsVSu05ejqJR7mDcg4TzEcO9vxLrq+mlnUHIl/xav9/rqOGeKgRwTik97RZqLy7+uY1lNACioQsY4Zuzdq1ne1TYIyAiJVq3NhzmETwYmekRMwNVsNq/B7vlOuC+TBn14uxUDEEiC36J4/C9akF1AF8B8EOuMlAxtLFApX/Oq9TIsyP5VMVpbhKu4amF05KxpOQJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0WYLBG+/liJlBJhMK26ghj22G9avDxoxxGi7xb+UwOM=; b=Sdt8Vh23jW2MQNit98ghwhZHDH9NCGb40YheZHgpqn5VURQDfCxAqACcyoWik/3++ihkOe16QGe0DNWVH1lxq9ZCI9bRYA/ZPQuDZjpMJxY5oGToQ17OKfe+Ur5jNseCpn5uAj6gu+5MoR0DrHrGxMqsUUa+kyFYOXnj+hR2JeT1KKOdvLznDdJQ6zSBbNZHX8Eu6txiupVlhDEnfYkgruEmMER29jxrmPAX/cl7zPUXyvHu7dOiIskJHDhi9RINcyaIA4bXZbjbP57YH/DLwvN/GXAg3RB275YVDt2SRztSdXkzWbSldh5tr+VJ3nh7Wh3krLML0CxXxQSp8sACmg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0WYLBG+/liJlBJhMK26ghj22G9avDxoxxGi7xb+UwOM=; b=i2/pp9uQleePuJUy1zdBM4VNrk+ehJfnhehnVBkhFXZdknbWjsY/sUCknhJbTvxPZDmi9i/W66sDjQYlRT65lb6L/7L+tjwNkQ05skkQhAo1j6n5ytVeO+ICzwwZ6mLrP1jTQwgvzueo1P3sX2SjFAJ+8ufrArvSs5uNjXPmI1ZaqMkYWXfF0M2K5B8LCn5gpZeQKNssjZ+FZ/8rE7m5mT/hY/i+auBjN9fvZU3qt75XcJTJXlawjWkDMXg/OFsAz9hPkcYqsuz+ECfyMMNGVn/aMU5IUG0VxpTobZaCbhIEC4ZLqVKOFgecHcpiT6d2spRGCdDWODWEUK3AogLT7Q== Received: from TYYPR01MB14116.jpnprd01.prod.outlook.com (2603:1096:405:212::9) by TYYPR01MB6729.jpnprd01.prod.outlook.com (2603:1096:400:ca::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9846.21; Thu, 23 Apr 2026 04:31:24 +0000 Received: from TYYPR01MB14116.jpnprd01.prod.outlook.com ([fe80::31dd:4ff2:eea8:c663]) by TYYPR01MB14116.jpnprd01.prod.outlook.com ([fe80::31dd:4ff2:eea8:c663%5]) with mapi id 15.20.9846.019; Thu, 23 Apr 2026 04:31:24 +0000 From: Chengpeng Yan To: David Rowley CC: PostgreSQL-development , cca5507 , Tom Lane Subject: Re: [PATCH] Fix hashed ScalarArrayOp semantics for NULL LHS with non-strict comparators Thread-Topic: [PATCH] Fix hashed ScalarArrayOp semantics for NULL LHS with non-strict comparators Thread-Index: AQHczaEqi+5p9wMBTka3ciLQwzUU6rXmX14AgAD10wCAACpDAIAERiEAgABTKAA= Date: Thu, 23 Apr 2026 04:31:24 +0000 Message-ID: <614EFDA0-6858-4C14-9E6A-53FC4EABE1AA@outlook.com> References: <5CDAD4B4-6DC6-4C31-8AC1-1F45EA6ED480@outlook.com> In-Reply-To: Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-traffictypediagnostic: TYYPR01MB14116:EE_|TYYPR01MB6729:EE_ x-ms-office365-filtering-correlation-id: 9ca69991-ea9a-4db6-0d70-08dea0f12d67 x-microsoft-antispam: BCL:0;ARA:14566002|19110799012|31061999003|24021099003|22091999003|12121999013|15080799012|461199028|24121999003|8022599003|8060799015|8062599012|440099028|3412199025|102099032; x-microsoft-antispam-message-info: =?us-ascii?Q?DApnpA0TgXhG2vQO8u+rTBdEFR9l9LHSmzzUEkbEDBjde7CHfpL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uEtYWWVSshuUzOyhnm12ATLSsYtCJxoBOxUMLOpQ?= =?us-ascii?Q?whE7tO9eOP1oQzKJB9PngFRHl7RtlDMTzrCyddtP5jWWox7GJ4lmxbSy/ngE?= =?us-ascii?Q?B+57?= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Be4c+qKGu1fBpYo29L3BhDzZc+5asf7yi+IQmgvVCGNu4SvchlrUxEM94tM+?= =?us-ascii?Q?ltSBxX6gk8nutoZd/g5y87CtYo/a8fQ8+S0ti+eI/93RbV+Q60K7p8FXwZor?= =?us-ascii?Q?iH1UDc9XBvyiw1xvdOEKMyjKfduavgVNSMgdFpxIQBMsbwth7XJf720ZXbPy?= =?us-ascii?Q?WeA8VNbmYqCXE2VdrK9IMMJVZppnuMIvRqYi9as75VcyYIminR0kMYFjMlrF?= =?us-ascii?Q?ExyuTo7ZCJRYAXdEmvD4B0wtdw2F6+TucwhddPbHmPdt7K01azbAw1HWKoPi?= =?us-ascii?Q?rwo2H/jVeGX/MhLSw+JQPkRGo0Aww4exC1QFjd4enIiBJN+gCYYKMFVs6MZ/?= =?us-ascii?Q?XmCj8WqfhXlD13wg0ri/zMCoZtYw/YQzWpQPMzeovhpemGD3ZfLVggiVxatS?= =?us-ascii?Q?gbRw0zWVQMb3sSKLPYtSCxduIxWs/pUdINGYP7aWzF3aotTUfAJ++Xh+icgZ?= =?us-ascii?Q?DgH7UzQ2KrbK3f/rXdL/EgIn0dqm2Aj2IvXLoUiX8d6zJeif3xJbuF+s7e9u?= =?us-ascii?Q?KPuubzHoSYUCcLfOGjcLbsSw/OSH3cwtkpNuTAQVvGkMEWuU7n90nfPXDS8z?= =?us-ascii?Q?peKEM7n0tl8FgSl76vIrdh4ZafxdQVHF1RTnEWS9h+NlVYpdbgrzbEg7USTe?= =?us-ascii?Q?y0sszAjGycWrtQeAkKLXYBSeBkToStKm7lWxEzI7tdvneEomi0P5Vzk4cOTV?= =?us-ascii?Q?yfiuGMvKLVniWW2sqGVmWSPfJHQ+qBxwreNJWqGhhWS76QYb4FvEqA/fAKFj?= =?us-ascii?Q?+v3TagoKs7SX/RjoMhXcyuK5cB4WkI4payWn90nIUtfSRmYIJjAV+6DhQDcq?= =?us-ascii?Q?42TXn2TrJeiAE3s2k9Cg/Q6cq3Dc7XFvNzWNkjUQlvPTIA11Lkal8fgweRLt?= =?us-ascii?Q?n8fSGQRyabWLn6JoJA2Kz0X6fs8M7mpTSOMF/7wDVj7kPFJFwCFxO/ALOtXh?= =?us-ascii?Q?0gns/WwAaaNIY2gxploJ45Ffjj/xIEp3Y53FzxMraDa2WUtewULRi3HqKeE1?= =?us-ascii?Q?bvRBw/2vs/+BFr3mxuHxy4QEsKKnOAHMjxZ7vi/DdW8EghHI81ccexaDSXfn?= =?us-ascii?Q?9uaUoFPqko09//rILJtbISM1kueKqrUR7hPavK3isuW4Di2uBuAwcRJpL7sp?= =?us-ascii?Q?8Ly1WrY0yNhSw+uhJMwEkH6t+PUvBfR3ZvCJUOfUT73DpIhUMgXhxRMVTch7?= =?us-ascii?Q?EZbev376IttR4hWR0ydKAZClDpWn1kYPWazV7EcdZb4iD/qdvc9s+adRVWEI?= =?us-ascii?Q?7xczDRjop7tHzV3pRwSLN9ep72vIEKdXtHKGdjiOr/+dJSXN92PcA7Jqe+ag?= =?us-ascii?Q?8g+M3cgHzI1U9wnqBP/XWjuPr+80SoAKeXmPq/MI02Esz5hHjiVHvgYKYSxu?= =?us-ascii?Q?08VPI9zFJc4sQgS1ETwbjBNGJoR7eeiOCzZPeHpcAdxnzjojOQ=3D=3D?= Content-Type: text/plain; charset="us-ascii" Content-ID: <4CAB8882145AFE46AFB6ED9A96A2F1F5@jpnprd01.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TYYPR01MB14116.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 9ca69991-ea9a-4db6-0d70-08dea0f12d67 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Apr 2026 04:31:24.2253 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYYPR01MB6729 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, > On Apr 23, 2026, at 07:33, David Rowley wrote: >=20 > Yeah, it doesn't make sense to repeatedly perform a linear search over > the array to check if NULL matches anything in the array. Let's just > do that once when we build the hash table and reuse that cached value > whenever we see a NULL. We can skip that step with strict functions > since we'll short-circuit earlier. >=20 > A patch for that is attached. Thanks for working on this. Overall, this version looks good to me, and I'm fine with the current approach. One possible improvement, though not a blocker, would be to defer the lhs-NULL handling until we actually encounter the first NULL on the lhs. That could avoid a bit of extra work in the common case where the lhs contains no NULLs. That said, I think the current implementation is perfectly OK as-is. > IMO it's unrealistic to assume we can do anything sane with an > equality function that always returns NULL. >=20 > I really doubt it's worth troubling over that. If we did want to do > something, then it would be more efficient to probe the hash table > directly after we insert a Datum and verify we can find it again. If > we can't find any value we just inserted, mark the entire table as > broken and have it so we check for that and do a linear search. I tend to agree. Even if such a case can be constructed, it seems rare enough that I am not sure it is worth adding more complexity, or extra overhead in the common hashed SAOP path, to handle it in this patch. I think we can revisit that separately if a concrete case turns up that seems worth looking into. -- Best regards, Chengpeng Yan