Skip to content

Commit

Permalink
PG16: Replace pg_class_ownercheck() with object_ownercheck
Browse files Browse the repository at this point in the history
PG16 replaces pg_foo_ownercheck() functions with a common
object_ownercheck() function. Added a new compat function for
pg_class_ownercheck() function affected by this change and replaced all
its callers.

postgres/postgres@afbfc029
  • Loading branch information
lkshminarayanan committed Aug 9, 2023
1 parent 22ea577 commit a9505b4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
17 changes: 17 additions & 0 deletions src/compat/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,23 @@ object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode)
}
return ACLCHECK_NOT_OWNER;
}

/*
* PG16 replaces pg_foo_ownercheck() functions with a common object_ownercheck() function
* https://github.com/postgres/postgres/commit/afbfc029
*/
static inline bool
object_ownercheck(Oid classid, Oid objectid, Oid roleid)
{
switch (classid)
{
case RelationRelationId:
return pg_class_ownercheck(objectid, roleid);
default:
Assert(false);
}
return false;
}
#endif

#endif /* TIMESCALEDB_COMPAT_H */
2 changes: 1 addition & 1 deletion tsl/src/continuous_aggs/refresh.c
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ continuous_agg_refresh_internal(const ContinuousAgg *cagg,
ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), (errmsg("could not set search_path"))));

/* Like regular materialized views, require owner to refresh. */
if (!pg_class_ownercheck(cagg->relid, GetUserId()))
if (!object_ownercheck(RelationRelationId, cagg->relid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER,
get_relkind_objtype(get_rel_relkind(cagg->relid)),
get_rel_name(cagg->relid));
Expand Down
4 changes: 2 additions & 2 deletions tsl/src/reorder.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ reorder_chunk(Oid chunk_id, Oid index_id, bool verbose, Oid wait_id, Oid destina
/* Our check gives better error messages, but keep the original one too. */
ts_hypertable_permissions_check(ht->main_table_relid, GetUserId());

if (!pg_class_ownercheck(ht->main_table_relid, GetUserId()))
if (!object_ownercheck(RelationRelationId, ht->main_table_relid, GetUserId()))
{
Oid main_table_relid = ht->main_table_relid;

Expand Down Expand Up @@ -565,7 +565,7 @@ reorder_rel(Oid tableOid, Oid indexOid, bool verbose, Oid wait_id, Oid destinati
* that the relation still is what we think it is.
*/
/* Check that the user still owns the relation */
if (!pg_class_ownercheck(tableOid, GetUserId()))
if (!object_ownercheck(RelationRelationId, tableOid, GetUserId()))
{
relation_close(OldHeap, ExclusiveLock);
ereport(WARNING, (errcode(ERRCODE_WARNING), errmsg("ownership changed during reorder")));
Expand Down

0 comments on commit a9505b4

Please sign in to comment.