| From: | Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com> |
|---|---|
| To: | Richard Guo <guofenglinux(at)gmail(dot)com> |
| Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: remove_useless_joins vs. bug #19560 |
| Date: | 2026-09-25 11:43:35 |
| Message-ID: | CAJTYsWW8THbrnsmYnDqnUgg0PjGrqw2vNOWb8qx7eu191KPW3g@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
Could there be one more case here with a PHV inside an outer-level
aggregate? On master at e27f3b2cad7, after bee81f78646, this still
trips an assertion:
create table t (a int);
explain (verbose, costs off)
select (select sum(ss.c) from t i offset 0)
from (select (select s.a) as c from t s) ss
right join t o on true;
TRAP: failed Assert("!IsA(node, SubPlan)"), File: "subselect.c"
IIUC, build_subplan() already leaves a bare PHV argument alone, but
an Aggref argument can contain the same preprocessed PHV. Walking
the Aggref seems to enter that PHV again and reach the SubPlan
created earlier.
Would it make sense to skip PHVs during that argument walk too,
while still processing other SubLinks in the argument? The attached
patch tries that, with small tests for sum() and GROUPING().
I haven't seen a wrong result or crash without assertions though.
Regards,
Ayush
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Don-t-reprocess-PHV-copies-within-outer-level-agg.patch | application/octet-stream | 7.4 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Matheus Alcantara | 2026-09-25 11:45:06 | Re: RI fastpath misses checking EXECUTE on functions |
| Previous Message | Dirkjan Bussink | 2026-09-25 11:29:40 | Server crash when describing a FETCH statement after its cursor is closed |