This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.0 by this push:
new cf70f91d2e8 branch-4.0: [fix](fe) Detect Doris-compatible MySQL JDBC
targets #64389 (#64472)
cf70f91d2e8 is described below
commit cf70f91d2e8413df37fc4591a7cb317ab1febd8d
Author: Socrates <[email protected]>
AuthorDate: Fri Jun 26 10:04:06 2026 +0800
branch-4.0: [fix](fe) Detect Doris-compatible MySQL JDBC targets #64389
(#64472)
### What problem does this PR solve?
Issue Number: None
Related PR: #64389
---
.../datasource/jdbc/client/JdbcMySQLClient.java | 15 ++++++++-
.../jdbc/client/JdbcMySQLClientTest.java | 37 ++++++++++++++++++++++
2 files changed, 51 insertions(+), 1 deletion(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java
index 79e7fb65a0e..95304f10bdc 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java
@@ -36,6 +36,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
@@ -58,7 +59,7 @@ public class JdbcMySQLClient extends JdbcClient {
rs = stmt.executeQuery("SHOW VARIABLES LIKE 'version_comment'");
if (rs.next()) {
String versionComment = rs.getString("Value");
- isDoris = versionComment.toLowerCase().contains("doris");
+ isDoris = isDorisCompatibleVersionComment(versionComment);
}
} catch (SQLException | JdbcClientException e) {
closeClient();
@@ -74,6 +75,18 @@ public class JdbcMySQLClient extends JdbcClient {
this.dbType = dbType;
}
+ static boolean isDorisCompatibleVersionComment(String versionComment) {
+ if (Strings.isNullOrEmpty(versionComment)) {
+ return false;
+ }
+ String lowerVersionComment = versionComment.toLowerCase(Locale.ROOT);
+ return lowerVersionComment.contains("doris")
+ || lowerVersionComment.contains("selectdb")
+ || lowerVersionComment.contains("velodb")
+ || (lowerVersionComment.contains("enterprise version")
+ && lowerVersionComment.contains("cloud mode"));
+ }
+
@Override
public String getTableComment(String remoteDbName, String remoteTableName)
{
ImmutableList.Builder<String> tableCommentBuilder =
ImmutableList.builder();
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClientTest.java
b/fe/fe-core/src/test/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClientTest.java
new file mode 100644
index 00000000000..010181b52e6
--- /dev/null
+++
b/fe/fe-core/src/test/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClientTest.java
@@ -0,0 +1,37 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.datasource.jdbc.client;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class JdbcMySQLClientTest {
+
+ @Test
+ public void testIsDorisCompatibleVersionComment() {
+
Assert.assertTrue(JdbcMySQLClient.isDorisCompatibleVersionComment("Apache Doris
version 3.1.0"));
+
Assert.assertTrue(JdbcMySQLClient.isDorisCompatibleVersionComment("SelectDB
Cloud version 4.0.5"));
+
Assert.assertTrue(JdbcMySQLClient.isDorisCompatibleVersionComment("VeloDB
version 2.1.0"));
+ Assert.assertTrue(JdbcMySQLClient.isDorisCompatibleVersionComment(
+ "enterprise version enterprise-4.0.5-rc01-0724569463d (Cloud
Mode)"));
+
+
Assert.assertFalse(JdbcMySQLClient.isDorisCompatibleVersionComment("MySQL
Community Server - GPL"));
+
Assert.assertFalse(JdbcMySQLClient.isDorisCompatibleVersionComment(""));
+
Assert.assertFalse(JdbcMySQLClient.isDorisCompatibleVersionComment(null));
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]