Re: [PATCH] Fix hashed ScalarArrayOp semantics for NULL LHS with non-strict comparators

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Chengpeng Yan <chengpeng_yan(at)outlook(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Fix hashed ScalarArrayOp semantics for NULL LHS with non-strict comparators
Date: 2026-04-20 04:14:03
Message-ID: 100165.1776658443@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

David Rowley <dgrowleyml(at)gmail(dot)com> writes:
> I've attached a version that "probes" the equality function for its
> NULL = NULL behaviour and its NULL = 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 opinion.

> The patch does assume that the non-strict function will return the
> same thing for NULL = non-NULL as it will for non-NULL = NULL.

Meh. I think we assume that hashable equality functions satisfy the
symmetric law, ie A = B if and only if B = 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2026-04-20 04:49:16 Re: POC: Comparison of partitioning key values
Previous Message David Rowley 2026-04-20 03:46:10 Re: [PATCH] Fix hashed ScalarArrayOp semantics for NULL LHS with non-strict comparators