Re: remove_useless_joins vs. bug #19560

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: Tender Wang <tndrwang(at)gmail(dot)com>, Thom Brown <thom(at)linux(dot)com>, Jacob Brazeal <jacob(dot)brazeal(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: remove_useless_joins vs. bug #19560
Date: 2026-08-30 16:20:41
Message-ID: 495449.1788106841@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Richard Guo <guofenglinux(at)gmail(dot)com> writes:
> ... The exception is
> flatten_join_alias_vars, which descends into every PHV and asserts on
> SubPlans. I changed it to leave PHVs of upper levels alone; such a
> PHV cannot contain join aliases of the level being flattened anyway.

BTW, this comment reminds me strongly of an earlier draft I had,
which eliminated the assertion failure by just not letting
ChangeVarNodes recurse into outer-level PHVs, on the grounds that
we can ignore their contents until they get replaced by Params.
That didn't seem terribly principled on its own, so I also made
eval_const_expressions not do anything to outer-level PHVs, but
then I started to wonder just how far the implications should extend.
When I realized that a localized fix in extract_lateral_references()
seemed possible I gave up on that approach. But maybe it's the way
to go. It has the attractive property of removing useless work.
Attached is as far as I got with the idea before switching to the
other way.

regards, tom lane

Attachment Content-Type Size
skip-outer-level-PHVs.patch text/x-diff 5.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Osama Abdul Qader 2026-08-30 16:22:46 Re: REPACK (ANALYZE) within transaction block segfaults
Previous Message Tom Lane 2026-08-30 15:33:43 Re: remove_useless_joins vs. bug #19560