You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2023/06/07 10:41:50 UTC
[shardingsphere] branch master updated: Exclude dual when validate if a table exist. (#26091) (#26092)
This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 7f9e61c379a Exclude dual when validate if a table exist. (#26091) (#26092)
7f9e61c379a is described below
commit 7f9e61c379abc2e3201fa06351389e5f70088012
Author: Cong Hu <ia...@qq.com>
AuthorDate: Wed Jun 7 18:41:42 2023 +0800
Exclude dual when validate if a table exist. (#26091) (#26092)
* Exclude dual when validate if a table exist. (#26091)
* Exclude dual when validate if a table exist. (#26091)
* Exclude dual when validate if a table exist. (#26091)
* Exclude dual when validate if a table exist. (#26091)
* Exclude dual when validate if a table exist. (#26091)
---
.../validator/ShardingSphereMetaDataValidateUtils.java | 11 ++++++++++-
.../src/test/resources/cases/dql/dql-integration-select.xml | 2 ++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/infra/context/src/main/java/org/apache/shardingsphere/infra/connection/validator/ShardingSphereMetaDataValidateUtils.java b/infra/context/src/main/java/org/apache/shardingsphere/infra/connection/validator/ShardingSphereMetaDataValidateUtils.java
index f47d6b3f4a6..a176c13a824 100644
--- a/infra/context/src/main/java/org/apache/shardingsphere/infra/connection/validator/ShardingSphereMetaDataValidateUtils.java
+++ b/infra/context/src/main/java/org/apache/shardingsphere/infra/connection/validator/ShardingSphereMetaDataValidateUtils.java
@@ -25,6 +25,9 @@ import org.apache.shardingsphere.infra.database.type.DatabaseTypeEngine;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
+import java.util.Collection;
+import java.util.HashSet;
+
/**
* ShardingSphere meta data validate utility class.
*/
@@ -32,6 +35,12 @@ import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSp
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class ShardingSphereMetaDataValidateUtils {
+ public static final Collection<String> EXCLUDE_VALIDATE_TABLES = new HashSet<>(1, 1F);
+
+ static {
+ EXCLUDE_VALIDATE_TABLES.add("DUAL");
+ }
+
/**
* Validate table exist.
*
@@ -43,7 +52,7 @@ public final class ShardingSphereMetaDataValidateUtils {
String defaultSchemaName = DatabaseTypeEngine.getDefaultSchemaName(sqlStatementContext.getDatabaseType(), database.getName());
ShardingSphereSchema schema = sqlStatementContext.getTablesContext().getSchemaName().map(database::getSchema).orElseGet(() -> database.getSchema(defaultSchemaName));
for (String each : sqlStatementContext.getTablesContext().getTableNames()) {
- if (!schema.containsTable(each)) {
+ if (!EXCLUDE_VALIDATE_TABLES.contains(each.toUpperCase()) && !schema.containsTable(each)) {
throw new NoSuchTableException(each);
}
}
diff --git a/test/e2e/sql/src/test/resources/cases/dql/dql-integration-select.xml b/test/e2e/sql/src/test/resources/cases/dql/dql-integration-select.xml
index 610ed5cb0ac..88807b090fb 100644
--- a/test/e2e/sql/src/test/resources/cases/dql/dql-integration-select.xml
+++ b/test/e2e/sql/src/test/resources/cases/dql/dql-integration-select.xml
@@ -17,6 +17,8 @@
-->
<integration-test-cases>
+ <test-case sql="SELECT 1 FROM dual" />
+
<test-case sql="SELECT 1 as a" />
<test-case sql="SELECT t_order.* FROM t_order t_order WHERE user_id = ? AND order_id = ?" scenario-types="db,tbl,dbtbl_with_readwrite_splitting,readwrite_splitting">