This is an automated email from the ASF dual-hosted git repository.
tuichenchuxin 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 7f8c7624979 Add props for ShardingStatementValidator#preValidate and
remove useless ShardingSelectStatementValidator (#21151)
7f8c7624979 is described below
commit 7f8c7624979d26dac0cb989f41a55402fb33d046
Author: Zhengqiang Duan <[email protected]>
AuthorDate: Fri Sep 23 15:45:11 2022 +0800
Add props for ShardingStatementValidator#preValidate and remove useless
ShardingSelectStatementValidator (#21151)
* Add props for ShardingStatementValidator#preValidate and remove useless
ShardingSelectStatementValidator
* Add props for ShardingStatementValidator#preValidate and remove useless
ShardingSelectStatementValidator
* fix unit test
---
.../sharding/route/engine/ShardingSQLRouter.java | 2 +-
.../validator/ShardingStatementValidator.java | 3 +-
.../ShardingStatementValidatorFactory.java | 5 ---
.../impl/ShardingAlterIndexStatementValidator.java | 4 +-
.../impl/ShardingAlterTableStatementValidator.java | 2 +-
.../impl/ShardingAlterViewStatementValidator.java | 2 +-
.../ShardingCreateFunctionStatementValidator.java | 2 +-
.../ShardingCreateIndexStatementValidator.java | 2 +-
.../ShardingCreateProcedureStatementValidator.java | 2 +-
.../ShardingCreateTableStatementValidator.java | 4 +-
.../impl/ShardingCreateViewStatementValidator.java | 8 ++--
.../impl/ShardingDropIndexStatementValidator.java | 3 +-
.../impl/ShardingDropTableStatementValidator.java | 4 +-
.../impl/ShardingPrepareStatementValidator.java | 4 +-
.../ShardingRenameTableStatementValidator.java | 4 +-
.../dml/impl/ShardingCopyStatementValidator.java | 4 +-
.../dml/impl/ShardingDeleteStatementValidator.java | 2 +-
.../dml/impl/ShardingInsertStatementValidator.java | 2 +-
.../dml/impl/ShardingSelectStatementValidator.java | 46 ----------------------
.../dml/impl/ShardingUpdateStatementValidator.java | 4 +-
.../ShardingAlterIndexStatementValidatorTest.java | 7 ++--
.../ShardingAlterTableStatementValidatorTest.java | 4 +-
.../ShardingAlterViewStatementValidatorTest.java | 9 +++--
...ardingCreateFunctionStatementValidatorTest.java | 9 +++--
.../ShardingCreateIndexStatementValidatorTest.java | 13 +++---
...rdingCreateProcedureStatementValidatorTest.java | 9 +++--
.../ShardingCreateTableStatementValidatorTest.java | 4 +-
.../ShardingCreateViewStatementValidatorTest.java | 14 ++++---
.../ShardingDropIndexStatementValidatorTest.java | 4 +-
.../ShardingDropTableStatementValidatorTest.java | 2 +-
.../ShardingRenameTableStatementValidatorTest.java | 6 +--
.../dml/ShardingCopyStatementValidatorTest.java | 7 ++--
.../dml/ShardingDeleteStatementValidatorTest.java | 3 +-
.../dml/ShardingInsertStatementValidatorTest.java | 12 +++---
.../dml/ShardingUpdateStatementValidatorTest.java | 4 +-
.../showprocesslist/engine/ShowProcessListIT.java | 10 ++---
36 files changed, 95 insertions(+), 131 deletions(-)
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/ShardingSQLRouter.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/ShardingSQLRouter.java
index 17c1729eed4..bc551249c40 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/ShardingSQLRouter.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/ShardingSQLRouter.java
@@ -52,7 +52,7 @@ public final class ShardingSQLRouter implements
SQLRouter<ShardingRule> {
SQLStatement sqlStatement =
queryContext.getSqlStatementContext().getSqlStatement();
ShardingConditions shardingConditions =
createShardingConditions(queryContext, database, rule);
Optional<ShardingStatementValidator> validator =
ShardingStatementValidatorFactory.newInstance(sqlStatement, shardingConditions);
- validator.ifPresent(optional -> optional.preValidate(rule,
queryContext.getSqlStatementContext(), queryContext.getParameters(), database));
+ validator.ifPresent(optional -> optional.preValidate(rule,
queryContext.getSqlStatementContext(), queryContext.getParameters(), database,
props));
if (sqlStatement instanceof DMLStatement &&
shardingConditions.isNeedMerge()) {
shardingConditions.merge();
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ShardingStatementValidator.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ShardingStatementValidator.java
index 9728ca92929..29ccab5ea1c 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ShardingStatementValidator.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ShardingStatementValidator.java
@@ -40,8 +40,9 @@ public interface ShardingStatementValidator<T extends
SQLStatement> {
* @param sqlStatementContext SQL statement context
* @param parameters SQL parameters
* @param database database
+ * @param props props
*/
- void preValidate(ShardingRule shardingRule, SQLStatementContext<T>
sqlStatementContext, List<Object> parameters, ShardingSphereDatabase database);
+ void preValidate(ShardingRule shardingRule, SQLStatementContext<T>
sqlStatementContext, List<Object> parameters, ShardingSphereDatabase database,
ConfigurationProperties props);
/**
* Validate whether sharding operation is supported after route.
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ShardingStatementValidatorFactory.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ShardingStatementValidatorFactory.java
index cdeb43856c6..2007677a9b2 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ShardingStatementValidatorFactory.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ShardingStatementValidatorFactory.java
@@ -35,7 +35,6 @@ import
org.apache.shardingsphere.sharding.route.engine.validator.ddl.impl.Shardi
import
org.apache.shardingsphere.sharding.route.engine.validator.dml.impl.ShardingCopyStatementValidator;
import
org.apache.shardingsphere.sharding.route.engine.validator.dml.impl.ShardingDeleteStatementValidator;
import
org.apache.shardingsphere.sharding.route.engine.validator.dml.impl.ShardingInsertStatementValidator;
-import
org.apache.shardingsphere.sharding.route.engine.validator.dml.impl.ShardingSelectStatementValidator;
import
org.apache.shardingsphere.sharding.route.engine.validator.dml.impl.ShardingUpdateStatementValidator;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.AlterIndexStatement;
@@ -55,7 +54,6 @@ import
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.CopyStateme
import
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.DMLStatement;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.DeleteStatement;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.InsertStatement;
-import
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.SelectStatement;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.UpdateStatement;
import java.util.Optional;
@@ -133,9 +131,6 @@ public final class ShardingStatementValidatorFactory {
if (sqlStatement instanceof DeleteStatement) {
return Optional.of(new ShardingDeleteStatementValidator());
}
- if (sqlStatement instanceof SelectStatement) {
- return Optional.of(new ShardingSelectStatementValidator());
- }
if (sqlStatement instanceof CopyStatement) {
return Optional.of(new ShardingCopyStatementValidator());
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingAlterIndexStatementValidator.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingAlterIndexStatementValidator.java
index 407831d9d84..c701e35793f 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingAlterIndexStatementValidator.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingAlterIndexStatementValidator.java
@@ -40,8 +40,8 @@ import java.util.Optional;
public final class ShardingAlterIndexStatementValidator extends
ShardingDDLStatementValidator<AlterIndexStatement> {
@Override
- public void preValidate(final ShardingRule shardingRule,
- final SQLStatementContext<AlterIndexStatement>
sqlStatementContext, final List<Object> parameters, final
ShardingSphereDatabase database) {
+ public void preValidate(final ShardingRule shardingRule, final
SQLStatementContext<AlterIndexStatement> sqlStatementContext,
+ final List<Object> parameters, final
ShardingSphereDatabase database, final ConfigurationProperties props) {
Optional<IndexSegment> index =
sqlStatementContext.getSqlStatement().getIndex();
String defaultSchemaName =
DatabaseTypeEngine.getDefaultSchemaName(sqlStatementContext.getDatabaseType(),
database.getName());
ShardingSphereSchema schema = index.flatMap(optional ->
optional.getOwner()
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingAlterTableStatementValidator.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingAlterTableStatementValidator.java
index 8fb542ed5a0..1da1778b88b 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingAlterTableStatementValidator.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingAlterTableStatementValidator.java
@@ -41,7 +41,7 @@ public final class ShardingAlterTableStatementValidator
extends ShardingDDLState
@Override
public void preValidate(final ShardingRule shardingRule, final
SQLStatementContext<AlterTableStatement> sqlStatementContext,
- final List<Object> parameters, final
ShardingSphereDatabase database) {
+ final List<Object> parameters, final
ShardingSphereDatabase database, final ConfigurationProperties props) {
Collection<String> tableNames = sqlStatementContext instanceof
TableAvailable
? ((TableAvailable)
sqlStatementContext).getAllTables().stream().map(each ->
each.getTableName().getIdentifier().getValue()).collect(Collectors.toList())
: sqlStatementContext.getTablesContext().getTableNames();
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingAlterViewStatementValidator.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingAlterViewStatementValidator.java
index 7c35e4e9f95..6047cfa87d3 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingAlterViewStatementValidator.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingAlterViewStatementValidator.java
@@ -41,7 +41,7 @@ public final class ShardingAlterViewStatementValidator
extends ShardingDDLStatem
@Override
public void preValidate(final ShardingRule shardingRule, final
SQLStatementContext<AlterViewStatement> sqlStatementContext,
- final List<Object> parameters, final
ShardingSphereDatabase database) {
+ final List<Object> parameters, final
ShardingSphereDatabase database, final ConfigurationProperties props) {
Optional<SelectStatement> selectStatement =
AlterViewStatementHandler.getSelectStatement(sqlStatementContext.getSqlStatement());
if (selectStatement.isPresent()) {
TableExtractor extractor = new TableExtractor();
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateFunctionStatementValidator.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateFunctionStatementValidator.java
index 3ab7ee8b8e2..1b6ddf5a7a8 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateFunctionStatementValidator.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateFunctionStatementValidator.java
@@ -42,7 +42,7 @@ public final class ShardingCreateFunctionStatementValidator
extends ShardingDDLS
@Override
public void preValidate(final ShardingRule shardingRule, final
SQLStatementContext<CreateFunctionStatement> sqlStatementContext,
- final List<Object> parameters, final
ShardingSphereDatabase database) {
+ final List<Object> parameters, final
ShardingSphereDatabase database, final ConfigurationProperties props) {
Optional<RoutineBodySegment> routineBodySegment =
CreateFunctionStatementHandler.getRoutineBodySegment(sqlStatementContext.getSqlStatement());
if (!routineBodySegment.isPresent()) {
return;
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateIndexStatementValidator.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateIndexStatementValidator.java
index f287e1118f4..8941a277e98 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateIndexStatementValidator.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateIndexStatementValidator.java
@@ -40,7 +40,7 @@ public final class ShardingCreateIndexStatementValidator
extends ShardingDDLStat
@Override
public void preValidate(final ShardingRule shardingRule, final
SQLStatementContext<CreateIndexStatement> sqlStatementContext,
- final List<Object> parameters, final
ShardingSphereDatabase database) {
+ final List<Object> parameters, final
ShardingSphereDatabase database, final ConfigurationProperties props) {
if
(CreateIndexStatementHandler.ifNotExists(sqlStatementContext.getSqlStatement()))
{
return;
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateProcedureStatementValidator.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateProcedureStatementValidator.java
index 6e535955fbd..f361a72a420 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateProcedureStatementValidator.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateProcedureStatementValidator.java
@@ -42,7 +42,7 @@ public final class ShardingCreateProcedureStatementValidator
extends ShardingDDL
@Override
public void preValidate(final ShardingRule shardingRule, final
SQLStatementContext<CreateProcedureStatement> sqlStatementContext,
- final List<Object> parameters, final
ShardingSphereDatabase database) {
+ final List<Object> parameters, final
ShardingSphereDatabase database, final ConfigurationProperties props) {
Optional<RoutineBodySegment> routineBodySegment =
CreateProcedureStatementHandler.getRoutineBodySegment(sqlStatementContext.getSqlStatement());
if (!routineBodySegment.isPresent()) {
return;
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateTableStatementValidator.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateTableStatementValidator.java
index eb025aeb8af..ec34ab5279b 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateTableStatementValidator.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateTableStatementValidator.java
@@ -38,8 +38,8 @@ import java.util.List;
public final class ShardingCreateTableStatementValidator extends
ShardingDDLStatementValidator<CreateTableStatement> {
@Override
- public void preValidate(final ShardingRule shardingRule,
- final SQLStatementContext<CreateTableStatement>
sqlStatementContext, final List<Object> parameters, final
ShardingSphereDatabase database) {
+ public void preValidate(final ShardingRule shardingRule, final
SQLStatementContext<CreateTableStatement> sqlStatementContext,
+ final List<Object> parameters, final
ShardingSphereDatabase database, final ConfigurationProperties props) {
if
(!CreateTableStatementHandler.ifNotExists(sqlStatementContext.getSqlStatement()))
{
String defaultSchemaName =
DatabaseTypeEngine.getDefaultSchemaName(sqlStatementContext.getDatabaseType(),
database.getName());
ShardingSphereSchema schema =
sqlStatementContext.getTablesContext().getSchemaName()
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateViewStatementValidator.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateViewStatementValidator.java
index 3078506f10e..344a172dee0 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateViewStatementValidator.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateViewStatementValidator.java
@@ -19,6 +19,7 @@ package
org.apache.shardingsphere.sharding.route.engine.validator.ddl.impl;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.route.context.RouteContext;
import
org.apache.shardingsphere.sharding.exception.metadata.EngagedViewException;
@@ -46,7 +47,7 @@ public final class ShardingCreateViewStatementValidator
extends ShardingDDLState
@Override
public void preValidate(final ShardingRule shardingRule, final
SQLStatementContext<CreateViewStatement> sqlStatementContext,
- final List<Object> parameters, final
ShardingSphereDatabase database) {
+ final List<Object> parameters, final
ShardingSphereDatabase database, final ConfigurationProperties props) {
Optional<SelectStatement> selectStatement =
sqlStatementContext.getSqlStatement().getSelect();
if (!selectStatement.isPresent()) {
return;
@@ -54,10 +55,11 @@ public final class ShardingCreateViewStatementValidator
extends ShardingDDLState
TableExtractor extractor = new TableExtractor();
extractor.extractTablesFromSelect(selectStatement.get());
Collection<SimpleTableSegment> tableSegments =
extractor.getRewriteTables();
- if (isShardingTablesWithoutBinding(shardingRule, sqlStatementContext,
tableSegments)) {
+ String sqlFederationType =
props.getValue(ConfigurationPropertyKey.SQL_FEDERATION_TYPE);
+ if ("NONE".equals(sqlFederationType) &&
isShardingTablesWithoutBinding(shardingRule, sqlStatementContext,
tableSegments)) {
throw new EngagedViewException("sharding");
}
- if (isAllBroadcastTablesWithoutConfigView(shardingRule,
sqlStatementContext, tableSegments)) {
+ if ("NONE".equals(sqlFederationType) &&
isAllBroadcastTablesWithoutConfigView(shardingRule, sqlStatementContext,
tableSegments)) {
throw new EngagedViewException("broadcast");
}
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingDropIndexStatementValidator.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingDropIndexStatementValidator.java
index 34ad7f38249..b3086454941 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingDropIndexStatementValidator.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingDropIndexStatementValidator.java
@@ -42,7 +42,8 @@ import java.util.stream.Collectors;
public final class ShardingDropIndexStatementValidator extends
ShardingDDLStatementValidator<DropIndexStatement> {
@Override
- public void preValidate(final ShardingRule shardingRule, final
SQLStatementContext<DropIndexStatement> sqlStatementContext, final List<Object>
parameters, final ShardingSphereDatabase database) {
+ public void preValidate(final ShardingRule shardingRule, final
SQLStatementContext<DropIndexStatement> sqlStatementContext,
+ final List<Object> parameters, final
ShardingSphereDatabase database, final ConfigurationProperties props) {
if
(DropIndexStatementHandler.ifExists(sqlStatementContext.getSqlStatement())) {
return;
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingDropTableStatementValidator.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingDropTableStatementValidator.java
index d4c484e70db..17014a6aa40 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingDropTableStatementValidator.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingDropTableStatementValidator.java
@@ -46,8 +46,8 @@ import java.util.stream.Collectors;
public final class ShardingDropTableStatementValidator extends
ShardingDDLStatementValidator<DropTableStatement> {
@Override
- public void preValidate(final ShardingRule shardingRule,
- final SQLStatementContext<DropTableStatement>
sqlStatementContext, final List<Object> parameters, final
ShardingSphereDatabase database) {
+ public void preValidate(final ShardingRule shardingRule, final
SQLStatementContext<DropTableStatement> sqlStatementContext,
+ final List<Object> parameters, final
ShardingSphereDatabase database, final ConfigurationProperties props) {
if
(!DropTableStatementHandler.ifExists(sqlStatementContext.getSqlStatement())) {
String defaultSchemaName =
DatabaseTypeEngine.getDefaultSchemaName(sqlStatementContext.getDatabaseType(),
database.getName());
ShardingSphereSchema schema =
sqlStatementContext.getTablesContext().getSchemaName()
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingPrepareStatementValidator.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingPrepareStatementValidator.java
index 040ddd152c8..57efd335b5c 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingPrepareStatementValidator.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingPrepareStatementValidator.java
@@ -37,8 +37,8 @@ import java.util.stream.Collectors;
public final class ShardingPrepareStatementValidator extends
ShardingDDLStatementValidator<PrepareStatement> {
@Override
- public void preValidate(final ShardingRule shardingRule, final
SQLStatementContext<PrepareStatement> sqlStatementContext,
- final List<Object> parameters, final
ShardingSphereDatabase database) {
+ public void preValidate(final ShardingRule shardingRule, final
SQLStatementContext<PrepareStatement> sqlStatementContext, final List<Object>
parameters, final ShardingSphereDatabase database,
+ final ConfigurationProperties props) {
}
@Override
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingRenameTableStatementValidator.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingRenameTableStatementValidator.java
index a4ecc84214c..5992bc4f79f 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingRenameTableStatementValidator.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingRenameTableStatementValidator.java
@@ -40,8 +40,8 @@ import java.util.stream.Collectors;
public final class ShardingRenameTableStatementValidator extends
ShardingDDLStatementValidator<RenameTableStatement> {
@Override
- public void preValidate(final ShardingRule shardingRule, final
SQLStatementContext<RenameTableStatement> sqlStatementContext,
- final List<Object> parameters, final
ShardingSphereDatabase database) {
+ public void preValidate(final ShardingRule shardingRule, final
SQLStatementContext<RenameTableStatement> sqlStatementContext, final
List<Object> parameters, final ShardingSphereDatabase database,
+ final ConfigurationProperties props) {
Collection<String> tableNames = sqlStatementContext instanceof
TableAvailable
? ((TableAvailable)
sqlStatementContext).getAllTables().stream().map(each ->
each.getTableName().getIdentifier().getValue()).collect(Collectors.toList())
: sqlStatementContext.getTablesContext().getTableNames();
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingCopyStatementValidator.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingCopyStatementValidator.java
index 827ba6b4634..0431a2ef5b2 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingCopyStatementValidator.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingCopyStatementValidator.java
@@ -34,8 +34,8 @@ import java.util.List;
public final class ShardingCopyStatementValidator extends
ShardingDMLStatementValidator<CopyStatement> {
@Override
- public void preValidate(final ShardingRule shardingRule,
- final SQLStatementContext<CopyStatement>
sqlStatementContext, final List<Object> parameters, final
ShardingSphereDatabase database) {
+ public void preValidate(final ShardingRule shardingRule, final
SQLStatementContext<CopyStatement> sqlStatementContext,
+ final List<Object> parameters, final
ShardingSphereDatabase database, final ConfigurationProperties props) {
String tableName =
sqlStatementContext.getSqlStatement().getTableSegment().getTableName().getIdentifier().getValue();
if (shardingRule.isShardingTable(tableName)) {
throw new UnsupportedShardingOperationException("COPY", tableName);
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingDeleteStatementValidator.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingDeleteStatementValidator.java
index 6040337965e..f06ddac7d0d 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingDeleteStatementValidator.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingDeleteStatementValidator.java
@@ -36,7 +36,7 @@ public final class ShardingDeleteStatementValidator extends
ShardingDMLStatement
@Override
public void preValidate(final ShardingRule shardingRule, final
SQLStatementContext<DeleteStatement> sqlStatementContext,
- final List<Object> parameters, final
ShardingSphereDatabase database) {
+ final List<Object> parameters, final
ShardingSphereDatabase database, final ConfigurationProperties props) {
validateMultipleTable(shardingRule, sqlStatementContext);
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingInsertStatementValidator.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingInsertStatementValidator.java
index 71fe43d2e38..2c325b30bff 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingInsertStatementValidator.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingInsertStatementValidator.java
@@ -54,7 +54,7 @@ public final class ShardingInsertStatementValidator extends
ShardingDMLStatement
@Override
public void preValidate(final ShardingRule shardingRule, final
SQLStatementContext<InsertStatement> sqlStatementContext,
- final List<Object> parameters, final
ShardingSphereDatabase database) {
+ final List<Object> parameters, final
ShardingSphereDatabase database, final ConfigurationProperties props) {
if (null == ((InsertStatementContext)
sqlStatementContext).getInsertSelectContext()) {
validateMultipleTable(shardingRule, sqlStatementContext);
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingSelectStatementValidator.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingSelectStatementValidator.java
deleted file mode 100644
index 46e4d3015b6..00000000000
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingSelectStatementValidator.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.shardingsphere.sharding.route.engine.validator.dml.impl;
-
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
-import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
-import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.route.context.RouteContext;
-import
org.apache.shardingsphere.sharding.route.engine.validator.dml.ShardingDMLStatementValidator;
-import org.apache.shardingsphere.sharding.rule.ShardingRule;
-import
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.SelectStatement;
-
-import java.util.List;
-
-/**
- * Sharding select statement validator.
- */
-@RequiredArgsConstructor
-public final class ShardingSelectStatementValidator extends
ShardingDMLStatementValidator<SelectStatement> {
-
- @Override
- public void preValidate(final ShardingRule shardingRule, final
SQLStatementContext<SelectStatement> sqlStatementContext,
- final List<Object> parameters, final
ShardingSphereDatabase database) {
- }
-
- @Override
- public void postValidate(final ShardingRule shardingRule, final
SQLStatementContext<SelectStatement> sqlStatementContext, final List<Object>
parameters,
- final ShardingSphereDatabase database, final
ConfigurationProperties props, final RouteContext routeContext) {
- }
-}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingUpdateStatementValidator.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingUpdateStatementValidator.java
index ba99b5d7af9..a2c83b64a40 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingUpdateStatementValidator.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingUpdateStatementValidator.java
@@ -39,8 +39,8 @@ import java.util.Optional;
public final class ShardingUpdateStatementValidator extends
ShardingDMLStatementValidator<UpdateStatement> {
@Override
- public void preValidate(final ShardingRule shardingRule, final
SQLStatementContext<UpdateStatement> sqlStatementContext,
- final List<Object> parameters, final
ShardingSphereDatabase database) {
+ public void preValidate(final ShardingRule shardingRule, final
SQLStatementContext<UpdateStatement> sqlStatementContext, final List<Object>
parameters, final ShardingSphereDatabase database,
+ final ConfigurationProperties props) {
validateMultipleTable(shardingRule, sqlStatementContext);
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingAlterIndexStatementValidatorTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingAlterIndexStatementValidatorTest.java
index 5d6737ab28f..db0b392f937 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingAlterIndexStatementValidatorTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingAlterIndexStatementValidatorTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.sharding.route.engine.validator.ddl;
import
org.apache.shardingsphere.infra.binder.statement.ddl.AlterIndexStatementContext;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereIndex;
import
org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereTable;
@@ -63,7 +64,7 @@ public final class ShardingAlterIndexStatementValidatorTest {
when(database.getSchema("public").getTable("t_order")).thenReturn(table);
when(indexes.containsKey("t_order_index")).thenReturn(true);
when(indexes.containsKey("t_order_index_new")).thenReturn(false);
- new ShardingAlterIndexStatementValidator().preValidate(shardingRule,
new AlterIndexStatementContext(sqlStatement), Collections.emptyList(),
database);
+ new ShardingAlterIndexStatementValidator().preValidate(shardingRule,
new AlterIndexStatementContext(sqlStatement), Collections.emptyList(),
database, mock(ConfigurationProperties.class));
}
@Test(expected = IndexNotExistedException.class)
@@ -77,7 +78,7 @@ public final class ShardingAlterIndexStatementValidatorTest {
when(database.getSchema("public").getAllTableNames()).thenReturn(Collections.singletonList("t_order"));
when(database.getSchema("public").getTable("t_order")).thenReturn(table);
when(indexes.containsKey("t_order_index")).thenReturn(false);
- new ShardingAlterIndexStatementValidator().preValidate(shardingRule,
new AlterIndexStatementContext(sqlStatement), Collections.emptyList(),
database);
+ new ShardingAlterIndexStatementValidator().preValidate(shardingRule,
new AlterIndexStatementContext(sqlStatement), Collections.emptyList(),
database, mock(ConfigurationProperties.class));
}
@Test(expected = DuplicatedIndexException.class)
@@ -92,6 +93,6 @@ public final class ShardingAlterIndexStatementValidatorTest {
when(database.getSchema("public").getTable("t_order")).thenReturn(table);
when(indexes.containsKey("t_order_index")).thenReturn(true);
when(indexes.containsKey("t_order_index_new")).thenReturn(true);
- new ShardingAlterIndexStatementValidator().preValidate(shardingRule,
new AlterIndexStatementContext(sqlStatement), Collections.emptyList(),
database);
+ new ShardingAlterIndexStatementValidator().preValidate(shardingRule,
new AlterIndexStatementContext(sqlStatement), Collections.emptyList(),
database, mock(ConfigurationProperties.class));
}
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingAlterTableStatementValidatorTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingAlterTableStatementValidatorTest.java
index c2879728b22..e0b106a829d 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingAlterTableStatementValidatorTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingAlterTableStatementValidatorTest.java
@@ -67,7 +67,7 @@ public final class ShardingAlterTableStatementValidatorTest {
sqlStatement.setRenameTable(new SimpleTableSegment(new
TableNameSegment(0, 0, new IdentifierValue("t_order_new"))));
SQLStatementContext<AlterTableStatement> sqlStatementContext = new
AlterTableStatementContext(sqlStatement);
when(shardingRule.tableRuleExists(Arrays.asList("t_order",
"t_order_new"))).thenReturn(true);
- new ShardingAlterTableStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database);
+ new ShardingAlterTableStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database,
mock(ConfigurationProperties.class));
}
@Test(expected = UnsupportedShardingOperationException.class)
@@ -78,7 +78,7 @@ public final class ShardingAlterTableStatementValidatorTest {
SQLStatementContext<AlterTableStatement> sqlStatementContext = new
AlterTableStatementContext(sqlStatement);
when(shardingRule.tableRuleExists(Arrays.asList("t_order",
"t_order_new"))).thenReturn(false);
when(shardingRule.isBroadcastTable("t_order")).thenReturn(true);
- new ShardingAlterTableStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database);
+ new ShardingAlterTableStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database,
mock(ConfigurationProperties.class));
}
@Test
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingAlterViewStatementValidatorTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingAlterViewStatementValidatorTest.java
index 1786d40ae7c..de48898f4f7 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingAlterViewStatementValidatorTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingAlterViewStatementValidatorTest.java
@@ -19,6 +19,7 @@ package
org.apache.shardingsphere.sharding.route.engine.validator.ddl;
import
org.apache.shardingsphere.infra.binder.statement.CommonSQLStatementContext;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.sharding.exception.syntax.RenamedViewWithoutSameConfigurationException;
import
org.apache.shardingsphere.sharding.exception.syntax.UnsupportedShardingOperationException;
@@ -56,7 +57,7 @@ public final class ShardingAlterViewStatementValidatorTest {
SQLStatementContext<AlterViewStatement> sqlStatementContext = new
CommonSQLStatementContext<>(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class);
when(shardingRule.isShardingTable("t_order")).thenReturn(false);
- new ShardingAlterViewStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database);
+ new ShardingAlterViewStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database,
mock(ConfigurationProperties.class));
}
@Test(expected = UnsupportedShardingOperationException.class)
@@ -68,7 +69,7 @@ public final class ShardingAlterViewStatementValidatorTest {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class);
SQLStatementContext<AlterViewStatement> sqlStatementContext = new
CommonSQLStatementContext<>(sqlStatement);
when(shardingRule.isShardingTable("t_order")).thenReturn(true);
- new ShardingAlterViewStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database);
+ new ShardingAlterViewStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database,
mock(ConfigurationProperties.class));
}
@Test
@@ -80,7 +81,7 @@ public final class ShardingAlterViewStatementValidatorTest {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class);
when(shardingRule.isBroadcastTable("t_order")).thenReturn(true);
when(shardingRule.isBroadcastTable("t_order_new")).thenReturn(true);
- new ShardingAlterViewStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database);
+ new ShardingAlterViewStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database,
mock(ConfigurationProperties.class));
}
@Test(expected = RenamedViewWithoutSameConfigurationException.class)
@@ -92,6 +93,6 @@ public final class ShardingAlterViewStatementValidatorTest {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class);
when(shardingRule.isBroadcastTable("t_order")).thenReturn(true);
when(shardingRule.isBroadcastTable("t_order_new")).thenReturn(false);
- new ShardingAlterViewStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database);
+ new ShardingAlterViewStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database,
mock(ConfigurationProperties.class));
}
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateFunctionStatementValidatorTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateFunctionStatementValidatorTest.java
index 5b575c69d0f..ce40d2f6f0e 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateFunctionStatementValidatorTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateFunctionStatementValidatorTest.java
@@ -19,6 +19,7 @@ package
org.apache.shardingsphere.sharding.route.engine.validator.ddl;
import
org.apache.shardingsphere.infra.binder.statement.CommonSQLStatementContext;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.database.DefaultDatabase;
import
org.apache.shardingsphere.dialect.exception.syntax.table.NoSuchTableException;
import
org.apache.shardingsphere.dialect.exception.syntax.table.TableExistsException;
@@ -70,7 +71,7 @@ public final class
ShardingCreateFunctionStatementValidatorTest {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
when(database.getName()).thenReturn(DefaultDatabase.LOGIC_NAME);
when(database.getSchema(DefaultDatabase.LOGIC_NAME).containsTable("t_order_item")).thenReturn(true);
- new
ShardingCreateFunctionStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database);
+ new
ShardingCreateFunctionStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database,
mock(ConfigurationProperties.class));
}
@Test(expected = NoSuchTableException.class)
@@ -86,7 +87,7 @@ public final class
ShardingCreateFunctionStatementValidatorTest {
SQLStatementContext<CreateFunctionStatement> sqlStatementContext = new
CommonSQLStatementContext<>(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
when(database.getName()).thenReturn("db_schema");
- new
ShardingCreateFunctionStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database);
+ new
ShardingCreateFunctionStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database,
mock(ConfigurationProperties.class));
}
@Test(expected = NoSuchTableException.class)
@@ -102,7 +103,7 @@ public final class
ShardingCreateFunctionStatementValidatorTest {
SQLStatementContext<CreateFunctionStatement> sqlStatementContext = new
CommonSQLStatementContext<>(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
when(database.getName()).thenReturn("db_schema");
- new
ShardingCreateFunctionStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database);
+ new
ShardingCreateFunctionStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database,
mock(ConfigurationProperties.class));
}
@Test(expected = TableExistsException.class)
@@ -119,6 +120,6 @@ public final class
ShardingCreateFunctionStatementValidatorTest {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
when(database.getName()).thenReturn(DefaultDatabase.LOGIC_NAME);
when(database.getSchema(DefaultDatabase.LOGIC_NAME).containsTable("t_order")).thenReturn(true);
- new
ShardingCreateFunctionStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database);
+ new
ShardingCreateFunctionStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database,
mock(ConfigurationProperties.class));
}
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateIndexStatementValidatorTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateIndexStatementValidatorTest.java
index 1d30816e662..bf87eb5be9e 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateIndexStatementValidatorTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateIndexStatementValidatorTest.java
@@ -19,6 +19,7 @@ package
org.apache.shardingsphere.sharding.route.engine.validator.ddl;
import
org.apache.shardingsphere.dialect.exception.syntax.table.NoSuchTableException;
import
org.apache.shardingsphere.infra.binder.statement.ddl.CreateIndexStatementContext;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereTable;
import
org.apache.shardingsphere.sharding.exception.metadata.DuplicatedIndexException;
@@ -59,7 +60,7 @@ public final class ShardingCreateIndexStatementValidatorTest {
when(database.getSchema("public").containsTable("t_order")).thenReturn(true);
ShardingSphereTable table = mock(ShardingSphereTable.class);
when(database.getSchema("public").getTable("t_order")).thenReturn(table);
- new ShardingCreateIndexStatementValidator().preValidate(shardingRule,
new CreateIndexStatementContext(sqlStatement), Collections.emptyList(),
database);
+ new ShardingCreateIndexStatementValidator().preValidate(shardingRule,
new CreateIndexStatementContext(sqlStatement), Collections.emptyList(),
database, mock(ConfigurationProperties.class));
}
@Test(expected = NoSuchTableException.class)
@@ -68,7 +69,7 @@ public final class ShardingCreateIndexStatementValidatorTest {
sqlStatement.setTable(new SimpleTableSegment(new TableNameSegment(0,
0, new IdentifierValue("t_order"))));
sqlStatement.setIndex(new IndexSegment(0, 0, new IndexNameSegment(0,
0, new IdentifierValue("t_order_index"))));
when(database.getSchema("public").containsTable("t_order")).thenReturn(false);
- new ShardingCreateIndexStatementValidator().preValidate(shardingRule,
new CreateIndexStatementContext(sqlStatement), Collections.emptyList(),
database);
+ new ShardingCreateIndexStatementValidator().preValidate(shardingRule,
new CreateIndexStatementContext(sqlStatement), Collections.emptyList(),
database, mock(ConfigurationProperties.class));
}
@Test(expected = DuplicatedIndexException.class)
@@ -80,7 +81,7 @@ public final class ShardingCreateIndexStatementValidatorTest {
ShardingSphereTable table = mock(ShardingSphereTable.class);
when(database.getSchema("public").getTable("t_order")).thenReturn(table);
when(database.getSchema("public").containsIndex("t_order",
"t_order_index")).thenReturn(true);
- new ShardingCreateIndexStatementValidator().preValidate(shardingRule,
new CreateIndexStatementContext(sqlStatement), Collections.emptyList(),
database);
+ new ShardingCreateIndexStatementValidator().preValidate(shardingRule,
new CreateIndexStatementContext(sqlStatement), Collections.emptyList(),
database, mock(ConfigurationProperties.class));
}
@Test
@@ -92,7 +93,7 @@ public final class ShardingCreateIndexStatementValidatorTest {
when(database.getSchema("public").containsTable("t_order")).thenReturn(true);
ShardingSphereTable table = mock(ShardingSphereTable.class);
when(database.getSchema("public").getTable("t_order")).thenReturn(table);
- new ShardingCreateIndexStatementValidator().preValidate(shardingRule,
new CreateIndexStatementContext(sqlStatement), Collections.emptyList(),
database);
+ new ShardingCreateIndexStatementValidator().preValidate(shardingRule,
new CreateIndexStatementContext(sqlStatement), Collections.emptyList(),
database, mock(ConfigurationProperties.class));
}
@Test(expected = NoSuchTableException.class)
@@ -102,7 +103,7 @@ public final class
ShardingCreateIndexStatementValidatorTest {
sqlStatement.getColumns().add(new ColumnSegment(0, 0, new
IdentifierValue("content")));
sqlStatement.setGeneratedIndexStartIndex(10);
when(database.getSchema("public").containsTable("t_order")).thenReturn(false);
- new ShardingCreateIndexStatementValidator().preValidate(shardingRule,
new CreateIndexStatementContext(sqlStatement), Collections.emptyList(),
database);
+ new ShardingCreateIndexStatementValidator().preValidate(shardingRule,
new CreateIndexStatementContext(sqlStatement), Collections.emptyList(),
database, mock(ConfigurationProperties.class));
}
@Test(expected = DuplicatedIndexException.class)
@@ -115,6 +116,6 @@ public final class
ShardingCreateIndexStatementValidatorTest {
ShardingSphereTable table = mock(ShardingSphereTable.class);
when(database.getSchema("public").getTable("t_order")).thenReturn(table);
when(database.getSchema("public").containsIndex("t_order",
"content_idx")).thenReturn(true);
- new ShardingCreateIndexStatementValidator().preValidate(shardingRule,
new CreateIndexStatementContext(sqlStatement), Collections.emptyList(),
database);
+ new ShardingCreateIndexStatementValidator().preValidate(shardingRule,
new CreateIndexStatementContext(sqlStatement), Collections.emptyList(),
database, mock(ConfigurationProperties.class));
}
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateProcedureStatementValidatorTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateProcedureStatementValidatorTest.java
index 3346e356254..a690a66b777 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateProcedureStatementValidatorTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateProcedureStatementValidatorTest.java
@@ -19,6 +19,7 @@ package
org.apache.shardingsphere.sharding.route.engine.validator.ddl;
import
org.apache.shardingsphere.infra.binder.statement.CommonSQLStatementContext;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.database.DefaultDatabase;
import
org.apache.shardingsphere.dialect.exception.syntax.table.NoSuchTableException;
import
org.apache.shardingsphere.dialect.exception.syntax.table.TableExistsException;
@@ -71,7 +72,7 @@ public final class
ShardingCreateProcedureStatementValidatorTest {
when(database.getSchema(DefaultDatabase.LOGIC_NAME).containsTable("t_order_item")).thenReturn(true);
when(shardingRule.isShardingTable("t_order_item")).thenReturn(false);
SQLStatementContext<CreateProcedureStatement> sqlStatementContext =
new CommonSQLStatementContext<>(sqlStatement);
- new
ShardingCreateProcedureStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database);
+ new
ShardingCreateProcedureStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database,
mock(ConfigurationProperties.class));
}
@Test(expected = NoSuchTableException.class)
@@ -87,7 +88,7 @@ public final class
ShardingCreateProcedureStatementValidatorTest {
SQLStatementContext<CreateProcedureStatement> sqlStatementContext =
new CommonSQLStatementContext<>(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
when(database.getName()).thenReturn("db_schema");
- new
ShardingCreateProcedureStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database);
+ new
ShardingCreateProcedureStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database,
mock(ConfigurationProperties.class));
}
@Test(expected = NoSuchTableException.class)
@@ -103,7 +104,7 @@ public final class
ShardingCreateProcedureStatementValidatorTest {
SQLStatementContext<CreateProcedureStatement> sqlStatementContext =
new CommonSQLStatementContext<>(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
when(database.getName()).thenReturn("db_schema");
- new
ShardingCreateProcedureStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database);
+ new
ShardingCreateProcedureStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database,
mock(ConfigurationProperties.class));
}
@Test(expected = TableExistsException.class)
@@ -120,6 +121,6 @@ public final class
ShardingCreateProcedureStatementValidatorTest {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
when(database.getName()).thenReturn(DefaultDatabase.LOGIC_NAME);
when(database.getSchema(DefaultDatabase.LOGIC_NAME).containsTable("t_order")).thenReturn(true);
- new
ShardingCreateProcedureStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database);
+ new
ShardingCreateProcedureStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database,
mock(ConfigurationProperties.class));
}
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateTableStatementValidatorTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateTableStatementValidatorTest.java
index 30a0e505bd5..8451a98f92f 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateTableStatementValidatorTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateTableStatementValidatorTest.java
@@ -105,7 +105,7 @@ public final class
ShardingCreateTableStatementValidatorTest {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
when(database.getName()).thenReturn("sharding_db");
when(database.getSchema(schemaName).containsTable("t_order")).thenReturn(true);
- new ShardingCreateTableStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database);
+ new ShardingCreateTableStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database,
mock(ConfigurationProperties.class));
}
@Test
@@ -125,7 +125,7 @@ public final class
ShardingCreateTableStatementValidatorTest {
private void assertPreValidateCreateTableIfNotExists(final
CreateTableStatement sqlStatement) {
SQLStatementContext<CreateTableStatement> sqlStatementContext = new
CreateTableStatementContext(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
- new ShardingCreateTableStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database);
+ new ShardingCreateTableStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database,
mock(ConfigurationProperties.class));
}
@Test
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateViewStatementValidatorTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateViewStatementValidatorTest.java
index af4b6681542..f6bd634a5fc 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateViewStatementValidatorTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateViewStatementValidatorTest.java
@@ -19,6 +19,7 @@ package
org.apache.shardingsphere.sharding.route.engine.validator.ddl;
import
org.apache.shardingsphere.infra.binder.statement.ddl.CreateViewStatementContext;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.route.context.RouteContext;
import
org.apache.shardingsphere.sharding.exception.metadata.EngagedViewException;
@@ -74,16 +75,17 @@ public final class ShardingCreateViewStatementValidatorTest
{
@Test
public void assertPreValidateCreateView() {
- when(shardingRule.isShardingTable(any())).thenReturn(true);
- when(shardingRule.isAllBindingTables(any())).thenReturn(true);
- new ShardingCreateViewStatementValidator().preValidate(shardingRule,
createViewStatementContext, Collections.emptyList(),
mock(ShardingSphereDatabase.class));
+ new ShardingCreateViewStatementValidator().preValidate(shardingRule,
createViewStatementContext, Collections.emptyList(),
mock(ShardingSphereDatabase.class),
+ mock(ConfigurationProperties.class));
}
@Test(expected = EngagedViewException.class)
public void assertPreValidateCreateViewWithException() {
when(shardingRule.isShardingTable(any())).thenReturn(true);
when(shardingRule.isAllBindingTables(any())).thenReturn(false);
- new ShardingCreateViewStatementValidator().preValidate(shardingRule,
createViewStatementContext, Collections.emptyList(),
mock(ShardingSphereDatabase.class));
+ ConfigurationProperties props = mock(ConfigurationProperties.class);
+
when(props.getValue(ConfigurationPropertyKey.SQL_FEDERATION_TYPE)).thenReturn("NONE");
+ new ShardingCreateViewStatementValidator().preValidate(shardingRule,
createViewStatementContext, Collections.emptyList(),
mock(ShardingSphereDatabase.class), props);
}
@Test
@@ -107,6 +109,8 @@ public final class ShardingCreateViewStatementValidatorTest
{
public void assertPreValidateCreateViewWithBroadcastTable() {
when(shardingRule.isAllBroadcastTables(any())).thenReturn(true);
when(shardingRule.isBroadcastTable("order_view")).thenReturn(false);
- new ShardingCreateViewStatementValidator().preValidate(shardingRule,
createViewStatementContext, Collections.emptyList(),
mock(ShardingSphereDatabase.class));
+ ConfigurationProperties props = mock(ConfigurationProperties.class);
+
when(props.getValue(ConfigurationPropertyKey.SQL_FEDERATION_TYPE)).thenReturn("NONE");
+ new ShardingCreateViewStatementValidator().preValidate(shardingRule,
createViewStatementContext, Collections.emptyList(),
mock(ShardingSphereDatabase.class), props);
}
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingDropIndexStatementValidatorTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingDropIndexStatementValidatorTest.java
index 331b48ab9ff..a3e666e7f42 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingDropIndexStatementValidatorTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingDropIndexStatementValidatorTest.java
@@ -74,7 +74,7 @@ public final class ShardingDropIndexStatementValidatorTest {
when(database.getSchema("public").getTable("t_order")).thenReturn(table);
when(indexes.containsKey("t_order_index")).thenReturn(true);
when(indexes.containsKey("t_order_index_new")).thenReturn(true);
- new ShardingDropIndexStatementValidator().preValidate(shardingRule,
new DropIndexStatementContext(sqlStatement), Collections.emptyList(), database);
+ new ShardingDropIndexStatementValidator().preValidate(shardingRule,
new DropIndexStatementContext(sqlStatement), Collections.emptyList(), database,
mock(ConfigurationProperties.class));
}
@Test(expected = IndexNotExistedException.class)
@@ -88,7 +88,7 @@ public final class ShardingDropIndexStatementValidatorTest {
when(database.getSchema("public").getAllTableNames()).thenReturn(Collections.singletonList("t_order"));
when(database.getSchema("public").getTable("t_order")).thenReturn(table);
when(indexes.containsKey("t_order_index")).thenReturn(false);
- new ShardingDropIndexStatementValidator().preValidate(shardingRule,
new DropIndexStatementContext(sqlStatement), Collections.emptyList(), database);
+ new ShardingDropIndexStatementValidator().preValidate(shardingRule,
new DropIndexStatementContext(sqlStatement), Collections.emptyList(), database,
mock(ConfigurationProperties.class));
}
@Test
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingDropTableStatementValidatorTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingDropTableStatementValidatorTest.java
index 7bc33755c74..19b82a06527 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingDropTableStatementValidatorTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingDropTableStatementValidatorTest.java
@@ -81,7 +81,7 @@ public final class ShardingDropTableStatementValidatorTest {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
when(database.getName()).thenReturn("db_schema");
ShardingDropTableStatementValidator validator = new
ShardingDropTableStatementValidator();
- validator.preValidate(shardingRule, sqlStatementContext,
Collections.emptyList(), database);
+ validator.preValidate(shardingRule, sqlStatementContext,
Collections.emptyList(), database, mock(ConfigurationProperties.class));
Collection<RouteUnit> routeUnits = new LinkedList<>();
RouteMapper dataSourceMapper = new RouteMapper("db", "db1");
Collection<RouteMapper> tableMapper = new LinkedList<>();
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingRenameTableStatementValidatorTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingRenameTableStatementValidatorTest.java
index dd73258ff53..b280e8de0a6 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingRenameTableStatementValidatorTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingRenameTableStatementValidatorTest.java
@@ -59,7 +59,7 @@ public final class ShardingRenameTableStatementValidatorTest {
SQLStatementContext<RenameTableStatement> sqlStatementContext =
createRenameTableStatementContext("t_order", "t_user_order");
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class);
when(shardingRule.tableRuleExists(argThat(tableNames ->
tableNames.contains("t_order") ||
tableNames.contains("t_user_order")))).thenReturn(true);
- new ShardingRenameTableStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database);
+ new ShardingRenameTableStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database,
mock(ConfigurationProperties.class));
}
@Test(expected = UnsupportedShardingOperationException.class)
@@ -67,14 +67,14 @@ public final class
ShardingRenameTableStatementValidatorTest {
SQLStatementContext<RenameTableStatement> sqlStatementContext =
createRenameTableStatementContext("t_order", "t_user_order");
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class);
when(shardingRule.isBroadcastTable(eq("t_order"))).thenReturn(true);
- new ShardingRenameTableStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database);
+ new ShardingRenameTableStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database,
mock(ConfigurationProperties.class));
}
@Test
public void assertPreValidateNormalCase() {
SQLStatementContext<RenameTableStatement> sqlStatementContext =
createRenameTableStatementContext("t_not_sharding_table",
"t_not_sharding_table_new");
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class);
- new ShardingRenameTableStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database);
+ new ShardingRenameTableStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database,
mock(ConfigurationProperties.class));
}
@Test(expected = ShardingDDLRouteException.class)
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingCopyStatementValidatorTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingCopyStatementValidatorTest.java
index 5e141594080..87a6f3069f7 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingCopyStatementValidatorTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingCopyStatementValidatorTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.sharding.route.engine.validator.dml;
import
org.apache.shardingsphere.infra.binder.statement.dml.CopyStatementContext;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.sharding.exception.syntax.UnsupportedShardingOperationException;
import
org.apache.shardingsphere.sharding.route.engine.validator.dml.impl.ShardingCopyStatementValidator;
@@ -52,14 +53,14 @@ public final class ShardingCopyStatementValidatorTest {
public void assertPreValidateWhenTableSegmentForPostgreSQL() {
PostgreSQLCopyStatement sqlStatement = new PostgreSQLCopyStatement();
sqlStatement.setTableSegment(new SimpleTableSegment(new
TableNameSegment(0, 0, new IdentifierValue("t_order"))));
- new ShardingCopyStatementValidator().preValidate(shardingRule, new
CopyStatementContext(sqlStatement), Collections.emptyList(), database);
+ new ShardingCopyStatementValidator().preValidate(shardingRule, new
CopyStatementContext(sqlStatement), Collections.emptyList(), database,
mock(ConfigurationProperties.class));
}
@Test
public void assertPreValidateWhenTableSegmentForOpenGauss() {
OpenGaussCopyStatement sqlStatement = new OpenGaussCopyStatement();
sqlStatement.setTableSegment(new SimpleTableSegment(new
TableNameSegment(0, 0, new IdentifierValue("t_order"))));
- new ShardingCopyStatementValidator().preValidate(shardingRule, new
CopyStatementContext(sqlStatement), Collections.emptyList(), database);
+ new ShardingCopyStatementValidator().preValidate(shardingRule, new
CopyStatementContext(sqlStatement), Collections.emptyList(), database,
mock(ConfigurationProperties.class));
}
@Test(expected = UnsupportedShardingOperationException.class)
@@ -77,6 +78,6 @@ public final class ShardingCopyStatementValidatorTest {
CopyStatementContext sqlStatementContext = new
CopyStatementContext(sqlStatement);
String tableName = "t_order";
when(shardingRule.isShardingTable(tableName)).thenReturn(true);
- new ShardingCopyStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(),
mock(ShardingSphereDatabase.class));
+ new ShardingCopyStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(),
mock(ShardingSphereDatabase.class), mock(ConfigurationProperties.class));
}
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingDeleteStatementValidatorTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingDeleteStatementValidatorTest.java
index 1d24e152e77..58eea06a610 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingDeleteStatementValidatorTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingDeleteStatementValidatorTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.sharding.route.engine.validator.dml;
import
org.apache.shardingsphere.infra.binder.statement.dml.DeleteStatementContext;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.sharding.exception.syntax.DMLWithMultipleShardingTablesException;
import
org.apache.shardingsphere.sharding.route.engine.validator.dml.impl.ShardingDeleteStatementValidator;
@@ -86,6 +87,6 @@ public final class ShardingDeleteStatementValidatorTest {
Collection<String> tableNames = new HashSet<>(Arrays.asList("user",
"order", "order_item"));
when(shardingRule.isAllShardingTables(tableNames)).thenReturn(false);
when(shardingRule.tableRuleExists(tableNames)).thenReturn(true);
- new ShardingDeleteStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(),
mock(ShardingSphereDatabase.class));
+ new ShardingDeleteStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(),
mock(ShardingSphereDatabase.class), mock(ConfigurationProperties.class));
}
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingInsertStatementValidatorTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingInsertStatementValidatorTest.java
index 58f99afbd1c..8eb2ab6c090 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingInsertStatementValidatorTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingInsertStatementValidatorTest.java
@@ -91,7 +91,7 @@ public final class ShardingInsertStatementValidatorTest {
when(shardingRule.isAllShardingTables(tableNames)).thenReturn(false);
when(shardingRule.tableRuleExists(tableNames)).thenReturn(true);
new
ShardingInsertStatementValidator(shardingConditions).preValidate(shardingRule,
- sqlStatementContext, Collections.emptyList(),
mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS));
+ sqlStatementContext, Collections.emptyList(),
mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS),
mock(ConfigurationProperties.class));
}
private InsertStatementContext createInsertStatementContext(final
List<Object> parameters, final InsertStatement insertStatement) {
@@ -107,7 +107,7 @@ public final class ShardingInsertStatementValidatorTest {
SQLStatementContext<InsertStatement> sqlStatementContext =
createInsertStatementContext(Collections.singletonList(1),
createInsertSelectStatement());
sqlStatementContext.getTablesContext().getTableNames().addAll(createSingleTablesContext().getTableNames());
new
ShardingInsertStatementValidator(shardingConditions).preValidate(shardingRule,
- sqlStatementContext, Collections.emptyList(),
mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS));
+ sqlStatementContext, Collections.emptyList(),
mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS),
mock(ConfigurationProperties.class));
}
@Test
@@ -116,7 +116,8 @@ public final class ShardingInsertStatementValidatorTest {
when(shardingRule.isGenerateKeyColumn("id", "user")).thenReturn(true);
SQLStatementContext<InsertStatement> sqlStatementContext =
createInsertStatementContext(Collections.singletonList(1),
createInsertSelectStatement());
sqlStatementContext.getTablesContext().getTableNames().addAll(createSingleTablesContext().getTableNames());
- new
ShardingInsertStatementValidator(shardingConditions).preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(),
mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS));
+ new
ShardingInsertStatementValidator(shardingConditions).preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(),
mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS),
+ mock(ConfigurationProperties.class));
}
@Test(expected = InsertSelectTableViolationException.class)
@@ -128,7 +129,8 @@ public final class ShardingInsertStatementValidatorTest {
when(shardingRule.tableRuleExists(multiTablesContext.getTableNames())).thenReturn(true);
SQLStatementContext<InsertStatement> sqlStatementContext =
createInsertStatementContext(Collections.singletonList(1),
createInsertSelectStatement());
sqlStatementContext.getTablesContext().getTableNames().addAll(multiTablesContext.getTableNames());
- new
ShardingInsertStatementValidator(shardingConditions).preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(),
mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS));
+ new
ShardingInsertStatementValidator(shardingConditions).preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(),
mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS),
+ mock(ConfigurationProperties.class));
}
@Test
@@ -139,7 +141,7 @@ public final class ShardingInsertStatementValidatorTest {
SQLStatementContext<InsertStatement> sqlStatementContext =
createInsertStatementContext(Collections.singletonList(1),
createInsertSelectStatement());
sqlStatementContext.getTablesContext().getTableNames().addAll(multiTablesContext.getTableNames());
new
ShardingInsertStatementValidator(shardingConditions).preValidate(shardingRule,
- sqlStatementContext, Collections.emptyList(),
mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS));
+ sqlStatementContext, Collections.emptyList(),
mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS),
mock(ConfigurationProperties.class));
}
@Test
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingUpdateStatementValidatorTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingUpdateStatementValidatorTest.java
index 835256f1cdc..a38993d2584 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingUpdateStatementValidatorTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingUpdateStatementValidatorTest.java
@@ -75,7 +75,7 @@ public final class ShardingUpdateStatementValidatorTest {
Collection<String> tableNames =
sqlStatementContext.getTablesContext().getTableNames();
when(shardingRule.isAllShardingTables(tableNames)).thenReturn(true);
when(shardingRule.tableRuleExists(tableNames)).thenReturn(true);
- new ShardingUpdateStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(),
mock(ShardingSphereDatabase.class));
+ new ShardingUpdateStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(),
mock(ShardingSphereDatabase.class), mock(ConfigurationProperties.class));
}
@Test(expected = DMLWithMultipleShardingTablesException.class)
@@ -89,7 +89,7 @@ public final class ShardingUpdateStatementValidatorTest {
Collection<String> tableNames =
sqlStatementContext.getTablesContext().getTableNames();
when(shardingRule.isAllShardingTables(tableNames)).thenReturn(false);
when(shardingRule.tableRuleExists(tableNames)).thenReturn(true);
- new ShardingUpdateStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(),
mock(ShardingSphereDatabase.class));
+ new ShardingUpdateStatementValidator().preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(),
mock(ShardingSphereDatabase.class), mock(ConfigurationProperties.class));
}
@Test
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-showprocesslist/src/test/java/org/apache/shardingsphere/test/integration/showprocesslist/engine/ShowProcessListIT.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-showprocesslist/src/test/java/org/apache/shardingsphere/test/integration/showprocesslist/engine/ShowProcessListIT.java
index b2aba8b2f9c..60bbb544ef9 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-showprocesslist/src/test/java/org/apache/shardingsphere/test/integration/showprocesslist/engine/ShowProcessListIT.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-showprocesslist/src/test/java/org/apache/shardingsphere/test/integration/showprocesslist/engine/ShowProcessListIT.java
@@ -82,9 +82,8 @@ public final class ShowProcessListIT {
CompletableFuture<Void> executeSelectSleep3 =
CompletableFuture.runAsync(getExecuteSleepThread("proxy"));
Thread.sleep(100);
try (
- Connection connection =
containerComposer.getProxyDataSource().getConnection();
- Statement statement = connection.createStatement()
- ) {
+ Connection connection =
containerComposer.getProxyDataSource().getConnection();
+ Statement statement = connection.createStatement()) {
ResultSet resultSet = statement.executeQuery("show processlist");
assertResultSet(resultSet);
}
@@ -109,9 +108,8 @@ public final class ShowProcessListIT {
private Runnable getExecuteSleepThread(final String targetContainer) {
return () -> {
try (
- Connection connection = "proxy".equals(targetContainer) ?
containerComposer.getProxyDataSource().getConnection() :
containerComposer.getJdbcDataSource().getConnection();
- Statement statement = connection.createStatement()
- ) {
+ Connection connection = "proxy".equals(targetContainer) ?
containerComposer.getProxyDataSource().getConnection() :
containerComposer.getJdbcDataSource().getConnection();
+ Statement statement = connection.createStatement()) {
statement.executeQuery("select sleep(10)");
} catch (SQLException ex) {
throw new RuntimeException(ex);