aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2022-10-24 12:52:43 +0200
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2022-10-24 12:52:43 +0200
commitfb2a83b2b750a32ddfd107a75a3bc173f4f0a81f (patch)
treec509bb1109ab06e6d50812b0c8771e22657e9eea /src/backend/parser
parent4a6de748d3429cfa081942c46411d62341867bfd (diff)
downloadpostgresql-fb2a83b2b750a32ddfd107a75a3bc173f4f0a81f.tar.gz
postgresql-fb2a83b2b750a32ddfd107a75a3bc173f4f0a81f.zip
Update some comments that should've covered MERGE
Oversight in 7103ebb7aae8. Backpatch to 15. Author: Richard Guo <guofenglinux@gmail.com> Discussion: https://postgr.es/m/CAMbWs48gnDjZXq3-b56dVpQCNUJ5hD9kdtWN4QFwKCEapspNsA@mail.gmail.com
Diffstat (limited to 'src/backend/parser')
-rw-r--r--src/backend/parser/parse_clause.c6
-rw-r--r--src/backend/parser/parse_expr.c4
-rw-r--r--src/backend/parser/parse_merge.c6
3 files changed, 11 insertions, 5 deletions
diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c
index 05df373697b..d821969a7d6 100644
--- a/src/backend/parser/parse_clause.c
+++ b/src/backend/parser/parse_clause.c
@@ -153,7 +153,7 @@ transformFromClause(ParseState *pstate, List *frmList)
/*
* setTargetTable
- * Add the target relation of INSERT/UPDATE/DELETE to the range table,
+ * Add the target relation of INSERT/UPDATE/DELETE/MERGE to the range table,
* and make the special links to it in the ParseState.
*
* We also open the target relation and acquire a write lock on it.
@@ -163,7 +163,9 @@ transformFromClause(ParseState *pstate, List *frmList)
*
* If alsoSource is true, add the target to the query's joinlist and
* namespace. For INSERT, we don't want the target to be joined to;
- * it's a destination of tuples, not a source. For UPDATE/DELETE,
+ * it's a destination of tuples, not a source. MERGE is actually
+ * both, but we'll add it separately to joinlist and namespace, so
+ * doing nothing (like INSERT) is correct here. For UPDATE/DELETE,
* we do need to scan or join the target. (NOTE: we do not bother
* to check for namespace conflict; we assume that the namespace was
* initially empty in these cases.)
diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c
index 1c368079397..312d2c7ebaf 100644
--- a/src/backend/parser/parse_expr.c
+++ b/src/backend/parser/parse_expr.c
@@ -1689,8 +1689,8 @@ transformSubLink(ParseState *pstate, SubLink *sublink)
/*
* Check to see if the sublink is in an invalid place within the query. We
- * allow sublinks everywhere in SELECT/INSERT/UPDATE/DELETE, but generally
- * not in utility statements.
+ * allow sublinks everywhere in SELECT/INSERT/UPDATE/DELETE/MERGE, but
+ * generally not in utility statements.
*/
err = NULL;
switch (pstate->p_expr_kind)
diff --git a/src/backend/parser/parse_merge.c b/src/backend/parser/parse_merge.c
index bb9d76306b7..7913523b1c6 100644
--- a/src/backend/parser/parse_merge.c
+++ b/src/backend/parser/parse_merge.c
@@ -163,7 +163,11 @@ transformMergeStmt(ParseState *pstate, MergeStmt *stmt)
errmsg("unreachable WHEN clause specified after unconditional WHEN clause")));
}
- /* Set up the MERGE target table. */
+ /*
+ * Set up the MERGE target table. The target table is added to the
+ * namespace below and to joinlist in transform_MERGE_to_join, so don't
+ * do it here.
+ */
qry->resultRelation = setTargetTable(pstate, stmt->relation,
stmt->relation->inh,
false, targetPerms);