-
Notifications
You must be signed in to change notification settings - Fork 66
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
Fix drop database issue after MVU to PG17 #474
Fix drop database issue after MVU to PG17 #474
Conversation
Signed-off-by: Sumit Jaiswal <[email protected]>
src/backend/catalog/aclchk.c
Outdated
if (bbf_get_sysadmin_oid_hook && | ||
classid == DatabaseRelationId && | ||
is_member_of_role(GetUserId(), sysadminOid = (*bbf_get_sysadmin_oid_hook)())) | ||
{ | ||
grantorId = sysadminOid; | ||
} |
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.
- Will Grantor always be sysadmin in case of Babelfish? At the time of inserting the init_privs, how are we deciding the grantor? If we see possibility that grantor being diff. from sysadmin then we should utilise
select_best_grantor()
- Will it by triggered for other physical databases? Ideally it shouldn't. If it is then, I would suggest add check for babelfish physical db oid comparison if possible.
- We should check whether it is babelfish role or not as well.
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.
Discussed it offline and added check for babelfish database.
Signed-off-by: Sumit Jaiswal <[email protected]>
src/backend/catalog/aclchk.c
Outdated
*/ | ||
if (bbf_get_sysadmin_oid_hook && | ||
classid == DatabaseRelationId && | ||
objid == get_database_oid(GetConfigOption("babelfishpg_tsql.database_name", true, false), true) && |
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.
What if GetConfigOption("babelfishpg_tsql.database_name", true, false)
returns NULL?
Can you please include some manual testing from PG endpoint in the description which makes sure that it is not interfering when hitting this code path from different physical database?
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.
added check for that as well.
Signed-off-by: Sumit Jaiswal <[email protected]>
f9e9557
into
babelfish-for-postgresql:BABEL_5_X_DEV__PG_17_X
…gresql#474)" This reverts commit f9e9557.
Description
After performing MVU to PG17, we weren't able to drop the existing database because a new dependency was getting added between the
dbo
system role and physical babelfish database. This dependency is getting introduced when running the TSQL upgrade script babelfishpg_tsql--3.4.0--4.0.0.sql, which grants permissions to the bbf_role_admin role. The new dependency is expected and is a result of a community change 514a3de. However, even though there is a function RemoveRoleFromInitPriv() to clean up these dependencies when executing DROP OWNED BY commands, it is not working correctly for system roles. This is because the function assumes the grantor of rights is always the same as the owner, which is not the case for system roles, where the grantor should be sysadmin.This commit made changes to use sysadmin as grantor when generating ACLs for physical babelfish database while removing role from initial privileges.
Signed-off-by: Sumit Jaiswal [email protected]
Related Task: BABEL-5410
Check List
By submitting this pull request, I confirm that my contribution is under the terms of the PostgreSQL license, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.