mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
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
This commit is contained in:
@ -182,7 +182,8 @@ transformMergeStmt(ParseState *pstate, MergeStmt *stmt)
|
|||||||
errmsg("cannot execute MERGE on relation \"%s\"",
|
errmsg("cannot execute MERGE on relation \"%s\"",
|
||||||
RelationGetRelationName(pstate->p_target_relation)),
|
RelationGetRelationName(pstate->p_target_relation)),
|
||||||
errdetail_relkind_not_supported(pstate->p_target_relation->rd_rel->relkind)));
|
errdetail_relkind_not_supported(pstate->p_target_relation->rd_rel->relkind)));
|
||||||
if (pstate->p_target_relation->rd_rel->relhasrules)
|
if (pstate->p_target_relation->rd_rules != NULL &&
|
||||||
|
pstate->p_target_relation->rd_rules->numLocks > 0)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
errmsg("cannot execute MERGE on relation \"%s\"",
|
errmsg("cannot execute MERGE on relation \"%s\"",
|
||||||
|
Reference in New Issue
Block a user