-
Notifications
You must be signed in to change notification settings - Fork 0
Adding Grantor Information in sys.babelfish_schema_permissions catalog #132
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
Open
shreyeah38
wants to merge
6
commits into
amazon-aurora:bbf-database-permission-view
Choose a base branch
from
shreyeah38:database_permissions
base: bbf-database-permission-view
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f5c15e2
Added full support for sys.database_permissions view
shreyaxr3 cc699cd
Merge remote-tracking branch 'upstream/BABEL_5_X_DEV__PG_17_X' into d…
shreyaxr3 cba6fda
Merge branch 'babelfish-for-postgresql:BABEL_5_X_DEV__PG_17_X' into d…
shreyeah38 fdbe3ec
Merge branch 'database_permissions' of https://github.com/shreyeah38/…
shreyaxr3 f4300bc
Released locks before returning from ExecGrant function
shreyaxr3 8e1ff4c
fixed indentation
shreyaxr3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,6 +173,7 @@ static void recordExtensionInitPrivWorker(Oid objoid, Oid classoid, int objsubid | |
|
||
tsql_has_linked_srv_permissions_hook_type tsql_has_linked_srv_permissions_hook = NULL; | ||
bbf_execute_grantstmt_as_dbsecadmin_hook_type bbf_execute_grantstmt_as_dbsecadmin_hook = NULL; | ||
update_bbf_schema_permissions_catalog_hook_type update_bbf_schema_permissions_catalog_hook = NULL; | ||
pltsql_allow_storing_init_privs_hook_type pltsql_allow_storing_init_privs_hook = NULL; | ||
/* | ||
* If is_grant is true, adds the given privileges for the list of | ||
|
@@ -2052,6 +2053,25 @@ ExecGrant_Relation(InternalGrant *istmt) | |
NameStr(pg_class_tuple->relname), | ||
0, NULL); | ||
|
||
/* | ||
* Call the hook to add the permission in bbf_schema_permissions catalog | ||
* If the hook returns false, indicates that object-level and schema-level grants both are present and schema-level grant is revoked. | ||
* In such case we remove schema-level entry from the bbf_schema_permissions catalog but skip the execution of revoke as object-level grants exist. | ||
*/ | ||
if (update_bbf_schema_permissions_catalog_hook && !(*update_bbf_schema_permissions_catalog_hook) (this_privileges, istmt->is_grant, istmt->grantees, | ||
istmt->col_privs, pg_class_tuple->oid, GetUserNameFromId(grantorId, false), | ||
istmt->grant_option, GetUserNameFromId(ownerId, false), istmt->objtype)) | ||
{ | ||
pfree(old_rel_acl); | ||
pfree(col_privileges); | ||
if (!is_enr) | ||
UnlockTuple(relation, &tuple->t_self, InplaceUpdateTupleLock); | ||
ReleaseSysCache(tuple); | ||
table_close(attRelation, RowExclusiveLock); | ||
table_close(relation, RowExclusiveLock); | ||
return; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we are inside FOR loop here? do we really want to exit early? |
||
} | ||
|
||
/* | ||
* Generate new ACL. | ||
*/ | ||
|
@@ -2272,6 +2292,22 @@ ExecGrant_common(InternalGrant *istmt, Oid classid, AclMode default_privs, | |
NameStr(*DatumGetName(nameDatum)), | ||
0, NULL); | ||
|
||
/* | ||
* Call the hook to add the permission in bbf_schema_permissions catalog | ||
* If the hook returns false, indicates that object-level and schema-level grants both are present and schema-level grant is revoked. | ||
* In such case we remove schema-level entry from the bbf_schema_permissions catalog but skip the execution of revoke as object-level grants exist. | ||
*/ | ||
if (update_bbf_schema_permissions_catalog_hook && !(*update_bbf_schema_permissions_catalog_hook) (this_privileges, istmt->is_grant, istmt->grantees, | ||
istmt->col_privs, objectid, GetUserNameFromId(grantorId, false), | ||
istmt->grant_option, GetUserNameFromId(ownerId, false), istmt->objtype)) | ||
{ | ||
if (!is_enr) | ||
UnlockTuple(relation, &tuple->t_self, InplaceUpdateTupleLock); | ||
ReleaseSysCache(tuple); | ||
table_close(relation, RowExclusiveLock); | ||
return; | ||
} | ||
|
||
/* | ||
* Generate new ACL. | ||
*/ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need dialect check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes there is a dialect check inside the hook.