This is an automated email from the ASF dual-hosted git repository.
terrymanu 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 0eab7a2f1f8 Resolve quoted schema name in SupportedSQLCheckEngine
(#40069)
0eab7a2f1f8 is described below
commit 0eab7a2f1f8e5a12f9f6460fd0f63fedb4af3d16
Author: Eunbin Son <[email protected]>
AuthorDate: Sun Oct 11 00:29:05 2026 +0900
Resolve quoted schema name in SupportedSQLCheckEngine (#40069)
---
RELEASE-NOTES.md | 1 +
.../infra/checker/SupportedSQLCheckEngine.java | 2 +-
.../infra/checker/SupportedSQLCheckEngineTest.java | 26 +++++++++++++++++++++-
3 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index f04be11d6ba..7c78a023cae 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -23,6 +23,7 @@
1. Infra: Fix invalid target selection after counter overflow in
`RoundRobinLoadBalanceAlgorithm` -
[#39340](https://github.com/apache/shardingsphere/pull/39340)
1. Infra: Reject incomplete WEIGHT load balancer properties during rule
configuration validation -
[#39378](https://github.com/apache/shardingsphere/pull/39378)
1. Infra: Fix stale weights in WEIGHT load balancer after same-size read data
source changes - [#39995](https://github.com/apache/shardingsphere/pull/39995)
+1. Infra: Fix false table existence check failures for quoted schema names in
`SupportedSQLCheckEngine` -
[#40069](https://github.com/apache/shardingsphere/pull/40069)
1. SQL Parser: Preserve unary NOT as NotExpression for scalar-subquery table
extraction in PostgreSQL -
[#38187](https://github.com/apache/shardingsphere/pull/38187)
1. SQL Parser: Fix wrong parameter index parse in MySQL, Doris -
[#38624](https://github.com/apache/shardingsphere/pull/38624)
1. SQL Parser: Fix reversed parameter marker order for openGauss `LIMIT
offset, row-count` -
[#39242](https://github.com/apache/shardingsphere/pull/39242)
diff --git
a/infra/checker/src/main/java/org/apache/shardingsphere/infra/checker/SupportedSQLCheckEngine.java
b/infra/checker/src/main/java/org/apache/shardingsphere/infra/checker/SupportedSQLCheckEngine.java
index e3e3c4f7016..e806d752323 100644
---
a/infra/checker/src/main/java/org/apache/shardingsphere/infra/checker/SupportedSQLCheckEngine.java
+++
b/infra/checker/src/main/java/org/apache/shardingsphere/infra/checker/SupportedSQLCheckEngine.java
@@ -55,6 +55,6 @@ public final class SupportedSQLCheckEngine {
private ShardingSphereSchema getCurrentSchema(final SQLStatementContext
sqlStatementContext, final ShardingSphereDatabase database) {
ShardingSphereSchema defaultSchema =
database.findDefaultSchema().orElse(null);
- return
sqlStatementContext.getTablesContext().getSchemaName().map(database::getSchema).orElse(defaultSchema);
+ return
sqlStatementContext.getTablesContext().getIdentifierSchemaName().map(database::getSchema).orElse(defaultSchema);
}
}
diff --git
a/infra/checker/src/test/java/org/apache/shardingsphere/infra/checker/SupportedSQLCheckEngineTest.java
b/infra/checker/src/test/java/org/apache/shardingsphere/infra/checker/SupportedSQLCheckEngineTest.java
index 00c9b7ee8eb..9fbce9891f2 100644
---
a/infra/checker/src/test/java/org/apache/shardingsphere/infra/checker/SupportedSQLCheckEngineTest.java
+++
b/infra/checker/src/test/java/org/apache/shardingsphere/infra/checker/SupportedSQLCheckEngineTest.java
@@ -17,11 +17,13 @@
package org.apache.shardingsphere.infra.checker;
+import
org.apache.shardingsphere.database.connector.core.metadata.database.enums.QuoteCharacter;
import
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader;
+import
org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue;
import
org.apache.shardingsphere.test.infra.framework.extension.mock.AutoMockExtension;
import
org.apache.shardingsphere.test.infra.framework.extension.mock.StaticMockSettings;
import org.junit.jupiter.api.Test;
@@ -48,7 +50,7 @@ class SupportedSQLCheckEngineTest {
void assertCheckSQL() {
ShardingSphereRule rule = mock(ShardingSphereRule.class);
SQLStatementContext sqlStatementContext =
mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
-
when(sqlStatementContext.getTablesContext().getSchemaName()).thenReturn(Optional.empty());
+
when(sqlStatementContext.getTablesContext().getIdentifierSchemaName()).thenReturn(Optional.empty());
SupportedSQLChecker supportedSQLChecker =
mock(SupportedSQLChecker.class);
when(supportedSQLChecker.isCheck(sqlStatementContext)).thenReturn(true);
SupportedSQLChecker unsupportedSQLChecker =
mock(SupportedSQLChecker.class);
@@ -63,4 +65,26 @@ class SupportedSQLCheckEngineTest {
verify(supportedSQLChecker).check(rule, database, defaultSchema,
sqlStatementContext);
verify(unsupportedSQLChecker, never()).check(eq(rule), eq(database),
eq(defaultSchema), eq(sqlStatementContext));
}
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ @Test
+ void assertCheckSQLWithQuotedSchemaName() {
+ ShardingSphereRule rule = mock(ShardingSphereRule.class);
+ SQLStatementContext sqlStatementContext =
mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
+ IdentifierValue schemaName = new IdentifierValue("MySchema",
QuoteCharacter.QUOTE);
+
when(sqlStatementContext.getTablesContext().getIdentifierSchemaName()).thenReturn(Optional.of(schemaName));
+ SupportedSQLChecker supportedSQLChecker =
mock(SupportedSQLChecker.class);
+
when(supportedSQLChecker.isCheck(sqlStatementContext)).thenReturn(true);
+ SupportedSQLCheckersBuilder supportedSQLCheckersBuilder =
mock(SupportedSQLCheckersBuilder.class);
+
when(supportedSQLCheckersBuilder.getSupportedSQLCheckers()).thenReturn(Collections.singleton(supportedSQLChecker));
+ Map<ShardingSphereRule, SupportedSQLCheckersBuilder> services =
Collections.singletonMap(rule, supportedSQLCheckersBuilder);
+ when(OrderedSPILoader.getServices(SupportedSQLCheckersBuilder.class,
Collections.singleton(rule))).thenReturn(services);
+ ShardingSphereDatabase database = mock(ShardingSphereDatabase.class);
+ ShardingSphereSchema defaultSchema = mock(ShardingSphereSchema.class);
+
when(database.findDefaultSchema()).thenReturn(Optional.of(defaultSchema));
+ ShardingSphereSchema quotedSchema = mock(ShardingSphereSchema.class);
+ when(database.getSchema(schemaName)).thenReturn(quotedSchema);
+ new SupportedSQLCheckEngine().checkSQL(Collections.singleton(rule),
sqlStatementContext, database);
+ verify(supportedSQLChecker).check(rule, database, quotedSchema,
sqlStatementContext);
+ }
}