From 4b529266ebf18f95ca4e8c335d2a494812cf65bd Mon Sep 17 00:00:00 2001 From: Shinya Kato Date: Fri, 26 Dec 2025 16:19:26 +0900 Subject: [PATCH v3] Replace relation_{open,close} to table_{open,close} in policy.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RangeVarCallbackForPolicy already ensures policies apply only to tables or partitioned tables, so table_* isthe appropriate API for opening/closing the target relation. Author: Jian He Reviewed-by: Chao Li Reviewed-by: Shinya Kato Reviewed-by: Álvaro Herrera Discussion: https://postgr.es/m/CACJufxFvcqOd6g6uaQqKuKPRgcEfPwp_tLSaaxDiHFBb2snJDA@mail.gmail.com --- src/backend/commands/policy.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/backend/commands/policy.c b/src/backend/commands/policy.c index 5bd5f8c9968..b75592434b8 100644 --- a/src/backend/commands/policy.c +++ b/src/backend/commands/policy.c @@ -15,7 +15,6 @@ #include "access/genam.h" #include "access/htup.h" #include "access/htup_details.h" -#include "access/relation.h" #include "access/table.h" #include "access/xact.h" #include "catalog/catalog.h" @@ -630,7 +629,7 @@ CreatePolicy(CreatePolicyStmt *stmt) stmt); /* Open target_table to build quals. No additional lock is necessary. */ - target_table = relation_open(table_id, NoLock); + target_table = table_open(table_id, NoLock); /* Add for the regular security quals */ nsitem = addRangeTableEntryForRelation(qual_pstate, target_table, @@ -752,7 +751,7 @@ CreatePolicy(CreatePolicyStmt *stmt) free_parsestate(qual_pstate); free_parsestate(with_check_pstate); systable_endscan(sscan); - relation_close(target_table, NoLock); + table_close(target_table, NoLock); table_close(pg_policy_rel, RowExclusiveLock); return myself; @@ -805,7 +804,7 @@ AlterPolicy(AlterPolicyStmt *stmt) RangeVarCallbackForPolicy, stmt); - target_table = relation_open(table_id, NoLock); + target_table = table_open(table_id, NoLock); /* Parse the using policy clause */ if (stmt->qual) @@ -1082,7 +1081,7 @@ AlterPolicy(AlterPolicyStmt *stmt) /* Clean up. */ systable_endscan(sscan); - relation_close(target_table, NoLock); + table_close(target_table, NoLock); table_close(pg_policy_rel, RowExclusiveLock); return myself; @@ -1110,7 +1109,7 @@ rename_policy(RenameStmt *stmt) RangeVarCallbackForPolicy, stmt); - target_table = relation_open(table_id, NoLock); + target_table = table_open(table_id, NoLock); pg_policy_rel = table_open(PolicyRelationId, RowExclusiveLock); @@ -1189,7 +1188,7 @@ rename_policy(RenameStmt *stmt) /* Clean up. */ systable_endscan(sscan); table_close(pg_policy_rel, RowExclusiveLock); - relation_close(target_table, NoLock); + table_close(target_table, NoLock); return address; } -- 2.47.3