Re: BUG #19460: FULL JOIN rewriting issue on empty queries

Richard Guo <guofenglinux@gmail.com>

From: Richard Guo <guofenglinux@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@lists.postgresql.org, francois.jehl@pigment.com, Robert Haas <robertmhaas@gmail.com>
Date: 2026-04-20T23:04:29Z
Lists: pgsql-bugs
On Tue, Apr 21, 2026 at 7:40 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Ah: equivclass.c doesn't mind letting em->em_relids be an alias
> for the left_relids or right_relids of some source RestrictInfo.
> That's not problematic as long as those are all constants after
> construction of the EquivalenceClass, but when remove_rel_from_eclass
> is trying to change things, it's a big problem.

ha, I just came to the same conclusion.

> This seems to do the trick to fix it, although I'm going to wait
> for a valgrind regression run to finish before deciding this
> is enough:

This seems safe enough to me.  LGTM.

- Richard



Commits

  1. Fix relid-set clobber during join removal.

  2. Clean up all relid fields of RestrictInfos during join removal.