lvyanquan commented on code in PR #4032:
URL: https://github.com/apache/flink-cdc/pull/4032#discussion_r2131636344
##########
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/source/utils/TableDiscoveryUtils.java:
##########
@@ -50,54 +54,26 @@ public static List<TableId> listTables(
// READ DATABASE NAMES
// -------------------
// Get the list of databases ...
- LOG.info("Read list of available databases");
- final List<String> databaseNames = new ArrayList<>();
-
- jdbc.query(
- "SHOW DATABASES",
- rs -> {
- while (rs.next()) {
- String databaseName = rs.getString(1);
- if (databaseFilter.test(databaseName)) {
- databaseNames.add(databaseName);
- }
+ try (Connection connection = jdbc.connection()) {
+ DatabaseMetaData databaseMetaData = connection.getMetaData();
+ try (ResultSet tableResult = databaseMetaData.getTables(null,
null, "%", TABLE_QUERY)) {
+ while (tableResult.next()) {
+ String dbName = tableResult.getString("TABLE_CAT");
+ if (!databaseFilter.test(dbName)) {
Review Comment:
You can ignore this comment, reducing the number of interactions with the
database is more appropriate than reducing calculations.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]