-
Notifications
You must be signed in to change notification settings - Fork 575
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
feat(mysql-cdc): support mysql source capture multiple databases #19038
Merged
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5f73b3e
mysql source multi database
StrikeW c03f267
add e2e tests
StrikeW 5cfe391
minor
StrikeW 388a4a1
fix
StrikeW 20ee997
minor
StrikeW 3116385
minor
StrikeW 0aa5af1
Merge remote-tracking branch 'origin/main' into siyuan/mysql-multi-db
StrikeW c40ddbe
refine
StrikeW 9289263
fix
StrikeW cd9e21d
minor
StrikeW 30d9e77
minor
StrikeW File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,6 @@ | |
package com.risingwave.connector.source.common; | ||
|
||
import com.risingwave.connector.api.TableSchema; | ||
import com.risingwave.connector.api.source.SourceTypeE; | ||
import com.risingwave.proto.Data; | ||
import java.sql.Connection; | ||
import java.sql.DriverManager; | ||
|
@@ -45,9 +44,7 @@ public MySqlValidator( | |
|
||
var dbHost = userProps.get(DbzConnectorConfig.HOST); | ||
var dbPort = userProps.get(DbzConnectorConfig.PORT); | ||
var dbName = userProps.get(DbzConnectorConfig.DB_NAME); | ||
var jdbcUrl = ValidatorUtils.getJdbcUrl(SourceTypeE.MYSQL, dbHost, dbPort, dbName); | ||
|
||
var jdbcUrl = String.format("jdbc:mysql://%s:%s", dbHost, dbPort); | ||
var properties = new Properties(); | ||
properties.setProperty("user", userProps.get(DbzConnectorConfig.USER)); | ||
properties.setProperty("password", userProps.get(DbzConnectorConfig.PASSWORD)); | ||
|
@@ -72,6 +69,26 @@ public void validateDbConfig() { | |
if ((major > 8) || (major == 8 && minor >= 4)) { | ||
throw ValidatorUtils.failedPrecondition("MySQL version should be less than 8.4"); | ||
} | ||
|
||
// "database.name" is a comma-separated list of database names | ||
var dbNames = userProps.get(DbzConnectorConfig.DB_NAME); | ||
for (var dbName : dbNames.split(",")) { | ||
// check the existence of the database | ||
try (var stmt = | ||
jdbcConnection.prepareStatement( | ||
ValidatorUtils.getSql("mysql.check_db_exist"))) { | ||
stmt.setString(1, dbName.trim()); | ||
var res = stmt.executeQuery(); | ||
while (res.next()) { | ||
var ret = res.getInt(1); | ||
if (ret == 0) { | ||
throw ValidatorUtils.invalidArgument( | ||
String.format("MySQL database '%s' doesn't exist", dbName)); | ||
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.
|
||
} | ||
} | ||
} | ||
} | ||
|
||
validateBinlogConfig(); | ||
} catch (SQLException e) { | ||
throw ValidatorUtils.internalError(e.getMessage()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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.
Should we then delete the
MYSQL
branch inValidatorUtils.getJdbcUrl
?