Skip to content

Commit

Permalink
Use different ownercheck func
Browse files Browse the repository at this point in the history
Signed-off-by: Sharu Goel <[email protected]>
  • Loading branch information
Sharu Goel committed Jan 22, 2025
1 parent 7f9c816 commit 0e269aa
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 19 deletions.
2 changes: 1 addition & 1 deletion contrib/babelfishpg_tsql/src/pl_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ assign_identity_insert(const char *newval, void *extra)
* 1. User is owner of object
* 2. User is member of db_ddladmin or db_owner database role
*/
if (!(has_privs_of_role(curr_user_id, get_pg_class_obj_owner_id(rel_oid)) ||
if (!(object_ownercheck(RelationRelationId, rel_oid, curr_user_id) ||
has_privs_of_role(curr_user_id, get_db_ddladmin_oid(cur_db_name, false)) ||
has_privs_of_role(curr_user_id, get_db_owner_oid(cur_db_name, false))))
throw_error_for_identity_insert(catalog_name, logical_schema_name, rel_name);
Expand Down
1 change: 0 additions & 1 deletion contrib/babelfishpg_tsql/src/pltsql.h
Original file line number Diff line number Diff line change
Expand Up @@ -2100,7 +2100,6 @@ extern int get_insert_bulk_kilobytes_per_batch(void);
extern char *get_original_query_string(void);
extern AclMode string_to_privilege(const char *privname);
extern const char *privilege_to_string(AclMode privilege);
extern Oid get_pg_class_obj_owner_id(Oid relation_oid);
extern Oid get_owner_of_schema(const char *schema);
extern void exec_database_roles_subcmds(const char *physical_schema);

Expand Down
17 changes: 0 additions & 17 deletions contrib/babelfishpg_tsql/src/pltsql_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -2461,23 +2461,6 @@ privilege_to_string(AclMode privilege)
return NULL;
}

Oid
get_pg_class_obj_owner_id(Oid relation_oid)
{
HeapTuple tuple;
Oid ownerId;

tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relation_oid));
if (!HeapTupleIsValid(tuple))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_TABLE),
errmsg("relation with OID %u does not exist", relation_oid)));
ownerId = ((Form_pg_class) GETSTRUCT(tuple))->relowner;
ReleaseSysCache(tuple);

return ownerId;
}

AccessPriv *
make_accesspriv_node(const char *priv_name)
{
Expand Down

0 comments on commit 0e269aa

Please sign in to comment.