Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2023-03-15 15:59:18 +0000
committerTom Lane2023-03-15 15:59:18 +0000
commite3ac85014eb280ee2e82b36dc3be1b62c838b3e4 (patch)
tree61342f702fda4694a94a96f9a64cf9287a4e308e /src/backend
parenta0137388cb642bcc1ba10fb906b88658653c589d (diff)
Support PlaceHolderVars in MERGE actions.
preprocess_targetlist thought PHVs couldn't appear here. It was mistaken, as per report from Önder Kalacı. Surveying other pull_var_clause calls, I noted no similar errors, but I did notice that qual_is_pushdown_safe's assertion about !contain_window_function was pointless, because the following pull_var_clause call would complain about them anyway. In HEAD only, remove the redundant Assert and improve the commentary. Discussion: https://postgr.es/m/CACawEhUuum-gC_2S3sXLTcsk7bUSPSHOD+g1ZpfKaDK-KKPPWA@mail.gmail.com
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/optimizer/path/allpaths.c12
-rw-r--r--src/backend/optimizer/prep/preptlist.c12
2 files changed, 10 insertions, 14 deletions
diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c
index 479a694bcac..132252b3e44 100644
--- a/src/backend/optimizer/path/allpaths.c
+++ b/src/backend/optimizer/path/allpaths.c
@@ -3840,17 +3840,15 @@ qual_is_pushdown_safe(Query *subquery, Index rti, RestrictInfo *rinfo,
return false;
/*
- * It would be unsafe to push down window function calls, but at least for
- * the moment we could never see any in a qual anyhow. (The same applies
- * to aggregates, which we check for in pull_var_clause below.)
- */
- Assert(!contain_window_function(qual));
-
- /*
* Examine all Vars used in clause. Since it's a restriction clause, all
* such Vars must refer to subselect output columns ... unless this is
* part of a LATERAL subquery, in which case there could be lateral
* references.
+ *
+ * By omitting the relevant flags, this also gives us a cheap sanity check
+ * that no aggregates or window functions appear in the qual. Those would
+ * be unsafe to push down, but at least for the moment we could never see
+ * any in a qual anyhow.
*/
vars = pull_var_clause(qual, PVC_INCLUDE_PLACEHOLDERS);
foreach(vl, vars)
diff --git a/src/backend/optimizer/prep/preptlist.c b/src/backend/optimizer/prep/preptlist.c
index c6d747b275c..2615d7f0b33 100644
--- a/src/backend/optimizer/prep/preptlist.c
+++ b/src/backend/optimizer/prep/preptlist.c
@@ -155,17 +155,15 @@ preprocess_targetlist(PlannerInfo *root)
extract_update_targetlist_colnos(action->targetList);
/*
- * Add resjunk entries for any Vars used in each action's
- * targetlist and WHEN condition that belong to relations other
- * than target. Note that aggregates, window functions and
- * placeholder vars are not possible anywhere in MERGE's WHEN
- * clauses. (PHVs may be added later, but they don't concern us
- * here.)
+ * Add resjunk entries for any Vars and PlaceHolderVars used in
+ * each action's targetlist and WHEN condition that belong to
+ * relations other than the target. We don't expect to see any
+ * aggregates or window functions here.
*/
vars = pull_var_clause((Node *)
list_concat_copy((List *) action->qual,
action->targetList),
- 0);
+ PVC_INCLUDE_PLACEHOLDERS);
foreach(l2, vars)
{
Var *var = (Var *) lfirst(l2);