From e3ac85014eb280ee2e82b36dc3be1b62c838b3e4 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 15 Mar 2023 11:59:18 -0400 Subject: Support PlaceHolderVars in MERGE actions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/backend/optimizer/path/allpaths.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/backend/optimizer/path/allpaths.c') 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 @@ -3839,18 +3839,16 @@ qual_is_pushdown_safe(Query *subquery, Index rti, RestrictInfo *rinfo, contain_leaked_vars(qual)) 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) -- cgit v1.2.3