aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2022-08-27 12:16:21 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2022-08-27 12:16:21 -0400
commitd1ce745db2d7db193c0be461db3cd34edd776dac (patch)
treeef620b56763eee27cf7aa94b7db20edbecd77110 /src/backend/executor
parent924954c670355f2a0ca1dd4173574a28fc0eedec (diff)
downloadpostgresql-d1ce745db2d7db193c0be461db3cd34edd776dac.tar.gz
postgresql-d1ce745db2d7db193c0be461db3cd34edd776dac.zip
Doc: add comment about bug fixed in back branches as of 3f7323cbb.
While the bug I just fixed in the back branches doesn't exist in HEAD, the requirement that MULTIEXPR SubPlans not share output parameters still does. Add a comment to memorialize that, because perhaps it could be an issue again someday. Discussion: https://postgr.es/m/17596-c5357f61427a81dc@postgresql.org
Diffstat (limited to 'src/backend/executor')
-rw-r--r--src/backend/executor/nodeSubplan.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/backend/executor/nodeSubplan.c b/src/backend/executor/nodeSubplan.c
index 43b36dcd3b4..434c72c9f20 100644
--- a/src/backend/executor/nodeSubplan.c
+++ b/src/backend/executor/nodeSubplan.c
@@ -245,6 +245,21 @@ ExecScanSubPlan(SubPlanState *node,
* ones, so this should be safe.) Unlike ExecReScanSetParamPlan, we do
* *not* set bits in the parent plan node's chgParam, because we don't
* want to cause a rescan of the parent.
+ *
+ * Note: we are also relying on MULTIEXPR SubPlans not sharing any output
+ * parameters with other SubPlans, because if one does then it is unclear
+ * which SubPlanState node the parameter's execPlan field will be pointing
+ * to when we come to evaluate the parameter. We can allow plain initplan
+ * SubPlans to share output parameters, because it doesn't actually matter
+ * which initplan SubPlan we reference as long as they all point to the
+ * same underlying subplan. However, that fails to hold for MULTIEXPRs
+ * because they can have non-empty args lists, and the "same" args might
+ * have mutated into different forms in different parts of a plan tree.
+ * There is currently no problem because MULTIEXPR can appear only in an
+ * UPDATE's top-level target list, so it won't get duplicated anyplace.
+ * Postgres versions before v14 had to make concrete efforts to avoid
+ * sharing output parameters across different clones of a MULTIEXPR, and
+ * the problem could recur someday.
*/
if (subLinkType == MULTIEXPR_SUBLINK)
{