Re: Wrong results from self-join elimination with different restriction operators

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tender Wang <tndrwang(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Subject: Re: Wrong results from self-join elimination with different restriction operators
Date: 2026-10-14 20:56:27
Message-ID: 1630846.1792011387@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tender Wang <tndrwang(at)gmail(dot)com> writes:
> After finding the SJE bug involving inheritance scans and ONLY, I
> asked an LLM to generate fuzz tests to look for further issues in
> self-join elimination.
> This uncovered another wrong-result case involving restriction clauses
> with different equality operators.

If we're going to refuse that, I wonder if we couldn't simplify
match_unique_clauses a great deal: just insist that the two OpExpr
clauses be equal(), after the ChangeVarNodes substitution on the outer
clause. Your proposal already breaks commuted-clause cases, which
seem like the only justification for all the futzing around with left
and right operands. I doubt that detecting that is of any real-world
value anyway.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Mircea Cadariu 2026-10-14 20:59:10 Re: parallel data loading for pgbench -i
Previous Message Alexandre Felipe 2026-10-14 20:53:21 Fwd: [patch] bufmgr Half state CAS