Skip to content
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

Revise MissingRequiredTargetDatabaseException and check target database is exists #30395

Merged
merged 2 commits into from
Mar 6, 2024

Conversation

azexcy
Copy link
Contributor

@azexcy azexcy commented Mar 5, 2024

Changes proposed in this pull request:

  • Check targetDatabaseName is valid at MigrateTableExecutor

Before committing this PR, I'm sure that I have checked the following options:

  • My code follows the code of conduct of this project.
  • I have self-reviewed the commit code.
  • I have (or in comment I request) added corresponding labels for the pull request.
  • I have passed maven check locally : ./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e.
  • I have made corresponding changes to the documentation.
  • I have added corresponding unit tests for my changes.

ShardingSphereDatabase targetDatabase = PipelineContextManager.getProxyContext().getContextManager().getDatabase(sqlStatement.getTargetDatabaseName());
ShardingSpherePreconditions.checkNotNull(targetDatabase, () -> new PipelineInvalidParameterException(String.format("Target database `%s` is not exists",
sqlStatement.getTargetDatabaseName())));
targetDatabaseName = targetDatabase.getName();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is targetDatabaseName = targetDatabase.getName(); necessary? Migration is compatible with upper and lower database name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improved, I find MIGRATE TABLE DistSQL now must select database, just like

mysql> MIGRATE TABLE ds_0.t_order_copy INTO sharding_DB2.t_order;
ERROR 1046 (3D000): No database selected
mysql> use sharding_db
Database changed

So I improve the exception message and check the target database is really exists

@azexcy azexcy changed the title Check targetDatabaseName is valid at MigrateTableExecutor Revise MissingRequiredTargetDatabaseException and check target database is exists Mar 5, 2024
@sandynz sandynz merged commit 616f7c5 into apache:master Mar 6, 2024
24 checks passed
@azexcy azexcy deleted the migration branch March 8, 2024 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants