Re: [PG19] Wrong results from Memoize with a nondeterministic collation

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: shihao zhong <zhong950419(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, David Rowley <dgrowleyml(at)gmail(dot)com>
Subject: Re: [PG19] Wrong results from Memoize with a nondeterministic collation
Date: 2026-10-29 01:36:09
Message-ID: CAMbWs48iXE7LQHWpURBpS_MveUtS5rsRD6d+GWgDCpjgdpAwHg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Oct 8, 2026 at 12:33 PM shihao zhong <zhong950419(at)gmail(dot)com> wrote:
> Since 0da29e4cb16 an anti join can use Memoize. Memoize compares its
> cache key with the collation of o.code, so 'P1' hits the cache entry
> of 'p1'. The clause compares under "C", where they differ.

The root cause here is that Memoize hashes and compares its cache key
using the collation of the outer expression rather than the input
collation of the join operator. That code dates back to v14, and the
LEFT JOIN form of the same query gives wrong results on all supported
branches.

0da29e4cb16 doesn't change how Memoize builds its cache keys. It only
allows one more join type to reach the same code, and the proposed fix
doesn't touch anything that commit added. So I don't think this
belongs under Open Items for v19.

- Richard

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2026-10-29 01:39:22 Re: SQL/JSON DEFAULT ON ERROR/ON EMPTY evaluation fail should rethrow error unconditionally
Previous Message ethantran 2026-10-29 01:19:00 Re: [PATCH]Fix planner's strictness check for JsonExpr