[Refactor] Refactor USE and SHOW CREATE DATABASE and RECOVER DATABASE statements to fe-parser #63683
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.
Why I'm doing:
What I'm doing:
This pull request refactors and improves the handling of catalog and database statements, especially around the
USE
,SHOW CREATE DATABASE
, andRECOVER DATABASE
statements. The changes ensure stricter validation of catalog presence, improve normalization and case-insensitivity, and enhance test coverage for these behaviors.Key improvements and changes:
1. Catalog Validation and Error Handling
USE
,SHOW CREATE DATABASE
, andRECOVER DATABASE
statements. Throws a semantic exception with a clear error message if not set. (BasicDbStmtAnalyzer.java
,AuthorizerStmtVisitor.java
) [1] [2] [3]BasicDbStmtAnalyzer.java
)2. Case Normalization and Parsing
SHOW CREATE DATABASE
andRECOVER DATABASE
statements. (AstBuilder.java
) [1] [2]TableObjectCaseInsensitiveTest.java
)3. Authorization and Privilege Checks
SHOW CREATE DATABASE
andRECOVER DATABASE
to use the catalog from the context and provide accurate error reporting. (AuthorizerStmtVisitor.java
) [1] [2]4. Code Cleanup and Consistency
ShowStmtAnalyzer.java
,AstVisitorExtendInterface.java
) [1] [2]AuthorizerStmtVisitor.java
,BasicDbStmtAnalyzer.java
) [1] [2]5. Test Coverage Enhancements
USE
statement behavior, including catalog selection, error handling for non-existent catalogs, and execution state validation. (UseDbTest.java
)These changes collectively make catalog/database operations more robust, predictable, and easier to maintain, while improving user feedback and test reliability.
What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist:
Bugfix cherry-pick branch check: