| 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-09-03 14:55:05 |
| Message-ID: | 1468659.1788447305@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
[ after a good deal of navel-gazing... ]
Richard Guo <guofenglinux(at)gmail(dot)com> writes:
> I'm also not sure about skipping outer-level PHVs in
> eval_const_expressions. I'm worried that that can cause us to carry
> the raw expressions in the outer query somewhere.
It still feels to me that that's the right thing to do. With your
v2 patch, subquery_planner will have taken care of preprocessing
any outer-level PHVs before the subquery's own preprocessing starts.
If we do that over again, the best-case result is that we waste
cycles. The worst-case result is that we end up with an expression
that looks different from what it looks like in the outer level
and then that causes problems. (I don't have any specific ideas
in mind about how the doubly-processed expression could come to be
different. But if we accept your point that "it's unsafe to do
preprocessing twice", it seems like this is fertile ground for
trouble.)
I think that your v2 patch is fundamentally the right way forward,
but I'm worried that it's not complete yet. In particular it
seems very strange that only flatten_join_alias_vars_mutator needs
to worry about skipping outer-level PHVs. I already explained why
I think eval_const_expressions should too, and I wonder if there
are not other places that should as well. Fundamentally it seems
like the policy across the board ought to be that subqueries keep
their hands off upper-level PHVs. Now, once we've applied
SS_replace_correlation_vars, the question is moot because all such
PHVs will have been replaced by Params, but anything that runs
before that needs a close look.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2026-09-03 14:57:37 | Re: Assert failure in try_nestloop_path() |
| Previous Message | Japin Li | 2026-09-03 14:17:07 | Re: [PATCH] Allow bare library names for non-superuser LOAD |