-
Notifications
You must be signed in to change notification settings - Fork 383
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
[#1231] Fix bugs in drop MySQL schemas #1235
Conversation
.../src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlDatabaseOperations.java
Outdated
Show resolved
Hide resolved
if (cascade) { | ||
throw new UnsupportedOperationException( | ||
"MySQL does not support CASCADE option for DROP DATABASE."); | ||
return dropDatabaseSql; |
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.
Need to handle database not empty.
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.
Is the condition !cascade
?
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.
Is the condition
!cascade
?
No, MySQL will automatically delete all tables in the database when it is removed.
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.
Why @Clearvive said that MySQL doesn't support cascading drop, have you verified with different MySQL versions, is it a consistent behavior?
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.
MySQL does support cascading deletion of schema, execute drop database {database_name}
will drop all tables under it.
@Clearvive , Please check it.
@Clearvive can you please help to review? |
@Clearvive , could you please assist in viewing this? thanks |
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.
LGTM
.../src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlDatabaseOperations.java
Show resolved
Hide resolved
### What changes were proposed in this pull request? - Allow dropping a database when `cascase` is `true`. - If the database is not empty and `cascade` is `false`, disable the drop operation. ### Why are the changes needed? Align the logic with Gravitino EntityStore. Fix: #1231 ### Does this PR introduce _any_ user-facing change? N/A ### How was this patch tested? Add UT `testDropMySQLDatabase`
What changes were proposed in this pull request?
cascase
istrue
.cascade
isfalse
, disable the drop operation.Why are the changes needed?
Align the logic with Gravitino EntityStore.
Fix: #1231
Does this PR introduce any user-facing change?
N/A
How was this patch tested?
Add UT
testDropMySQLDatabase