pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Don't reprocess PHV copies within outer aggregates' arguments
5+ messages / 1 participants
[nested] [flat]

* pgsql: Don't reprocess PHV copies within outer aggregates' arguments
@ 2026-10-06 02:00  Richard Guo <rguo@postgresql.org>
  0 siblings, 0 replies; 5+ messages in thread

From: Richard Guo @ 2026-10-06 02:00 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Don't reprocess PHV copies within outer aggregates' arguments

Since commit e28cf96e9, the copies of a query level's PlaceHolderVars
that were pushed down into its subqueries are preprocessed by that
level before its SubLinks are turned into SubPlans, so such a copy may
already contain SubPlans by the time the subquery is planned.  That
commit taught build_subplan not to process the SubLinks of a PHV that
is passed down as a SubPlan argument, but overlooked that such a copy
can also appear within the arguments of an outer-level Aggref,
GroupingFunc, or ReturningExpr.  The SubLinks in those arguments are
still processed when build_subplan collects the node, and that
processing descended into the already-preprocessed PHV and tripped the
no-SubPlan assertion in process_sublinks_mutator.

To fix, don't descend into PHVs when processing the SubLinks in such a
node's arguments.  Any PHV found there is a pushed-down copy that its
owning level has already preprocessed.

Back-patch to v16, as with commit e28cf96e9.

Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Richard Guo <guofenglinux@gmail.com>
Discussion: https://postgr.es/m/CAJTYsWW8THbrnsmYnDqnUgg0PjGrqw2vNOWb8qx7eu191KPW3g@mail.gmail.com
Backpatch-through: 16

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/3bfc7c8491e6744fd0a1d98f7a98b01528eeae41

Modified Files
--------------
src/backend/optimizer/plan/subselect.c | 18 +++++++++++++++---
src/test/regress/expected/join.out     | 25 +++++++++++++++++++++++++
src/test/regress/sql/join.sql          |  6 ++++++
3 files changed, 46 insertions(+), 3 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* pgsql: Don't reprocess PHV copies within outer aggregates' arguments
@ 2026-10-06 02:00  Richard Guo <rguo@postgresql.org>
  0 siblings, 0 replies; 5+ messages in thread

From: Richard Guo @ 2026-10-06 02:00 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Don't reprocess PHV copies within outer aggregates' arguments

Since commit e28cf96e9, the copies of a query level's PlaceHolderVars
that were pushed down into its subqueries are preprocessed by that
level before its SubLinks are turned into SubPlans, so such a copy may
already contain SubPlans by the time the subquery is planned.  That
commit taught build_subplan not to process the SubLinks of a PHV that
is passed down as a SubPlan argument, but overlooked that such a copy
can also appear within the arguments of an outer-level Aggref,
GroupingFunc, or ReturningExpr.  The SubLinks in those arguments are
still processed when build_subplan collects the node, and that
processing descended into the already-preprocessed PHV and tripped the
no-SubPlan assertion in process_sublinks_mutator.

To fix, don't descend into PHVs when processing the SubLinks in such a
node's arguments.  Any PHV found there is a pushed-down copy that its
owning level has already preprocessed.

Back-patch to v16, as with commit e28cf96e9.

Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Richard Guo <guofenglinux@gmail.com>
Discussion: https://postgr.es/m/CAJTYsWW8THbrnsmYnDqnUgg0PjGrqw2vNOWb8qx7eu191KPW3g@mail.gmail.com
Backpatch-through: 16

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/00d1b4598aba11a82c406120eb86d38c6f3f5c6c

Modified Files
--------------
src/backend/optimizer/plan/subselect.c | 20 ++++++++++++++++----
src/test/regress/expected/join.out     | 25 +++++++++++++++++++++++++
src/test/regress/sql/join.sql          |  6 ++++++
3 files changed, 47 insertions(+), 4 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* pgsql: Don't reprocess PHV copies within outer aggregates' arguments
@ 2026-10-06 02:00  Richard Guo <rguo@postgresql.org>
  0 siblings, 0 replies; 5+ messages in thread

From: Richard Guo @ 2026-10-06 02:00 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Don't reprocess PHV copies within outer aggregates' arguments

Since commit e28cf96e9, the copies of a query level's PlaceHolderVars
that were pushed down into its subqueries are preprocessed by that
level before its SubLinks are turned into SubPlans, so such a copy may
already contain SubPlans by the time the subquery is planned.  That
commit taught build_subplan not to process the SubLinks of a PHV that
is passed down as a SubPlan argument, but overlooked that such a copy
can also appear within the arguments of an outer-level Aggref,
GroupingFunc, or ReturningExpr.  The SubLinks in those arguments are
still processed when build_subplan collects the node, and that
processing descended into the already-preprocessed PHV and tripped the
no-SubPlan assertion in process_sublinks_mutator.

To fix, don't descend into PHVs when processing the SubLinks in such a
node's arguments.  Any PHV found there is a pushed-down copy that its
owning level has already preprocessed.

Back-patch to v16, as with commit e28cf96e9.

Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Richard Guo <guofenglinux@gmail.com>
Discussion: https://postgr.es/m/CAJTYsWW8THbrnsmYnDqnUgg0PjGrqw2vNOWb8qx7eu191KPW3g@mail.gmail.com
Backpatch-through: 16

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/533915857a67a8a717654c81692e617b893e2a3f

Modified Files
--------------
src/backend/optimizer/plan/subselect.c | 20 ++++++++++++++++----
src/test/regress/expected/join.out     | 25 +++++++++++++++++++++++++
src/test/regress/sql/join.sql          |  6 ++++++
3 files changed, 47 insertions(+), 4 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* pgsql: Don't reprocess PHV copies within outer aggregates' arguments
@ 2026-10-06 02:00  Richard Guo <rguo@postgresql.org>
  0 siblings, 0 replies; 5+ messages in thread

From: Richard Guo @ 2026-10-06 02:00 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Don't reprocess PHV copies within outer aggregates' arguments

Since commit e28cf96e9, the copies of a query level's PlaceHolderVars
that were pushed down into its subqueries are preprocessed by that
level before its SubLinks are turned into SubPlans, so such a copy may
already contain SubPlans by the time the subquery is planned.  That
commit taught build_subplan not to process the SubLinks of a PHV that
is passed down as a SubPlan argument, but overlooked that such a copy
can also appear within the arguments of an outer-level Aggref,
GroupingFunc, or ReturningExpr.  The SubLinks in those arguments are
still processed when build_subplan collects the node, and that
processing descended into the already-preprocessed PHV and tripped the
no-SubPlan assertion in process_sublinks_mutator.

To fix, don't descend into PHVs when processing the SubLinks in such a
node's arguments.  Any PHV found there is a pushed-down copy that its
owning level has already preprocessed.

Back-patch to v16, as with commit e28cf96e9.

Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Richard Guo <guofenglinux@gmail.com>
Discussion: https://postgr.es/m/CAJTYsWW8THbrnsmYnDqnUgg0PjGrqw2vNOWb8qx7eu191KPW3g@mail.gmail.com
Backpatch-through: 16

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6b858a36ddb80bfa4f478afebe3e84de72600e02

Modified Files
--------------
src/backend/optimizer/plan/subselect.c | 18 +++++++++++++++---
src/test/regress/expected/join.out     | 25 +++++++++++++++++++++++++
src/test/regress/sql/join.sql          |  6 ++++++
3 files changed, 46 insertions(+), 3 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* pgsql: Don't reprocess PHV copies within outer aggregates' arguments
@ 2026-10-06 02:00  Richard Guo <rguo@postgresql.org>
  0 siblings, 0 replies; 5+ messages in thread

From: Richard Guo @ 2026-10-06 02:00 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Don't reprocess PHV copies within outer aggregates' arguments

Since commit e28cf96e9, the copies of a query level's PlaceHolderVars
that were pushed down into its subqueries are preprocessed by that
level before its SubLinks are turned into SubPlans, so such a copy may
already contain SubPlans by the time the subquery is planned.  That
commit taught build_subplan not to process the SubLinks of a PHV that
is passed down as a SubPlan argument, but overlooked that such a copy
can also appear within the arguments of an outer-level Aggref,
GroupingFunc, or ReturningExpr.  The SubLinks in those arguments are
still processed when build_subplan collects the node, and that
processing descended into the already-preprocessed PHV and tripped the
no-SubPlan assertion in process_sublinks_mutator.

To fix, don't descend into PHVs when processing the SubLinks in such a
node's arguments.  Any PHV found there is a pushed-down copy that its
owning level has already preprocessed.

Back-patch to v16, as with commit e28cf96e9.

Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Richard Guo <guofenglinux@gmail.com>
Discussion: https://postgr.es/m/CAJTYsWW8THbrnsmYnDqnUgg0PjGrqw2vNOWb8qx7eu191KPW3g@mail.gmail.com
Backpatch-through: 16

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/8bcb6f901e4c7ec819cbfc88c64225f9fa9808f4

Modified Files
--------------
src/backend/optimizer/plan/subselect.c | 18 +++++++++++++++---
src/test/regress/expected/join.out     | 25 +++++++++++++++++++++++++
src/test/regress/sql/join.sql          |  6 ++++++
3 files changed, 46 insertions(+), 3 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2026-10-06 02:00 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-10-06 02:00 pgsql: Don't reprocess PHV copies within outer aggregates' arguments Richard Guo <rguo@postgresql.org>
2026-10-06 02:00 pgsql: Don't reprocess PHV copies within outer aggregates' arguments Richard Guo <rguo@postgresql.org>
2026-10-06 02:00 pgsql: Don't reprocess PHV copies within outer aggregates' arguments Richard Guo <rguo@postgresql.org>
2026-10-06 02:00 pgsql: Don't reprocess PHV copies within outer aggregates' arguments Richard Guo <rguo@postgresql.org>
2026-10-06 02:00 pgsql: Don't reprocess PHV copies within outer aggregates' arguments Richard Guo <rguo@postgresql.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox