pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix MULTIEXPR_SUBLINK with partitioned target tables, yet again. 6+ messages / 1 participants [nested] [flat]
* pgsql: Fix MULTIEXPR_SUBLINK with partitioned target tables, yet again. @ 2023-02-25 19:44 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2023-02-25 19:44 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix MULTIEXPR_SUBLINK with partitioned target tables, yet again. We already tried to fix this in commits 3f7323cbb et al (and follow-on fixes), but now it emerges that there are still unfixed cases; moreover, these cases affect all branches not only pre-v14. I thought we had eliminated all cases of making multiple clones of an UPDATE's target list when we nuked inheritance_planner. But it turns out we still do that in some partitioned-UPDATE cases, notably including INSERT ... ON CONFLICT UPDATE, because ExecInitPartitionInfo thinks it's okay to clone and modify the parent's targetlist. This fix is based on a suggestion from Andres Freund: let's stop abusing the ParamExecData.execPlan mechanism, which was only ever meant to handle initplans, and instead solve the execution timing problem by having the expression compiler move MULTIEXPR_SUBLINK steps to the front of their expression step lists. This is feasible because (a) all branches still in support compile the entire targetlist of an UPDATE into a single ExprState, and (b) we know that all MULTIEXPR_SUBLINKs do need to be evaluated --- none could be buried inside a CASE, for example. There is a minor semantics change concerning the order of execution of the MULTIEXPR's subquery versus other parts of the parent targetlist, but that seems like something we can get away with. By doing that, we no longer need to worry about whether different clones of a MULTIEXPR_SUBLINK share output Params; their usage of that data structure won't overlap. Per bug #17800 from Alexander Lakhin. Back-patch to all supported branches. In v13 and earlier, we can revert 3f7323cbb and follow-on fixes; however, I chose to keep the SubPlan.subLinkId field added in ccbb54c72. We don't need that anymore in the core code, but it's cheap enough to fill, and removing a plan node field in a minor release seems like it'd be asking for trouble. Andres Freund and Tom Lane Discussion: https://postgr.es/m/17800-ff90866b3906c964@postgresql.org Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/87f3667ec079c4acc2c87be51bf41e54d0b6f698 Modified Files -------------- src/backend/executor/execExpr.c | 174 ++++++++++++++++++++++------------ src/backend/executor/nodeSubplan.c | 134 +++++++++++++------------- src/include/nodes/primnodes.h | 10 +- src/test/regress/expected/inherit.out | 110 +++++++++++++++++++++ src/test/regress/sql/inherit.sql | 38 ++++++++ 5 files changed, 332 insertions(+), 134 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix MULTIEXPR_SUBLINK with partitioned target tables, yet again. @ 2023-02-25 19:44 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2023-02-25 19:44 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix MULTIEXPR_SUBLINK with partitioned target tables, yet again. We already tried to fix this in commits 3f7323cbb et al (and follow-on fixes), but now it emerges that there are still unfixed cases; moreover, these cases affect all branches not only pre-v14. I thought we had eliminated all cases of making multiple clones of an UPDATE's target list when we nuked inheritance_planner. But it turns out we still do that in some partitioned-UPDATE cases, notably including INSERT ... ON CONFLICT UPDATE, because ExecInitPartitionInfo thinks it's okay to clone and modify the parent's targetlist. This fix is based on a suggestion from Andres Freund: let's stop abusing the ParamExecData.execPlan mechanism, which was only ever meant to handle initplans, and instead solve the execution timing problem by having the expression compiler move MULTIEXPR_SUBLINK steps to the front of their expression step lists. This is feasible because (a) all branches still in support compile the entire targetlist of an UPDATE into a single ExprState, and (b) we know that all MULTIEXPR_SUBLINKs do need to be evaluated --- none could be buried inside a CASE, for example. There is a minor semantics change concerning the order of execution of the MULTIEXPR's subquery versus other parts of the parent targetlist, but that seems like something we can get away with. By doing that, we no longer need to worry about whether different clones of a MULTIEXPR_SUBLINK share output Params; their usage of that data structure won't overlap. Per bug #17800 from Alexander Lakhin. Back-patch to all supported branches. In v13 and earlier, we can revert 3f7323cbb and follow-on fixes; however, I chose to keep the SubPlan.subLinkId field added in ccbb54c72. We don't need that anymore in the core code, but it's cheap enough to fill, and removing a plan node field in a minor release seems like it'd be asking for trouble. Andres Freund and Tom Lane Discussion: https://postgr.es/m/17800-ff90866b3906c964@postgresql.org Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/a033f9165c2c024756d9cd3033263724d53fd9ef Modified Files -------------- src/backend/executor/execExpr.c | 174 ++++++++++++++++++++++------------ src/backend/executor/nodeSubplan.c | 119 +++++++++++++---------- src/include/nodes/primnodes.h | 10 +- src/test/regress/expected/inherit.out | 110 +++++++++++++++++++++ src/test/regress/sql/inherit.sql | 38 ++++++++ 5 files changed, 332 insertions(+), 119 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix MULTIEXPR_SUBLINK with partitioned target tables, yet again. @ 2023-02-25 19:44 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2023-02-25 19:44 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix MULTIEXPR_SUBLINK with partitioned target tables, yet again. We already tried to fix this in commits 3f7323cbb et al (and follow-on fixes), but now it emerges that there are still unfixed cases; moreover, these cases affect all branches not only pre-v14. I thought we had eliminated all cases of making multiple clones of an UPDATE's target list when we nuked inheritance_planner. But it turns out we still do that in some partitioned-UPDATE cases, notably including INSERT ... ON CONFLICT UPDATE, because ExecInitPartitionInfo thinks it's okay to clone and modify the parent's targetlist. This fix is based on a suggestion from Andres Freund: let's stop abusing the ParamExecData.execPlan mechanism, which was only ever meant to handle initplans, and instead solve the execution timing problem by having the expression compiler move MULTIEXPR_SUBLINK steps to the front of their expression step lists. This is feasible because (a) all branches still in support compile the entire targetlist of an UPDATE into a single ExprState, and (b) we know that all MULTIEXPR_SUBLINKs do need to be evaluated --- none could be buried inside a CASE, for example. There is a minor semantics change concerning the order of execution of the MULTIEXPR's subquery versus other parts of the parent targetlist, but that seems like something we can get away with. By doing that, we no longer need to worry about whether different clones of a MULTIEXPR_SUBLINK share output Params; their usage of that data structure won't overlap. Per bug #17800 from Alexander Lakhin. Back-patch to all supported branches. In v13 and earlier, we can revert 3f7323cbb and follow-on fixes; however, I chose to keep the SubPlan.subLinkId field added in ccbb54c72. We don't need that anymore in the core code, but it's cheap enough to fill, and removing a plan node field in a minor release seems like it'd be asking for trouble. Andres Freund and Tom Lane Discussion: https://postgr.es/m/17800-ff90866b3906c964@postgresql.org Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/9eaba06027ae01476a20725e54261e4f64ea023b Modified Files -------------- src/backend/executor/execExpr.c | 174 ++++++++++++++++++++++------------ src/backend/executor/nodeSubplan.c | 119 +++++++++++++---------- src/include/nodes/primnodes.h | 10 +- src/test/regress/expected/inherit.out | 110 +++++++++++++++++++++ src/test/regress/sql/inherit.sql | 38 ++++++++ 5 files changed, 332 insertions(+), 119 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix MULTIEXPR_SUBLINK with partitioned target tables, yet again. @ 2023-02-25 19:44 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2023-02-25 19:44 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix MULTIEXPR_SUBLINK with partitioned target tables, yet again. We already tried to fix this in commits 3f7323cbb et al (and follow-on fixes), but now it emerges that there are still unfixed cases; moreover, these cases affect all branches not only pre-v14. I thought we had eliminated all cases of making multiple clones of an UPDATE's target list when we nuked inheritance_planner. But it turns out we still do that in some partitioned-UPDATE cases, notably including INSERT ... ON CONFLICT UPDATE, because ExecInitPartitionInfo thinks it's okay to clone and modify the parent's targetlist. This fix is based on a suggestion from Andres Freund: let's stop abusing the ParamExecData.execPlan mechanism, which was only ever meant to handle initplans, and instead solve the execution timing problem by having the expression compiler move MULTIEXPR_SUBLINK steps to the front of their expression step lists. This is feasible because (a) all branches still in support compile the entire targetlist of an UPDATE into a single ExprState, and (b) we know that all MULTIEXPR_SUBLINKs do need to be evaluated --- none could be buried inside a CASE, for example. There is a minor semantics change concerning the order of execution of the MULTIEXPR's subquery versus other parts of the parent targetlist, but that seems like something we can get away with. By doing that, we no longer need to worry about whether different clones of a MULTIEXPR_SUBLINK share output Params; their usage of that data structure won't overlap. Per bug #17800 from Alexander Lakhin. Back-patch to all supported branches. In v13 and earlier, we can revert 3f7323cbb and follow-on fixes; however, I chose to keep the SubPlan.subLinkId field added in ccbb54c72. We don't need that anymore in the core code, but it's cheap enough to fill, and removing a plan node field in a minor release seems like it'd be asking for trouble. Andres Freund and Tom Lane Discussion: https://postgr.es/m/17800-ff90866b3906c964@postgresql.org Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/1e199c25994791842fe2f80c0809c2e69a3a7d2e Modified Files -------------- src/backend/executor/execExpr.c | 149 ++++++++++++++++++++++--------- src/backend/executor/nodeSubplan.c | 134 ++++++++++++++-------------- src/backend/optimizer/plan/planner.c | 4 - src/backend/optimizer/plan/subselect.c | 129 --------------------------- src/include/nodes/primnodes.h | 10 +-- src/include/optimizer/subselect.h | 1 - src/test/regress/expected/inherit.out | 158 ++++++++++++++++++++------------- src/test/regress/sql/inherit.sql | 48 ++++++---- 8 files changed, 306 insertions(+), 327 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix MULTIEXPR_SUBLINK with partitioned target tables, yet again. @ 2023-02-25 19:44 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2023-02-25 19:44 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix MULTIEXPR_SUBLINK with partitioned target tables, yet again. We already tried to fix this in commits 3f7323cbb et al (and follow-on fixes), but now it emerges that there are still unfixed cases; moreover, these cases affect all branches not only pre-v14. I thought we had eliminated all cases of making multiple clones of an UPDATE's target list when we nuked inheritance_planner. But it turns out we still do that in some partitioned-UPDATE cases, notably including INSERT ... ON CONFLICT UPDATE, because ExecInitPartitionInfo thinks it's okay to clone and modify the parent's targetlist. This fix is based on a suggestion from Andres Freund: let's stop abusing the ParamExecData.execPlan mechanism, which was only ever meant to handle initplans, and instead solve the execution timing problem by having the expression compiler move MULTIEXPR_SUBLINK steps to the front of their expression step lists. This is feasible because (a) all branches still in support compile the entire targetlist of an UPDATE into a single ExprState, and (b) we know that all MULTIEXPR_SUBLINKs do need to be evaluated --- none could be buried inside a CASE, for example. There is a minor semantics change concerning the order of execution of the MULTIEXPR's subquery versus other parts of the parent targetlist, but that seems like something we can get away with. By doing that, we no longer need to worry about whether different clones of a MULTIEXPR_SUBLINK share output Params; their usage of that data structure won't overlap. Per bug #17800 from Alexander Lakhin. Back-patch to all supported branches. In v13 and earlier, we can revert 3f7323cbb and follow-on fixes; however, I chose to keep the SubPlan.subLinkId field added in ccbb54c72. We don't need that anymore in the core code, but it's cheap enough to fill, and removing a plan node field in a minor release seems like it'd be asking for trouble. Andres Freund and Tom Lane Discussion: https://postgr.es/m/17800-ff90866b3906c964@postgresql.org Branch ------ REL_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/904b171a465583b35ba199d38868e9e49fcb8ef4 Modified Files -------------- src/backend/executor/execExpr.c | 149 ++++++++++++++++++++++--------- src/backend/executor/nodeSubplan.c | 134 ++++++++++++++-------------- src/backend/optimizer/plan/planner.c | 4 - src/backend/optimizer/plan/subselect.c | 129 --------------------------- src/include/nodes/primnodes.h | 10 +-- src/include/optimizer/subselect.h | 1 - src/test/regress/expected/inherit.out | 158 ++++++++++++++++++++------------- src/test/regress/sql/inherit.sql | 48 ++++++---- 8 files changed, 306 insertions(+), 327 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix MULTIEXPR_SUBLINK with partitioned target tables, yet again. @ 2023-02-25 19:44 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2023-02-25 19:44 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix MULTIEXPR_SUBLINK with partitioned target tables, yet again. We already tried to fix this in commits 3f7323cbb et al (and follow-on fixes), but now it emerges that there are still unfixed cases; moreover, these cases affect all branches not only pre-v14. I thought we had eliminated all cases of making multiple clones of an UPDATE's target list when we nuked inheritance_planner. But it turns out we still do that in some partitioned-UPDATE cases, notably including INSERT ... ON CONFLICT UPDATE, because ExecInitPartitionInfo thinks it's okay to clone and modify the parent's targetlist. This fix is based on a suggestion from Andres Freund: let's stop abusing the ParamExecData.execPlan mechanism, which was only ever meant to handle initplans, and instead solve the execution timing problem by having the expression compiler move MULTIEXPR_SUBLINK steps to the front of their expression step lists. This is feasible because (a) all branches still in support compile the entire targetlist of an UPDATE into a single ExprState, and (b) we know that all MULTIEXPR_SUBLINKs do need to be evaluated --- none could be buried inside a CASE, for example. There is a minor semantics change concerning the order of execution of the MULTIEXPR's subquery versus other parts of the parent targetlist, but that seems like something we can get away with. By doing that, we no longer need to worry about whether different clones of a MULTIEXPR_SUBLINK share output Params; their usage of that data structure won't overlap. Per bug #17800 from Alexander Lakhin. Back-patch to all supported branches. In v13 and earlier, we can revert 3f7323cbb and follow-on fixes; however, I chose to keep the SubPlan.subLinkId field added in ccbb54c72. We don't need that anymore in the core code, but it's cheap enough to fill, and removing a plan node field in a minor release seems like it'd be asking for trouble. Andres Freund and Tom Lane Discussion: https://postgr.es/m/17800-ff90866b3906c964@postgresql.org Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/ffec64ba86c40a31e5a1d0c9a53bf923624db51f Modified Files -------------- src/backend/executor/execExpr.c | 149 ++++++++++++++++++++++--------- src/backend/executor/nodeSubplan.c | 134 ++++++++++++++-------------- src/backend/optimizer/plan/planner.c | 4 - src/backend/optimizer/plan/subselect.c | 129 --------------------------- src/include/nodes/primnodes.h | 10 +-- src/include/optimizer/subselect.h | 1 - src/test/regress/expected/inherit.out | 158 ++++++++++++++++++++------------- src/test/regress/sql/inherit.sql | 48 ++++++---- 8 files changed, 306 insertions(+), 327 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2023-02-25 19:44 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2023-02-25 19:44 pgsql: Fix MULTIEXPR_SUBLINK with partitioned target tables, yet again. Tom Lane <tgl@sss.pgh.pa.us> 2023-02-25 19:44 pgsql: Fix MULTIEXPR_SUBLINK with partitioned target tables, yet again. Tom Lane <tgl@sss.pgh.pa.us> 2023-02-25 19:44 pgsql: Fix MULTIEXPR_SUBLINK with partitioned target tables, yet again. Tom Lane <tgl@sss.pgh.pa.us> 2023-02-25 19:44 pgsql: Fix MULTIEXPR_SUBLINK with partitioned target tables, yet again. Tom Lane <tgl@sss.pgh.pa.us> 2023-02-25 19:44 pgsql: Fix MULTIEXPR_SUBLINK with partitioned target tables, yet again. Tom Lane <tgl@sss.pgh.pa.us> 2023-02-25 19:44 pgsql: Fix MULTIEXPR_SUBLINK with partitioned target tables, yet again. 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