pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Further fixes for MULTIEXPR_SUBLINK fix.
4+ messages / 1 participants
[nested] [flat]

* pgsql: Further fixes for MULTIEXPR_SUBLINK fix.
@ 2022-09-06 20:38  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2022-09-06 20:38 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Further fixes for MULTIEXPR_SUBLINK fix.

Some more things I didn't think about in commits 3f7323cbb et al:

MULTIEXPR_SUBLINK subplans might have been converted to initplans
instead of regular subplans, in which case they won't show up in
the modified targetlist.  Fortunately, this would only happen if
they have no input parameters, which means that the problem we
originally needed to fix can't happen with them.  Therefore, there's
no need to clone their output parameters, and thus it doesn't hurt
that we'll fail to see them in the first pass over the targetlist.
Nonetheless, this complicates matters greatly, because now we have
to distinguish output Params of initplans (which shouldn't get
renumbered) from those of regular subplans (which should).
This also breaks the simplistic scheme I used of assuming that the
subplans found in the targetlist have consecutive subLinkIds.
We really can't avoid the need to know the subplans' subLinkIds in
this code.  To fix that, add subLinkId as the last field of SubPlan.
We can get away with that change in back branches because SubPlan
nodes will never be stored in the catalogs, and there's no ABI
break for external code that might be looking at the existing
fields of SubPlan.

Secondly, rewriteTargetListIU might have rolled up multiple
FieldStores or SubscriptingRefs into one targetlist entry,
breaking the assumption that there's at most one Param to fix
per targetlist entry.  (That assumption is OK I think in the
ruleutils.c code I stole the logic from in 18f51083c, because
that only deals with pre-rewrite query trees.  But it's
definitely not OK here.)  Abandon that shortcut and just do a
full tree walk on the targetlist to ensure we find all the
Params we have to change.

Per bug #17606 from Andre Lin.  As before, only v10-v13 need the
patch.

Discussion: https://postgr.es/m/17606-e5c8ad18d31db96a@postgresql.org

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/4d7c0fe51d6b4416db0fcc688a3f46574863426a

Modified Files
--------------
src/backend/nodes/copyfuncs.c          |   1 +
src/backend/nodes/equalfuncs.c         |   1 +
src/backend/nodes/outfuncs.c           |   1 +
src/backend/nodes/readfuncs.c          |   1 +
src/backend/optimizer/plan/subselect.c | 139 +++++++++++++++++----------------
src/include/nodes/primnodes.h          |   2 +
src/test/regress/expected/inherit.out  |  41 +++++++---
src/test/regress/sql/inherit.sql       |  16 ++--
8 files changed, 119 insertions(+), 83 deletions(-)



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

* pgsql: Further fixes for MULTIEXPR_SUBLINK fix.
@ 2022-09-06 20:38  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2022-09-06 20:38 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Further fixes for MULTIEXPR_SUBLINK fix.

Some more things I didn't think about in commits 3f7323cbb et al:

MULTIEXPR_SUBLINK subplans might have been converted to initplans
instead of regular subplans, in which case they won't show up in
the modified targetlist.  Fortunately, this would only happen if
they have no input parameters, which means that the problem we
originally needed to fix can't happen with them.  Therefore, there's
no need to clone their output parameters, and thus it doesn't hurt
that we'll fail to see them in the first pass over the targetlist.
Nonetheless, this complicates matters greatly, because now we have
to distinguish output Params of initplans (which shouldn't get
renumbered) from those of regular subplans (which should).
This also breaks the simplistic scheme I used of assuming that the
subplans found in the targetlist have consecutive subLinkIds.
We really can't avoid the need to know the subplans' subLinkIds in
this code.  To fix that, add subLinkId as the last field of SubPlan.
We can get away with that change in back branches because SubPlan
nodes will never be stored in the catalogs, and there's no ABI
break for external code that might be looking at the existing
fields of SubPlan.

Secondly, rewriteTargetListIU might have rolled up multiple
FieldStores or SubscriptingRefs into one targetlist entry,
breaking the assumption that there's at most one Param to fix
per targetlist entry.  (That assumption is OK I think in the
ruleutils.c code I stole the logic from in 18f51083c, because
that only deals with pre-rewrite query trees.  But it's
definitely not OK here.)  Abandon that shortcut and just do a
full tree walk on the targetlist to ensure we find all the
Params we have to change.

Per bug #17606 from Andre Lin.  As before, only v10-v13 need the
patch.

Discussion: https://postgr.es/m/17606-e5c8ad18d31db96a@postgresql.org

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9bcf6fb281de1a30cd6ced443451d5ab9ac4447f

Modified Files
--------------
src/backend/nodes/copyfuncs.c          |   1 +
src/backend/nodes/equalfuncs.c         |   1 +
src/backend/nodes/outfuncs.c           |   1 +
src/backend/nodes/readfuncs.c          |   1 +
src/backend/optimizer/plan/subselect.c | 139 +++++++++++++++++----------------
src/include/nodes/primnodes.h          |   2 +
src/test/regress/expected/inherit.out  |  41 +++++++---
src/test/regress/sql/inherit.sql       |  16 ++--
8 files changed, 119 insertions(+), 83 deletions(-)



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

* pgsql: Further fixes for MULTIEXPR_SUBLINK fix.
@ 2022-09-06 20:38  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2022-09-06 20:38 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Further fixes for MULTIEXPR_SUBLINK fix.

Some more things I didn't think about in commits 3f7323cbb et al:

MULTIEXPR_SUBLINK subplans might have been converted to initplans
instead of regular subplans, in which case they won't show up in
the modified targetlist.  Fortunately, this would only happen if
they have no input parameters, which means that the problem we
originally needed to fix can't happen with them.  Therefore, there's
no need to clone their output parameters, and thus it doesn't hurt
that we'll fail to see them in the first pass over the targetlist.
Nonetheless, this complicates matters greatly, because now we have
to distinguish output Params of initplans (which shouldn't get
renumbered) from those of regular subplans (which should).
This also breaks the simplistic scheme I used of assuming that the
subplans found in the targetlist have consecutive subLinkIds.
We really can't avoid the need to know the subplans' subLinkIds in
this code.  To fix that, add subLinkId as the last field of SubPlan.
We can get away with that change in back branches because SubPlan
nodes will never be stored in the catalogs, and there's no ABI
break for external code that might be looking at the existing
fields of SubPlan.

Secondly, rewriteTargetListIU might have rolled up multiple
FieldStores or SubscriptingRefs into one targetlist entry,
breaking the assumption that there's at most one Param to fix
per targetlist entry.  (That assumption is OK I think in the
ruleutils.c code I stole the logic from in 18f51083c, because
that only deals with pre-rewrite query trees.  But it's
definitely not OK here.)  Abandon that shortcut and just do a
full tree walk on the targetlist to ensure we find all the
Params we have to change.

Per bug #17606 from Andre Lin.  As before, only v10-v13 need the
patch.

Discussion: https://postgr.es/m/17606-e5c8ad18d31db96a@postgresql.org

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/ccbb54c72990d412552fbc50098b2e998b888359

Modified Files
--------------
src/backend/nodes/copyfuncs.c          |   1 +
src/backend/nodes/equalfuncs.c         |   1 +
src/backend/nodes/outfuncs.c           |   1 +
src/backend/nodes/readfuncs.c          |   1 +
src/backend/optimizer/plan/subselect.c | 139 +++++++++++++++++----------------
src/include/nodes/primnodes.h          |   2 +
src/test/regress/expected/inherit.out  |  41 +++++++---
src/test/regress/sql/inherit.sql       |  16 ++--
8 files changed, 119 insertions(+), 83 deletions(-)



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

* pgsql: Further fixes for MULTIEXPR_SUBLINK fix.
@ 2022-09-06 20:38  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2022-09-06 20:38 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Further fixes for MULTIEXPR_SUBLINK fix.

Some more things I didn't think about in commits 3f7323cbb et al:

MULTIEXPR_SUBLINK subplans might have been converted to initplans
instead of regular subplans, in which case they won't show up in
the modified targetlist.  Fortunately, this would only happen if
they have no input parameters, which means that the problem we
originally needed to fix can't happen with them.  Therefore, there's
no need to clone their output parameters, and thus it doesn't hurt
that we'll fail to see them in the first pass over the targetlist.
Nonetheless, this complicates matters greatly, because now we have
to distinguish output Params of initplans (which shouldn't get
renumbered) from those of regular subplans (which should).
This also breaks the simplistic scheme I used of assuming that the
subplans found in the targetlist have consecutive subLinkIds.
We really can't avoid the need to know the subplans' subLinkIds in
this code.  To fix that, add subLinkId as the last field of SubPlan.
We can get away with that change in back branches because SubPlan
nodes will never be stored in the catalogs, and there's no ABI
break for external code that might be looking at the existing
fields of SubPlan.

Secondly, rewriteTargetListIU might have rolled up multiple
FieldStores or SubscriptingRefs into one targetlist entry,
breaking the assumption that there's at most one Param to fix
per targetlist entry.  (That assumption is OK I think in the
ruleutils.c code I stole the logic from in 18f51083c, because
that only deals with pre-rewrite query trees.  But it's
definitely not OK here.)  Abandon that shortcut and just do a
full tree walk on the targetlist to ensure we find all the
Params we have to change.

Per bug #17606 from Andre Lin.  As before, only v10-v13 need the
patch.

Discussion: https://postgr.es/m/17606-e5c8ad18d31db96a@postgresql.org

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/174c929e3ba03c90cf5386436be05a00ea5ed36a

Modified Files
--------------
src/backend/nodes/copyfuncs.c          |   1 +
src/backend/nodes/equalfuncs.c         |   1 +
src/backend/nodes/outfuncs.c           |   1 +
src/backend/nodes/readfuncs.c          |   1 +
src/backend/optimizer/plan/subselect.c | 139 +++++++++++++++++----------------
src/include/nodes/primnodes.h          |   2 +
src/test/regress/expected/inherit.out  |  41 +++++++---
src/test/regress/sql/inherit.sql       |  16 ++--
8 files changed, 119 insertions(+), 83 deletions(-)



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


end of thread, other threads:[~2022-09-06 20:38 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-09-06 20:38 pgsql: Further fixes for MULTIEXPR_SUBLINK fix. Tom Lane <tgl@sss.pgh.pa.us>
2022-09-06 20:38 pgsql: Further fixes for MULTIEXPR_SUBLINK fix. Tom Lane <tgl@sss.pgh.pa.us>
2022-09-06 20:38 pgsql: Further fixes for MULTIEXPR_SUBLINK fix. Tom Lane <tgl@sss.pgh.pa.us>
2022-09-06 20:38 pgsql: Further fixes for MULTIEXPR_SUBLINK fix. Tom Lane <tgl@sss.pgh.pa.us>

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