This is an automated email from the ASF dual-hosted git repository.

menghaoranss pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new d8df72805f6 Use protocol schema resolver in DataNode compatibility 
constructor (#39701)
d8df72805f6 is described below

commit d8df72805f61bfa266297c3b10f92c420fd1d7f2
Author: Haoran Meng <[email protected]>
AuthorDate: Thu Sep 3 13:45:01 2026 +0800

    Use protocol schema resolver in DataNode compatibility constructor (#39701)
    
    * Use protocol schema resolver in DataNode compatibility constructor
    
    * Add regression test for DataNode protocol schema resolution
---
 .../java/org/apache/shardingsphere/infra/datanode/DataNode.java   | 8 +++-----
 .../org/apache/shardingsphere/infra/datanode/DataNodeTest.java    | 1 +
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/datanode/DataNode.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/datanode/DataNode.java
index e27d4d222ed..c8d71c618c5 100644
--- 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/datanode/DataNode.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/datanode/DataNode.java
@@ -23,6 +23,7 @@ import lombok.Getter;
 import lombok.RequiredArgsConstructor;
 import lombok.ToString;
 import 
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.schema.DialectSchemaOption;
+import 
org.apache.shardingsphere.database.connector.core.metadata.identifier.DefaultSchemaNameResolver;
 import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
 import 
org.apache.shardingsphere.database.connector.core.type.DatabaseTypeRegistry;
 import org.apache.shardingsphere.infra.exception.ShardingSpherePreconditions;
@@ -69,11 +70,8 @@ public final class DataNode {
      * @param dataNode data node use {@code .} to split schema name and table 
name
      */
     public DataNode(final String databaseName, final DatabaseType 
databaseType, final String dataNode) {
-        this(databaseName, new DatabaseTypeRegistry(databaseType), dataNode);
-    }
-    
-    private DataNode(final String databaseName, final DatabaseTypeRegistry 
registry, final String dataNode) {
-        this(registry.getDefaultSchemaName(databaseName), 
registry.getDialectDatabaseMetaData().getSchemaOption(), dataNode);
+        this(DefaultSchemaNameResolver.resolveProtocol(databaseType, 
databaseName),
+                new 
DatabaseTypeRegistry(databaseType).getDialectDatabaseMetaData().getSchemaOption(),
 dataNode);
     }
     
     private DataNode(final String defaultSchemaName, final DialectSchemaOption 
schemaOption, final String dataNode) {
diff --git 
a/infra/common/src/test/java/org/apache/shardingsphere/infra/datanode/DataNodeTest.java
 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/datanode/DataNodeTest.java
index 654bbd2c141..67fd5294393 100644
--- 
a/infra/common/src/test/java/org/apache/shardingsphere/infra/datanode/DataNodeTest.java
+++ 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/datanode/DataNodeTest.java
@@ -166,6 +166,7 @@ class DataNodeTest {
                 Arguments.of("postgresql_without_schema_segment", "test_db", 
POSTGRESQL_DATABASE_TYPE, "ds.tbl", "ds", "*", "tbl"),
                 Arguments.of("postgresql_dotted_table_suffix", "test_db", 
POSTGRESQL_DATABASE_TYPE, "ds.schema.tbl.part", "ds", "*", "schema.tbl.part"),
                 Arguments.of("mysql_without_schema_support", "test_db", 
MYSQL_DATABASE_TYPE, "ds.tbl", "ds", "test_db", "tbl"),
+                Arguments.of("mysql_normalizes_mixed_case_database_schema", 
"Foo_DB", MYSQL_DATABASE_TYPE, "ds.tbl", "ds", "foo_db", "tbl"),
                 Arguments.of("mysql_three_segments_kept_as_table_suffix", 
"test_db", MYSQL_DATABASE_TYPE, "ds.schema.tbl", "ds", "test_db", "schema.tbl"),
                 Arguments.of("postgresql_preserves_table_case", "test_db", 
POSTGRESQL_DATABASE_TYPE, "ds.schema.TABLE", "ds", "schema", "TABLE"),
                 Arguments.of("oracle_normalizes_database_schema", "logic_db", 
ORACLE_DATABASE_TYPE, "ds.tbl", "ds", "LOGIC_DB", "tbl"));

Reply via email to