summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorNathan Bossart2025-11-14 19:20:09 +0000
committerNathan Bossart2025-11-14 19:20:09 +0000
commit7506bdbbf45ea757f67162a352196976379ccdd7 (patch)
treea7a5533dc551e7e08da0fb9fdb892522e7fb2173 /src/backend
parent4c00960772237325bcdf75f1a068c712e392a69b (diff)
Add note about CreateStatistics()'s selective use of check_rights.HEADmaster
Commit 5e4fcbe531 added a check_rights parameter to this function for use by ALTER TABLE commands that re-create statistics objects. However, we intentionally ignore check_rights when verifying relation ownership because this function's lookup could return a different answer than the caller's. This commit adds a note to this effect so that we remember it down the road. Reviewed-by: Noah Misch <[email protected]> Backpatch-through: 14
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/commands/statscmds.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/backend/commands/statscmds.c b/src/backend/commands/statscmds.c
index 0cf0ea43f19..77b1a6e2dc5 100644
--- a/src/backend/commands/statscmds.c
+++ b/src/backend/commands/statscmds.c
@@ -135,7 +135,13 @@ CreateStatistics(CreateStatsStmt *stmt, bool check_rights)
RelationGetRelationName(rel)),
errdetail_relkind_not_supported(rel->rd_rel->relkind)));
- /* You must own the relation to create stats on it */
+ /*
+ * You must own the relation to create stats on it.
+ *
+ * NB: Concurrent changes could cause this function's lookup to find a
+ * different relation than a previous lookup by the caller, so we must
+ * perform this check even when check_rights == false.
+ */
if (!object_ownercheck(RelationRelationId, RelationGetRelid(rel), stxowner))
aclcheck_error(ACLCHECK_NOT_OWNER, get_relkind_objtype(rel->rd_rel->relkind),
RelationGetRelationName(rel));