Skip to content

Commit 7b2ccc5

Browse files
committed
Fix rule-detection code for MERGE.
Use the relation's rd_rules structure to test whether it has rules, rather than the relhasrules flag, which might be out of date. Reviewed by Tom Lane. Backpatch to 15, where MERGE was added. Discussion: https://postgr.es/m/CAEZATCVkBVZABfw71sYvkcPf6tarcOFST5Bc6AOi-LFT9YdccQ%40mail.gmail.com
1 parent b1d0158 commit 7b2ccc5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/backend/parser/parse_merge.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ transformMergeStmt(ParseState *pstate, MergeStmt *stmt)
182182
errmsg("cannot execute MERGE on relation \"%s\"",
183183
RelationGetRelationName(pstate->p_target_relation)),
184184
errdetail_relkind_not_supported(pstate->p_target_relation->rd_rel->relkind)));
185-
if (pstate->p_target_relation->rd_rel->relhasrules)
185+
if (pstate->p_target_relation->rd_rules != NULL &&
186+
pstate->p_target_relation->rd_rules->numLocks > 0)
186187
ereport(ERROR,
187188
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
188189
errmsg("cannot execute MERGE on relation \"%s\"",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy