Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance Improvement of create login in BBF #507

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/backend/utils/adt/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ bbf_get_sysadmin_oid_hook_type bbf_get_sysadmin_oid_hook = NULL;
get_bbf_admin_oid_hook_type get_bbf_admin_oid_hook = NULL;
pltsql_get_object_owner_hook_type pltsql_get_object_owner_hook = NULL;
is_bbf_db_ddladmin_operation_hook_type is_bbf_db_ddladmin_operation_hook = NULL;
has_bbf_role_direct_membership_with_admin_true_hook_type has_bbf_role_direct_membership_with_admin_true_hook = NULL;


/*
Expand Down Expand Up @@ -5278,6 +5279,19 @@ is_admin_of_role(Oid member, Oid role)
if (member == role)
return false;

/*
* Check if the given member is bbf_role_admin.
* If the member has the privilege to grant a given role through direct membership,
* returns the member with admin option set to true.
*/
if (sql_dialect == SQL_DIALECT_TSQL
&& get_bbf_admin_oid_hook && member == (*get_bbf_admin_oid_hook)()
anju15bharti marked this conversation as resolved.
Show resolved Hide resolved
&& (has_bbf_role_direct_membership_with_admin_true_hook)
&& (*has_bbf_role_direct_membership_with_admin_true_hook)(role))
{
return member;
anju15bharti marked this conversation as resolved.
Show resolved Hide resolved
}

(void) roles_is_member_of(member, ROLERECURSE_MEMBERS, role, &admin_role);
return OidIsValid(admin_role);
}
Expand Down
3 changes: 3 additions & 0 deletions src/include/utils/acl.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ extern PGDLLEXPORT is_bbf_db_ddladmin_operation_hook_type is_bbf_db_ddladmin_ope
typedef bool (*pltsql_allow_storing_init_privs_hook_type) (Oid objoid, Oid classoid, int objsubid);
extern PGDLLEXPORT pltsql_allow_storing_init_privs_hook_type pltsql_allow_storing_init_privs_hook;

typedef bool (*has_bbf_role_direct_membership_with_admin_true_hook_type) (Oid);
extern PGDLLEXPORT has_bbf_role_direct_membership_with_admin_true_hook_type has_bbf_role_direct_membership_with_admin_true_hook;

#define IS_BBF_DB_DDLADMIN(namespaceId) \
(is_bbf_db_ddladmin_operation_hook && \
is_bbf_db_ddladmin_operation_hook(namespaceId))
Expand Down
Loading