-
Notifications
You must be signed in to change notification settings - Fork 382
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
[#6042] refactor: Delete the privilege of catalog after dropping the catalogs #6045
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,8 +126,19 @@ public boolean dropCatalog(NameIdentifier ident) { | |
@Override | ||
public boolean dropCatalog(NameIdentifier ident, boolean force) | ||
throws NonEmptyEntityException, CatalogInUseException { | ||
AuthorizationUtils.authorizationPluginRemovePrivileges(ident, Entity.EntityType.CATALOG); | ||
return dispatcher.dropCatalog(ident, force); | ||
if (!dispatcher.catalogExists(ident)) { | ||
return false; | ||
} | ||
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. Should we 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. If not exist, we should return false directly. Changed. 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. Emm ... think twice about the protocol please.
This is not a mandatory change request. I was just dumping my brain on the 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. If the catalog doesn't exist, we would return false. Our other code follows this rule, too. Only the catalog exists, we would return true. If we occurs some errors, we would throw exceptions. 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. Got it. I wasn't suggesting that this is a right or wrong issue.
This, again, leads us to the situation of multiple exit conditions. We may 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. Thanks for your suggestion. I got your concern. It's a bigger topic. For this pull request, I will the semantic as community discussed before. You can discuss this topic in #5031 if you have concern. |
||
|
||
// If we call the authorization plugin after dropping catalog, we can't load the plugin of the | ||
// catalog | ||
Catalog catalog = dispatcher.loadCatalog(ident); | ||
boolean dropped = dispatcher.dropCatalog(ident, force); | ||
|
||
if (dropped && catalog != null) { | ||
AuthorizationUtils.removeCatalogPrivileges(catalog); | ||
} | ||
return dropped; | ||
} | ||
|
||
@Override | ||
|
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.
There seems no need to extract this logic as a method.
Thoughts?
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.
I prefer putting the logic into
AuthorizationUtils
.callAuthorizationPluginImpl
is a private implement method.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.
Em... then why don't we publicize this
callAuthorizationPluginImpl
?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.
I prefer putting similar logic to one place. Other similar logic are in the class AuthorizationUtils, It's better to maintain the code.
I don't preferring expose more implement methods to other package.