You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ch...@apache.org on 2024/12/13 01:19:49 UTC
(shardingsphere) branch master updated: Add TableSegmentBoundInfo for TableNameSegment and modify TablesContext logic (#34026)
This is an automated email from the ASF dual-hosted git repository.
chengzhang 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 f23d90899da Add TableSegmentBoundInfo for TableNameSegment and modify TablesContext logic (#34026)
f23d90899da is described below
commit f23d90899da4ae25037b4201bf1ddbe17296743e
Author: Zhengqiang Duan <du...@apache.org>
AuthorDate: Fri Dec 13 09:19:41 2024 +0800
Add TableSegmentBoundInfo for TableNameSegment and modify TablesContext logic (#34026)
* Add TableSegmentBoundInfo for TableNameSegment and modify TablesContext logic
* fix unit test
* fix unit test
* fix unit test
---
.../engine/BroadcastRouteEngineFactoryTest.java | 5 +-
.../EncryptOrderByItemSupportedCheckerTest.java | 2 +-
.../fixture/EncryptGeneratorFixtureBuilder.java | 2 +-
.../EncryptProjectionTokenGeneratorTest.java | 6 +-
.../EncryptGroupByItemTokenGeneratorTest.java | 2 +-
...dowDMLStatementDataSourceMappingsRetriever.java | 6 +-
...SelectStatementDataSourceMappingsRetriever.java | 16 +---
...ctStatementDataSourceMappingsRetrieverTest.java | 31 +++++---
.../ShardingAlterIndexSupportedCheckerTest.java | 6 +-
.../ShardingAlterTableSupportedCheckerTest.java | 2 +-
.../ddl/ShardingAlterViewSupportedCheckerTest.java | 6 +-
...ShardingCreateFunctionSupportedCheckerTest.java | 8 +-
.../ShardingCreateIndexSupportedCheckerTest.java | 12 +--
...hardingCreateProcedureSupportedCheckerTest.java | 8 +-
.../ShardingCreateTableSupportedCheckerTest.java | 4 +-
.../ddl/ShardingDropIndexSupportedCheckerTest.java | 4 +-
.../ddl/ShardingDropTableSupportedCheckerTest.java | 2 +-
.../ddl/ShardingInsertSupportedCheckerTest.java | 4 +-
.../ShardingRenameTableSupportedCheckerTest.java | 2 +-
.../sql/dml/ShardingCopySupportedCheckerTest.java | 6 +-
.../dml/ShardingDeleteSupportedCheckerTest.java | 2 +-
.../dml/ShardingLoadDataSupportedCheckerTest.java | 4 +-
.../dml/ShardingLoadXmlSupportedCheckerTest.java | 4 +-
.../dml/ShardingUpdateSupportedCheckerTest.java | 4 +-
.../merge/ddl/ShardingDDLResultMergerTest.java | 2 +-
.../ddl/fetch/FetchStreamMergedResultTest.java | 2 +-
.../ShardingAlterTableRouteContextCheckerTest.java | 4 +-
...ShardingCreateTableRouteContextCheckerTest.java | 6 +-
.../ShardingDropIndexRouteContextCheckerTest.java | 4 +-
.../ShardingDropTableRouteContextCheckerTest.java | 8 +-
...ShardingRenameTableRouteContextCheckerTest.java | 2 +-
.../dml/ShardingUpdateRouteContextCheckerTest.java | 6 +-
.../type/ShardingRouteEngineFactoryTest.java | 2 +-
.../sharding/rule/ShardingRuleTest.java | 2 +-
.../context/segment/table/TablesContext.java | 40 ++++------
.../statement/SQLStatementContextFactory.java | 74 +++++++++---------
.../dal/AnalyzeTableStatementContext.java | 4 +-
.../statement/dal/ExplainStatementContext.java | 4 +-
.../statement/dal/FlushStatementContext.java | 4 +-
.../dal/OptimizeTableStatementContext.java | 4 +-
.../statement/dal/ShowColumnsStatementContext.java | 4 +-
.../dal/ShowCreateTableStatementContext.java | 4 +-
.../statement/dal/ShowIndexStatementContext.java | 4 +-
.../statement/dcl/DenyUserStatementContext.java | 4 +-
.../statement/dcl/GrantStatementContext.java | 4 +-
.../statement/dcl/RevokeStatementContext.java | 4 +-
.../statement/ddl/AlterIndexStatementContext.java | 4 +-
.../statement/ddl/AlterTableStatementContext.java | 4 +-
.../statement/ddl/AlterViewStatementContext.java | 4 +-
.../statement/ddl/CloseStatementContext.java | 4 +-
.../statement/ddl/CommentStatementContext.java | 4 +-
.../ddl/CreateFunctionStatementContext.java | 4 +-
.../statement/ddl/CreateIndexStatementContext.java | 4 +-
.../ddl/CreateProcedureStatementContext.java | 4 +-
.../statement/ddl/CreateTableStatementContext.java | 4 +-
.../statement/ddl/CreateViewStatementContext.java | 4 +-
.../statement/ddl/CursorStatementContext.java | 4 +-
.../statement/ddl/DropIndexStatementContext.java | 4 +-
.../statement/ddl/DropTableStatementContext.java | 4 +-
.../statement/ddl/DropViewStatementContext.java | 4 +-
.../statement/ddl/FetchStatementContext.java | 4 +-
.../statement/ddl/MoveStatementContext.java | 4 +-
.../statement/ddl/PrepareStatementContext.java | 4 +-
.../statement/ddl/RenameTableStatementContext.java | 4 +-
.../statement/ddl/TruncateStatementContext.java | 4 +-
.../statement/dml/CopyStatementContext.java | 4 +-
.../statement/dml/DeleteStatementContext.java | 4 +-
.../statement/dml/InsertStatementContext.java | 4 +-
.../statement/dml/LoadDataStatementContext.java | 4 +-
.../statement/dml/LoadXMLStatementContext.java | 4 +-
.../statement/dml/SelectStatementContext.java | 2 +-
.../statement/dml/UpdateStatementContext.java | 8 +-
.../from/type/SimpleTableSegmentBinder.java | 1 +
.../engine/ProjectionsContextEngineTest.java | 25 +++++--
.../context/segment/table/TablesContextTest.java | 87 +++++++++++-----------
.../dal/AnalyzeTableStatementContextTest.java | 13 +++-
.../statement/dal/ExplainStatementContextTest.java | 2 +-
.../dal/OptimizeTableStatementContextTest.java | 7 +-
.../dal/ShowColumnsStatementContextTest.java | 7 +-
.../dal/ShowCreateTableStatementContextTest.java | 7 +-
.../dal/ShowIndexStatementContextTest.java | 7 +-
.../dcl/DenyUserStatementContextTest.java | 7 +-
.../statement/dcl/GrantStatementContextTest.java | 11 ++-
.../statement/dcl/RevokeStatementContextTest.java | 11 ++-
.../ddl/AlterIndexStatementContextTest.java | 2 +-
.../ddl/AlterTableStatementContextTest.java | 11 ++-
.../ddl/AlterViewStatementContextTest.java | 11 ++-
.../ddl/CreateFunctionStatementContextTest.java | 2 +-
.../ddl/CreateIndexStatementContextTest.java | 4 +-
.../ddl/CreateProcedureStatementContextTest.java | 2 +-
.../ddl/CreateTableStatementContextTest.java | 2 +-
.../ddl/CreateViewStatementContextTest.java | 7 +-
.../ddl/DropIndexStatementContextTest.java | 2 +-
.../ddl/DropTableStatementContextTest.java | 2 +-
.../ddl/DropViewStatementContextTest.java | 11 ++-
.../statement/ddl/PrepareStatementContextTest.java | 7 +-
.../ddl/TruncateStatementContextTest.java | 11 ++-
.../statement/dml/DeleteStatementContextTest.java | 11 ++-
.../statement/dml/InsertStatementContextTest.java | 49 +++++++++---
.../statement/dml/SelectStatementContextTest.java | 36 ++++++---
.../statement/dml/UpdateStatementContextTest.java | 15 +++-
.../executor/sql/process/ProcessEngineTest.java | 7 +-
.../sql/SingleDropTableSupportedCheckerTest.java | 2 +-
.../single/route/SingleSQLRouterTest.java | 8 +-
.../statement/core/extractor/TableExtractor.java | 8 +-
.../segment/generic/table/TableNameSegment.java | 13 +++-
.../backend/connector/ProxySQLExecutorTest.java | 8 +-
.../admin/PostgreSQLAdminExecutorCreatorTest.java | 2 +-
108 files changed, 496 insertions(+), 368 deletions(-)
diff --git a/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/route/engine/BroadcastRouteEngineFactoryTest.java b/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/route/engine/BroadcastRouteEngineFactoryTest.java
index 1a82b8480b2..0eabb0847b6 100644
--- a/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/route/engine/BroadcastRouteEngineFactoryTest.java
+++ b/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/route/engine/BroadcastRouteEngineFactoryTest.java
@@ -26,10 +26,8 @@ import org.apache.shardingsphere.infra.binder.context.segment.table.TablesContex
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.binder.context.statement.ddl.CloseStatementContext;
import org.apache.shardingsphere.infra.binder.context.type.TableAvailable;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.session.query.QueryContext;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.DALStatement;
@@ -137,7 +135,6 @@ class BroadcastRouteEngineFactoryTest {
}
private TablesContext createTablesContext() {
- DatabaseType databaseType = TypedSPILoader.getService(DatabaseType.class, "FIXTURE");
- return new TablesContext(Collections.singleton(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("foo_tbl")))), databaseType, null);
+ return new TablesContext(Collections.singleton(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("foo_tbl")))), null);
}
}
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/checker/sql/orderby/EncryptOrderByItemSupportedCheckerTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/checker/sql/orderby/EncryptOrderByItemSupportedCheckerTest.java
index d513329c082..bd54b59414a 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/checker/sql/orderby/EncryptOrderByItemSupportedCheckerTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/checker/sql/orderby/EncryptOrderByItemSupportedCheckerTest.java
@@ -123,7 +123,7 @@ class EncryptOrderByItemSupportedCheckerTest {
when(result.getOrderByContext().getItems()).thenReturn(Collections.singleton(orderByItem));
when(result.getGroupByContext().getItems()).thenReturn(Collections.emptyList());
when(result.getSubqueryContexts().values()).thenReturn(Collections.emptyList());
- when(result.getTablesContext()).thenReturn(new TablesContext(Collections.singleton(simpleTableSegment), databaseType, "foo_db"));
+ when(result.getTablesContext()).thenReturn(new TablesContext(Collections.singleton(simpleTableSegment)));
return result;
}
}
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/fixture/EncryptGeneratorFixtureBuilder.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/fixture/EncryptGeneratorFixtureBuilder.java
index 80287886d79..5befae4ed05 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/fixture/EncryptGeneratorFixtureBuilder.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/fixture/EncryptGeneratorFixtureBuilder.java
@@ -164,7 +164,7 @@ public final class EncryptGeneratorFixtureBuilder {
updateStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_user"))));
updateStatement.setWhere(createWhereSegment());
updateStatement.setSetAssignment(createSetAssignmentSegment());
- return new UpdateStatementContext(updateStatement, "foo_db");
+ return new UpdateStatementContext(updateStatement);
}
private static WhereSegment createWhereSegment() {
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/projection/EncryptProjectionTokenGeneratorTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/projection/EncryptProjectionTokenGeneratorTest.java
index 627e0b4b171..5648193a7d5 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/projection/EncryptProjectionTokenGeneratorTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/projection/EncryptProjectionTokenGeneratorTest.java
@@ -92,7 +92,7 @@ class EncryptProjectionTokenGeneratorTest {
when(sqlStatementContext.getSqlStatement().getProjections()).thenReturn(projections);
when(sqlStatementContext.getSubqueryContexts().values()).thenReturn(Collections.emptyList());
SimpleTableSegment doctorOneTable = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("doctor1")));
- when(sqlStatementContext.getTablesContext()).thenReturn(new TablesContext(Arrays.asList(doctorTable, doctorOneTable), databaseType, "foo_db"));
+ when(sqlStatementContext.getTablesContext()).thenReturn(new TablesContext(Arrays.asList(doctorTable, doctorOneTable)));
when(sqlStatementContext.getProjectionsContext().getProjections()).thenReturn(Collections.singleton(new ColumnProjection("a", "mobile", null, databaseType)));
Collection<SQLToken> actual = generator.generateSQLTokens(sqlStatementContext);
assertThat(actual.size(), is(1));
@@ -114,7 +114,7 @@ class EncryptProjectionTokenGeneratorTest {
when(sqlStatementContext.getSqlStatement().getProjections()).thenReturn(projections);
when(sqlStatementContext.getSubqueryContexts().values()).thenReturn(Collections.emptyList());
SimpleTableSegment sameDoctorTable = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("doctor")));
- when(sqlStatementContext.getTablesContext()).thenReturn(new TablesContext(Arrays.asList(doctorTable, sameDoctorTable), databaseType, "foo_db"));
+ when(sqlStatementContext.getTablesContext()).thenReturn(new TablesContext(Arrays.asList(doctorTable, sameDoctorTable)));
when(sqlStatementContext.getProjectionsContext().getProjections()).thenReturn(Collections.singleton(new ColumnProjection("a", "mobile", null, databaseType)));
Collection<SQLToken> actual = generator.generateSQLTokens(sqlStatementContext);
assertThat(actual.size(), is(1));
@@ -133,7 +133,7 @@ class EncryptProjectionTokenGeneratorTest {
when(sqlStatementContext.getSubqueryContexts().values()).thenReturn(Collections.emptyList());
SimpleTableSegment doctorTable = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("doctor")));
SimpleTableSegment doctorOneTable = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("doctor1")));
- when(sqlStatementContext.getTablesContext()).thenReturn(new TablesContext(Arrays.asList(doctorTable, doctorOneTable), databaseType, "foo_db"));
+ when(sqlStatementContext.getTablesContext()).thenReturn(new TablesContext(Arrays.asList(doctorTable, doctorOneTable)));
when(sqlStatementContext.getProjectionsContext().getProjections()).thenReturn(Collections.singleton(new ColumnProjection("doctor", "mobile", null, databaseType)));
Collection<SQLToken> actual = generator.generateSQLTokens(sqlStatementContext);
assertThat(actual.size(), is(1));
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/select/EncryptGroupByItemTokenGeneratorTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/select/EncryptGroupByItemTokenGeneratorTest.java
index c503669a7be..add57075398 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/select/EncryptGroupByItemTokenGeneratorTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/select/EncryptGroupByItemTokenGeneratorTest.java
@@ -86,7 +86,7 @@ class EncryptGroupByItemTokenGeneratorTest {
OrderByItem orderByItem = new OrderByItem(columnOrderByItemSegment);
when(result.getGroupByContext().getItems()).thenReturn(Collections.singleton(orderByItem));
when(result.getSubqueryContexts().values()).thenReturn(Collections.emptyList());
- when(result.getTablesContext()).thenReturn(new TablesContext(Collections.singleton(simpleTableSegment), databaseType, "foo_db"));
+ when(result.getTablesContext()).thenReturn(new TablesContext(Collections.singleton(simpleTableSegment)));
return result;
}
}
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/ShadowDMLStatementDataSourceMappingsRetriever.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/ShadowDMLStatementDataSourceMappingsRetriever.java
index bc711bb832e..85e20e1b0c8 100644
--- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/ShadowDMLStatementDataSourceMappingsRetriever.java
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/ShadowDMLStatementDataSourceMappingsRetriever.java
@@ -43,14 +43,14 @@ import java.util.Map;
@HighFrequencyInvocation
public final class ShadowDMLStatementDataSourceMappingsRetriever implements ShadowDataSourceMappingsRetriever {
- private final Map<String, String> tableAliasNameMap;
+ private final Collection<String> tableNames;
private final ShadowTableHintDataSourceMappingsRetriever tableHintDataSourceMappingsRetriever;
private final ShadowColumnDataSourceMappingsRetriever shadowColumnDataSourceMappingsRetriever;
public ShadowDMLStatementDataSourceMappingsRetriever(final QueryContext queryContext, final ShadowOperationType operationType) {
- tableAliasNameMap = ((TableAvailable) queryContext.getSqlStatementContext()).getTablesContext().getTableAliasNameMap();
+ tableNames = ((TableAvailable) queryContext.getSqlStatementContext()).getTablesContext().getTableNames();
tableHintDataSourceMappingsRetriever = new ShadowTableHintDataSourceMappingsRetriever(operationType, queryContext.getHintValueContext().isShadow());
shadowColumnDataSourceMappingsRetriever = createShadowDataSourceMappingsRetriever(queryContext);
}
@@ -73,7 +73,7 @@ public final class ShadowDMLStatementDataSourceMappingsRetriever implements Shad
@Override
public Map<String, String> retrieve(final ShadowRule rule) {
- Collection<String> shadowTables = rule.filterShadowTables(tableAliasNameMap.values());
+ Collection<String> shadowTables = rule.filterShadowTables(tableNames);
Map<String, String> result = tableHintDataSourceMappingsRetriever.retrieve(rule, shadowTables);
return result.isEmpty() && null != shadowColumnDataSourceMappingsRetriever ? shadowColumnDataSourceMappingsRetriever.retrieve(rule, shadowTables) : result;
}
diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/table/column/impl/ShadowSelectStatementDataSourceMappingsRetriever.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/table/column/impl/ShadowSelectStatementDataSourceMappingsRetriever.java
index 1eed56d03ee..aaefa816fd5 100644
--- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/table/column/impl/ShadowSelectStatementDataSourceMappingsRetriever.java
+++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/table/column/impl/ShadowSelectStatementDataSourceMappingsRetriever.java
@@ -23,18 +23,16 @@ import org.apache.shardingsphere.shadow.condition.ShadowColumnCondition;
import org.apache.shardingsphere.shadow.route.retriever.dml.table.column.ShadowColumnDataSourceMappingsRetriever;
import org.apache.shardingsphere.shadow.route.util.ShadowExtractor;
import org.apache.shardingsphere.shadow.spi.ShadowOperationType;
+import org.apache.shardingsphere.sql.parser.statement.core.extractor.ColumnExtractor;
+import org.apache.shardingsphere.sql.parser.statement.core.extractor.ExpressionExtractor;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.column.ColumnSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.ExpressionSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.predicate.AndPredicate;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.predicate.WhereSegment;
-import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.OwnerSegment;
-import org.apache.shardingsphere.sql.parser.statement.core.extractor.ColumnExtractor;
-import org.apache.shardingsphere.sql.parser.statement.core.extractor.ExpressionExtractor;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
-import java.util.Optional;
/**
* Shadow select statement data source mappings retriever.
@@ -60,7 +58,8 @@ public final class ShadowSelectStatementDataSourceMappingsRetriever extends Shad
if (1 != columns.size()) {
continue;
}
- ShadowExtractor.extractValues(each, parameters).map(values -> new ShadowColumnCondition(getOwnerTableName(columns.iterator().next()), shadowColumnName, values)).ifPresent(result::add);
+ ShadowExtractor.extractValues(each, parameters).map(values -> new ShadowColumnCondition(
+ columns.iterator().next().getColumnBoundInfo().getOriginalTable().getValue(), shadowColumnName, values)).ifPresent(result::add);
}
return result;
}
@@ -74,11 +73,4 @@ public final class ShadowSelectStatementDataSourceMappingsRetriever extends Shad
}
return result;
}
-
- private String getOwnerTableName(final ColumnSegment columnSegment) {
- Optional<OwnerSegment> owner = columnSegment.getOwner();
- return owner.isPresent()
- ? sqlStatementContext.getTablesContext().getTableAliasNameMap().get(owner.get().getIdentifier().getValue())
- : sqlStatementContext.getTablesContext().getTableNames().iterator().next();
- }
}
diff --git a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/dml/table/column/impl/ShadowSelectStatementDataSourceMappingsRetrieverTest.java b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/dml/table/column/impl/ShadowSelectStatementDataSourceMappingsRetrieverTest.java
index f66278379d7..f4b34481b35 100644
--- a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/dml/table/column/impl/ShadowSelectStatementDataSourceMappingsRetrieverTest.java
+++ b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/dml/table/column/impl/ShadowSelectStatementDataSourceMappingsRetrieverTest.java
@@ -20,11 +20,12 @@ package org.apache.shardingsphere.shadow.route.retriever.dml.table.column.impl;
import org.apache.shardingsphere.infra.binder.context.statement.dml.SelectStatementContext;
import org.apache.shardingsphere.shadow.condition.ShadowColumnCondition;
import org.apache.shardingsphere.shadow.route.util.ShadowExtractor;
+import org.apache.shardingsphere.sql.parser.statement.core.extractor.ColumnExtractor;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.column.ColumnSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.ExpressionSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.predicate.WhereSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.OwnerSegment;
-import org.apache.shardingsphere.sql.parser.statement.core.extractor.ColumnExtractor;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue;
import org.apache.shardingsphere.test.mock.AutoMockExtension;
import org.apache.shardingsphere.test.mock.StaticMockSettings;
@@ -36,7 +37,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Optional;
-import static org.apache.shardingsphere.test.matcher.ShardingSphereAssertionMatchers.deepEqual;
+import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -53,16 +54,22 @@ class ShadowSelectStatementDataSourceMappingsRetrieverTest {
ExpressionSegment expressionSegment = mock(ExpressionSegment.class);
when(whereSegment.getExpr()).thenReturn(expressionSegment);
when(sqlStatementContext.getWhereSegments()).thenReturn(Arrays.asList(whereSegment, mock(WhereSegment.class, RETURNS_DEEP_STUBS)));
- ColumnSegment columnSegment = mock(ColumnSegment.class);
- when(columnSegment.getOwner()).thenReturn(Optional.of(new OwnerSegment(0, 0, new IdentifierValue("foo"))));
+ ColumnSegment columnSegment = mock(ColumnSegment.class, RETURNS_DEEP_STUBS);
+ when(columnSegment.getColumnBoundInfo().getOriginalTable().getValue()).thenReturn("foo_tbl");
+ OwnerSegment ownerSegment = new OwnerSegment(0, 0, new IdentifierValue("foo"));
+ ownerSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ when(columnSegment.getOwner()).thenReturn(Optional.of(ownerSegment));
when(ColumnExtractor.extract(expressionSegment)).thenReturn(Collections.singleton(columnSegment));
when(ShadowExtractor.extractValues(expressionSegment, Collections.singletonList("foo"))).thenReturn(Optional.of(Collections.singleton("foo")));
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singleton("foo_tbl"));
- when(sqlStatementContext.getTablesContext().getTableAliasNameMap().get("foo")).thenReturn("foo_tbl");
ShadowSelectStatementDataSourceMappingsRetriever retriever = new ShadowSelectStatementDataSourceMappingsRetriever(sqlStatementContext, Collections.singletonList("foo"));
Collection<ShadowColumnCondition> actual = retriever.getShadowColumnConditions("foo_col");
- Collection<ShadowColumnCondition> expected = Collections.singletonList(new ShadowColumnCondition("foo_tbl", "foo_col", Collections.singleton("foo")));
- assertThat(actual, deepEqual(expected));
+ assertThat(actual.size(), is(1));
+ ShadowColumnCondition actualCondition = actual.iterator().next();
+ assertThat(actualCondition.getTable(), is("foo_tbl"));
+ assertThat(actualCondition.getColumn(), is("foo_col"));
+ assertThat(actualCondition.getValues(), is(Collections.singleton("foo")));
+
}
@Test
@@ -72,14 +79,18 @@ class ShadowSelectStatementDataSourceMappingsRetrieverTest {
ExpressionSegment expressionSegment = mock(ExpressionSegment.class);
when(whereSegment.getExpr()).thenReturn(expressionSegment);
when(sqlStatementContext.getWhereSegments()).thenReturn(Arrays.asList(whereSegment, mock(WhereSegment.class, RETURNS_DEEP_STUBS)));
- ColumnSegment columnSegment = mock(ColumnSegment.class);
+ ColumnSegment columnSegment = mock(ColumnSegment.class, RETURNS_DEEP_STUBS);
+ when(columnSegment.getColumnBoundInfo().getOriginalTable().getValue()).thenReturn("foo_tbl");
when(columnSegment.getOwner()).thenReturn(Optional.empty());
when(ColumnExtractor.extract(expressionSegment)).thenReturn(Collections.singleton(columnSegment));
when(ShadowExtractor.extractValues(expressionSegment, Collections.singletonList("foo"))).thenReturn(Optional.of(Collections.singleton("foo")));
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singleton("foo_tbl"));
ShadowSelectStatementDataSourceMappingsRetriever retriever = new ShadowSelectStatementDataSourceMappingsRetriever(sqlStatementContext, Collections.singletonList("foo"));
Collection<ShadowColumnCondition> actual = retriever.getShadowColumnConditions("foo_col");
- Collection<ShadowColumnCondition> expected = Collections.singletonList(new ShadowColumnCondition("foo_tbl", "foo_col", Collections.singleton("foo")));
- assertThat(actual, deepEqual(expected));
+ assertThat(actual.size(), is(1));
+ ShadowColumnCondition actualCondition = actual.iterator().next();
+ assertThat(actualCondition.getTable(), is("foo_tbl"));
+ assertThat(actualCondition.getColumn(), is("foo_col"));
+ assertThat(actualCondition.getValues(), is(Collections.singleton("foo")));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterIndexSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterIndexSupportedCheckerTest.java
index 897a46822ec..0c17547c6c5 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterIndexSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterIndexSupportedCheckerTest.java
@@ -60,7 +60,7 @@ class ShardingAlterIndexSupportedCheckerTest {
when(schema.getAllTables()).thenReturn(Collections.singleton(table));
when(table.containsIndex("t_order_index")).thenReturn(true);
when(table.containsIndex("t_order_index_new")).thenReturn(false);
- assertDoesNotThrow(() -> new ShardingAlterIndexSupportedChecker().check(rule, database, schema, new AlterIndexStatementContext(sqlStatement, "foo_db")));
+ assertDoesNotThrow(() -> new ShardingAlterIndexSupportedChecker().check(rule, database, schema, new AlterIndexStatementContext(sqlStatement)));
}
@Test
@@ -70,7 +70,7 @@ class ShardingAlterIndexSupportedCheckerTest {
sqlStatement.setRenameIndex(new IndexSegment(0, 0, new IndexNameSegment(0, 0, new IdentifierValue("t_order_index_new"))));
ShardingSphereTable table = mock(ShardingSphereTable.class);
when(database.getSchema("public").getTable("t_order")).thenReturn(table);
- assertThrows(IndexNotFoundException.class, () -> new ShardingAlterIndexSupportedChecker().check(rule, database, mock(), new AlterIndexStatementContext(sqlStatement, "foo_db")));
+ assertThrows(IndexNotFoundException.class, () -> new ShardingAlterIndexSupportedChecker().check(rule, database, mock(), new AlterIndexStatementContext(sqlStatement)));
}
@Test
@@ -84,6 +84,6 @@ class ShardingAlterIndexSupportedCheckerTest {
when(table.containsIndex("t_order_index")).thenReturn(true);
when(table.containsIndex("t_order_index_new")).thenReturn(true);
assertThrows(DuplicateIndexException.class,
- () -> new ShardingAlterIndexSupportedChecker().check(rule, database, schema, new AlterIndexStatementContext(sqlStatement, "foo_db")));
+ () -> new ShardingAlterIndexSupportedChecker().check(rule, database, schema, new AlterIndexStatementContext(sqlStatement)));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterTableSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterTableSupportedCheckerTest.java
index 0ed445f918c..7fbb8d35888 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterTableSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterTableSupportedCheckerTest.java
@@ -51,7 +51,7 @@ class ShardingAlterTableSupportedCheckerTest {
PostgreSQLAlterTableStatement sqlStatement = new PostgreSQLAlterTableStatement();
sqlStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order"))));
sqlStatement.setRenameTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order_new"))));
- AlterTableStatementContext sqlStatementContext = new AlterTableStatementContext(sqlStatement, "foo_db");
+ AlterTableStatementContext sqlStatementContext = new AlterTableStatementContext(sqlStatement);
when(rule.containsShardingTable(Arrays.asList("t_order", "t_order_new"))).thenReturn(true);
assertThrows(UnsupportedShardingOperationException.class, () -> new ShardingAlterTableSupportedChecker().check(rule, database, mock(), sqlStatementContext));
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterViewSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterViewSupportedCheckerTest.java
index 0b7c2ce56b7..1acaea3299c 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterViewSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterViewSupportedCheckerTest.java
@@ -49,7 +49,7 @@ class ShardingAlterViewSupportedCheckerTest {
MySQLAlterViewStatement sqlStatement = new MySQLAlterViewStatement();
sqlStatement.setView(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order_view"))));
sqlStatement.setSelect(selectStatement);
- AlterViewStatementContext sqlStatementContext = new AlterViewStatementContext(sqlStatement, "foo_db");
+ AlterViewStatementContext sqlStatementContext = new AlterViewStatementContext(sqlStatement);
when(rule.isShardingTable("t_order")).thenReturn(false);
assertDoesNotThrow(() -> new ShardingAlterViewSupportedChecker().check(rule, mock(), mock(), sqlStatementContext));
}
@@ -61,7 +61,7 @@ class ShardingAlterViewSupportedCheckerTest {
MySQLAlterViewStatement sqlStatement = new MySQLAlterViewStatement();
sqlStatement.setView(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order_view"))));
sqlStatement.setSelect(selectStatement);
- AlterViewStatementContext sqlStatementContext = new AlterViewStatementContext(sqlStatement, "foo_db");
+ AlterViewStatementContext sqlStatementContext = new AlterViewStatementContext(sqlStatement);
when(rule.isShardingTable("t_order")).thenReturn(true);
assertThrows(EngagedViewException.class, () -> new ShardingAlterViewSupportedChecker().check(rule, mock(), mock(), sqlStatementContext));
}
@@ -71,7 +71,7 @@ class ShardingAlterViewSupportedCheckerTest {
OpenGaussAlterViewStatement sqlStatement = new OpenGaussAlterViewStatement();
sqlStatement.setView(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order_view"))));
sqlStatement.setRenameView(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order_new"))));
- AlterViewStatementContext sqlStatementContext = new AlterViewStatementContext(sqlStatement, "foo_db");
+ AlterViewStatementContext sqlStatementContext = new AlterViewStatementContext(sqlStatement);
assertDoesNotThrow(() -> new ShardingAlterViewSupportedChecker().check(rule, mock(), mock(), sqlStatementContext));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateFunctionSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateFunctionSupportedCheckerTest.java
index c37805b4346..517500fbdae 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateFunctionSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateFunctionSupportedCheckerTest.java
@@ -64,7 +64,7 @@ class ShardingCreateFunctionSupportedCheckerTest {
routineBody.getValidStatements().add(selectValidStatementSegment);
MySQLCreateFunctionStatement sqlStatement = new MySQLCreateFunctionStatement();
sqlStatement.setRoutineBody(routineBody);
- CreateFunctionStatementContext sqlStatementContext = new CreateFunctionStatementContext(sqlStatement, "foo_db");
+ CreateFunctionStatementContext sqlStatementContext = new CreateFunctionStatementContext(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class);
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable("t_order_item")).thenReturn(true);
@@ -81,7 +81,7 @@ class ShardingCreateFunctionSupportedCheckerTest {
routineBody.getValidStatements().add(validStatementSegment);
MySQLCreateFunctionStatement sqlStatement = new MySQLCreateFunctionStatement();
sqlStatement.setRoutineBody(routineBody);
- CreateFunctionStatementContext sqlStatementContext = new CreateFunctionStatementContext(sqlStatement, "foo_db");
+ CreateFunctionStatementContext sqlStatementContext = new CreateFunctionStatementContext(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(rule.isShardingTable("t_order")).thenReturn(true);
assertThrows(UnsupportedShardingOperationException.class, () -> new ShardingCreateFunctionSupportedChecker().check(rule, database, mock(), sqlStatementContext));
@@ -97,7 +97,7 @@ class ShardingCreateFunctionSupportedCheckerTest {
routineBody.getValidStatements().add(validStatementSegment);
MySQLCreateFunctionStatement sqlStatement = new MySQLCreateFunctionStatement();
sqlStatement.setRoutineBody(routineBody);
- CreateFunctionStatementContext sqlStatementContext = new CreateFunctionStatementContext(sqlStatement, "foo_db");
+ CreateFunctionStatementContext sqlStatementContext = new CreateFunctionStatementContext(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
assertThrows(NoSuchTableException.class, () -> new ShardingCreateFunctionSupportedChecker().check(rule, database, mock(), sqlStatementContext));
}
@@ -112,7 +112,7 @@ class ShardingCreateFunctionSupportedCheckerTest {
routineBody.getValidStatements().add(validStatementSegment);
MySQLCreateFunctionStatement sqlStatement = new MySQLCreateFunctionStatement();
sqlStatement.setRoutineBody(routineBody);
- CreateFunctionStatementContext sqlStatementContext = new CreateFunctionStatementContext(sqlStatement, "foo_db");
+ CreateFunctionStatementContext sqlStatementContext = new CreateFunctionStatementContext(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable("t_order")).thenReturn(true);
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateIndexSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateIndexSupportedCheckerTest.java
index 3f115e5e965..1fedc80468e 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateIndexSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateIndexSupportedCheckerTest.java
@@ -57,7 +57,7 @@ class ShardingCreateIndexSupportedCheckerTest {
sqlStatement.setIndex(new IndexSegment(0, 0, new IndexNameSegment(0, 0, new IdentifierValue("t_order_index"))));
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable("t_order")).thenReturn(true);
- assertDoesNotThrow(() -> new ShardingCreateIndexSupportedChecker().check(rule, database, schema, new CreateIndexStatementContext(sqlStatement, "foo_db")));
+ assertDoesNotThrow(() -> new ShardingCreateIndexSupportedChecker().check(rule, database, schema, new CreateIndexStatementContext(sqlStatement)));
}
@Test
@@ -67,7 +67,7 @@ class ShardingCreateIndexSupportedCheckerTest {
sqlStatement.setIndex(new IndexSegment(0, 0, new IndexNameSegment(0, 0, new IdentifierValue("t_order_index"))));
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable("t_order")).thenReturn(false);
- assertThrows(NoSuchTableException.class, () -> new ShardingCreateIndexSupportedChecker().check(rule, database, schema, new CreateIndexStatementContext(sqlStatement, "foo_db")));
+ assertThrows(NoSuchTableException.class, () -> new ShardingCreateIndexSupportedChecker().check(rule, database, schema, new CreateIndexStatementContext(sqlStatement)));
}
@Test
@@ -78,7 +78,7 @@ class ShardingCreateIndexSupportedCheckerTest {
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable("t_order")).thenReturn(true);
when(schema.containsIndex("t_order", "t_order_index")).thenReturn(true);
- assertThrows(DuplicateIndexException.class, () -> new ShardingCreateIndexSupportedChecker().check(rule, database, schema, new CreateIndexStatementContext(sqlStatement, "foo_db")));
+ assertThrows(DuplicateIndexException.class, () -> new ShardingCreateIndexSupportedChecker().check(rule, database, schema, new CreateIndexStatementContext(sqlStatement)));
}
@Test
@@ -89,7 +89,7 @@ class ShardingCreateIndexSupportedCheckerTest {
sqlStatement.setGeneratedIndexStartIndex(10);
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable("t_order")).thenReturn(true);
- assertDoesNotThrow(() -> new ShardingCreateIndexSupportedChecker().check(rule, database, schema, new CreateIndexStatementContext(sqlStatement, "foo_db")));
+ assertDoesNotThrow(() -> new ShardingCreateIndexSupportedChecker().check(rule, database, schema, new CreateIndexStatementContext(sqlStatement)));
}
@Test
@@ -100,7 +100,7 @@ class ShardingCreateIndexSupportedCheckerTest {
sqlStatement.setGeneratedIndexStartIndex(10);
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable("t_order")).thenReturn(false);
- assertThrows(NoSuchTableException.class, () -> new ShardingCreateIndexSupportedChecker().check(rule, database, schema, new CreateIndexStatementContext(sqlStatement, "foo_db")));
+ assertThrows(NoSuchTableException.class, () -> new ShardingCreateIndexSupportedChecker().check(rule, database, schema, new CreateIndexStatementContext(sqlStatement)));
}
@Test
@@ -112,6 +112,6 @@ class ShardingCreateIndexSupportedCheckerTest {
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable("t_order")).thenReturn(true);
when(schema.containsIndex("t_order", "content_idx")).thenReturn(true);
- assertThrows(DuplicateIndexException.class, () -> new ShardingCreateIndexSupportedChecker().check(rule, database, schema, new CreateIndexStatementContext(sqlStatement, "foo_db")));
+ assertThrows(DuplicateIndexException.class, () -> new ShardingCreateIndexSupportedChecker().check(rule, database, schema, new CreateIndexStatementContext(sqlStatement)));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateProcedureSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateProcedureSupportedCheckerTest.java
index 48b55eaa30b..e48488ffe94 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateProcedureSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateProcedureSupportedCheckerTest.java
@@ -68,7 +68,7 @@ class ShardingCreateProcedureSupportedCheckerTest {
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable("t_order_item")).thenReturn(true);
when(rule.isShardingTable("t_order_item")).thenReturn(false);
- CreateProcedureStatementContext sqlStatementContext = new CreateProcedureStatementContext(sqlStatement, "foo_db");
+ CreateProcedureStatementContext sqlStatementContext = new CreateProcedureStatementContext(sqlStatement);
assertDoesNotThrow(() -> new ShardingCreateProcedureSupportedChecker().check(rule, database, schema, sqlStatementContext));
}
@@ -82,7 +82,7 @@ class ShardingCreateProcedureSupportedCheckerTest {
routineBody.getValidStatements().add(validStatementSegment);
MySQLCreateProcedureStatement sqlStatement = new MySQLCreateProcedureStatement();
sqlStatement.setRoutineBody(routineBody);
- CreateProcedureStatementContext sqlStatementContext = new CreateProcedureStatementContext(sqlStatement, "foo_db");
+ CreateProcedureStatementContext sqlStatementContext = new CreateProcedureStatementContext(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
when(rule.isShardingTable("t_order")).thenReturn(true);
assertThrows(UnsupportedShardingOperationException.class, () -> new ShardingCreateProcedureSupportedChecker().check(rule, database, mock(), sqlStatementContext));
@@ -98,7 +98,7 @@ class ShardingCreateProcedureSupportedCheckerTest {
routineBody.getValidStatements().add(validStatementSegment);
MySQLCreateProcedureStatement sqlStatement = new MySQLCreateProcedureStatement();
sqlStatement.setRoutineBody(routineBody);
- CreateProcedureStatementContext sqlStatementContext = new CreateProcedureStatementContext(sqlStatement, "foo_db");
+ CreateProcedureStatementContext sqlStatementContext = new CreateProcedureStatementContext(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
assertThrows(NoSuchTableException.class, () -> new ShardingCreateProcedureSupportedChecker().check(rule, database, mock(), sqlStatementContext));
}
@@ -113,7 +113,7 @@ class ShardingCreateProcedureSupportedCheckerTest {
routineBody.getValidStatements().add(validStatementSegment);
MySQLCreateProcedureStatement sqlStatement = new MySQLCreateProcedureStatement();
sqlStatement.setRoutineBody(routineBody);
- CreateProcedureStatementContext sqlStatementContext = new CreateProcedureStatementContext(sqlStatement, "foo_db");
+ CreateProcedureStatementContext sqlStatementContext = new CreateProcedureStatementContext(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable("t_order")).thenReturn(true);
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateTableSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateTableSupportedCheckerTest.java
index 539c40418be..6231def6742 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateTableSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateTableSupportedCheckerTest.java
@@ -83,7 +83,7 @@ class ShardingCreateTableSupportedCheckerTest {
}
private void assertCheck(final CreateTableStatement sqlStatement) {
- CreateTableStatementContext sqlStatementContext = new CreateTableStatementContext(sqlStatement, "sharding_db");
+ CreateTableStatementContext sqlStatementContext = new CreateTableStatementContext(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable("t_order")).thenReturn(true);
@@ -105,7 +105,7 @@ class ShardingCreateTableSupportedCheckerTest {
}
private void assertCheckIfNotExists(final CreateTableStatement sqlStatement) {
- CreateTableStatementContext sqlStatementContext = new CreateTableStatementContext(sqlStatement, "foo_db");
+ CreateTableStatementContext sqlStatementContext = new CreateTableStatementContext(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
new ShardingCreateTableSupportedChecker().check(rule, database, mock(), sqlStatementContext);
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropIndexSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropIndexSupportedCheckerTest.java
index c6784dd59e7..3ae4f537141 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropIndexSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropIndexSupportedCheckerTest.java
@@ -59,7 +59,7 @@ class ShardingDropIndexSupportedCheckerTest {
when(schema.getAllTables()).thenReturn(Collections.singleton(table));
when(table.containsIndex("t_order_index")).thenReturn(true);
when(table.containsIndex("t_order_index_new")).thenReturn(true);
- assertDoesNotThrow(() -> new ShardingDropIndexSupportedChecker().check(rule, database, schema, new DropIndexStatementContext(sqlStatement, "foo_db")));
+ assertDoesNotThrow(() -> new ShardingDropIndexSupportedChecker().check(rule, database, schema, new DropIndexStatementContext(sqlStatement)));
}
@Test
@@ -70,6 +70,6 @@ class ShardingDropIndexSupportedCheckerTest {
ShardingSphereTable table = mock(ShardingSphereTable.class);
when(database.getSchema("public").getAllTables()).thenReturn(Collections.singleton(table));
when(database.getSchema("public").getTable("t_order")).thenReturn(table);
- assertThrows(IndexNotFoundException.class, () -> new ShardingDropIndexSupportedChecker().check(rule, database, mock(), new DropIndexStatementContext(sqlStatement, "foo_db")));
+ assertThrows(IndexNotFoundException.class, () -> new ShardingDropIndexSupportedChecker().check(rule, database, mock(), new DropIndexStatementContext(sqlStatement)));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropTableSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropTableSupportedCheckerTest.java
index 38489b6b6df..5223b63b374 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropTableSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropTableSupportedCheckerTest.java
@@ -64,7 +64,7 @@ class ShardingDropTableSupportedCheckerTest {
void assertCheckForMySQL() {
MySQLDropTableStatement sqlStatement = new MySQLDropTableStatement(false);
sqlStatement.getTables().add(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order_item"))));
- DropTableStatementContext sqlStatementContext = new DropTableStatementContext(sqlStatement, "db_schema");
+ DropTableStatementContext sqlStatementContext = new DropTableStatementContext(sqlStatement);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable("t_order_item")).thenReturn(true);
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingInsertSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingInsertSupportedCheckerTest.java
index 52fce0fd430..da9a6cebc88 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingInsertSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingInsertSupportedCheckerTest.java
@@ -148,13 +148,13 @@ class ShardingInsertSupportedCheckerTest {
private TablesContext createSingleTablesContext() {
List<SimpleTableSegment> result = new LinkedList<>();
result.add(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("user"))));
- return new TablesContext(result, databaseType, "foo_db");
+ return new TablesContext(result);
}
private TablesContext createMultiTablesContext() {
List<SimpleTableSegment> result = new LinkedList<>();
result.add(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("user"))));
result.add(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("order"))));
- return new TablesContext(result, databaseType, "foo_db");
+ return new TablesContext(result);
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingRenameTableSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingRenameTableSupportedCheckerTest.java
index d4aaae3d616..9b8000cfb05 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingRenameTableSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingRenameTableSupportedCheckerTest.java
@@ -61,6 +61,6 @@ class ShardingRenameTableSupportedCheckerTest {
renameTableDefinitionSegment.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue(originTableName))));
renameTableDefinitionSegment.setRenameTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue(newTableName))));
sqlStatement.getRenameTables().add(renameTableDefinitionSegment);
- return new RenameTableStatementContext(sqlStatement, "foo_db");
+ return new RenameTableStatementContext(sqlStatement);
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingCopySupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingCopySupportedCheckerTest.java
index 271eed7fd04..9b15a14b9f5 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingCopySupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingCopySupportedCheckerTest.java
@@ -46,14 +46,14 @@ class ShardingCopySupportedCheckerTest {
void assertCheckWhenTableSegmentForPostgreSQL() {
PostgreSQLCopyStatement sqlStatement = new PostgreSQLCopyStatement();
sqlStatement.setTableSegment(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order"))));
- assertDoesNotThrow(() -> new ShardingCopySupportedChecker().check(rule, mock(), mock(), new CopyStatementContext(sqlStatement, "foo_db")));
+ assertDoesNotThrow(() -> new ShardingCopySupportedChecker().check(rule, mock(), mock(), new CopyStatementContext(sqlStatement)));
}
@Test
void assertCheckWhenTableSegmentForOpenGauss() {
OpenGaussCopyStatement sqlStatement = new OpenGaussCopyStatement();
sqlStatement.setTableSegment(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order"))));
- assertDoesNotThrow(() -> new ShardingCopySupportedChecker().check(rule, mock(), mock(), new CopyStatementContext(sqlStatement, "foo_db")));
+ assertDoesNotThrow(() -> new ShardingCopySupportedChecker().check(rule, mock(), mock(), new CopyStatementContext(sqlStatement)));
}
@Test
@@ -68,7 +68,7 @@ class ShardingCopySupportedCheckerTest {
private void assertCheckCopyTable(final CopyStatement sqlStatement) {
sqlStatement.setTableSegment(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order"))));
- CopyStatementContext sqlStatementContext = new CopyStatementContext(sqlStatement, "foo_db");
+ CopyStatementContext sqlStatementContext = new CopyStatementContext(sqlStatement);
String tableName = "t_order";
when(rule.isShardingTable(tableName)).thenReturn(true);
new ShardingCopySupportedChecker().check(rule, mock(), mock(), sqlStatementContext);
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingDeleteSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingDeleteSupportedCheckerTest.java
index 7644a8f4109..7af8a2b3de8 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingDeleteSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingDeleteSupportedCheckerTest.java
@@ -83,7 +83,7 @@ class ShardingDeleteSupportedCheckerTest {
Collection<String> tableNames = new HashSet<>(Arrays.asList("user", "order", "order_item"));
when(rule.isAllShardingTables(tableNames)).thenReturn(false);
when(rule.containsShardingTable(tableNames)).thenReturn(true);
- DeleteStatementContext sqlStatementContext = new DeleteStatementContext(sqlStatement, "foo_db");
+ DeleteStatementContext sqlStatementContext = new DeleteStatementContext(sqlStatement);
new ShardingDeleteSupportedChecker().check(rule, mock(), mock(), sqlStatementContext);
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingLoadDataSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingLoadDataSupportedCheckerTest.java
index 9cda9b65822..37c8bfd91fb 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingLoadDataSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingLoadDataSupportedCheckerTest.java
@@ -43,13 +43,13 @@ class ShardingLoadDataSupportedCheckerTest {
@Test
void assertCheckWithSingleTable() {
MySQLLoadDataStatement sqlStatement = new MySQLLoadDataStatement(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order"))));
- assertDoesNotThrow(() -> new ShardingLoadDataSupportedChecker().check(rule, mock(), mock(), new LoadDataStatementContext(sqlStatement, "foo_db")));
+ assertDoesNotThrow(() -> new ShardingLoadDataSupportedChecker().check(rule, mock(), mock(), new LoadDataStatementContext(sqlStatement)));
}
@Test
void assertCheckWithShardingTable() {
MySQLLoadDataStatement sqlStatement = new MySQLLoadDataStatement(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order"))));
when(rule.isShardingTable("t_order")).thenReturn(true);
- assertThrows(UnsupportedShardingOperationException.class, () -> new ShardingLoadDataSupportedChecker().check(rule, mock(), mock(), new LoadDataStatementContext(sqlStatement, "foo_db")));
+ assertThrows(UnsupportedShardingOperationException.class, () -> new ShardingLoadDataSupportedChecker().check(rule, mock(), mock(), new LoadDataStatementContext(sqlStatement)));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingLoadXmlSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingLoadXmlSupportedCheckerTest.java
index 718e3787a31..0538a83d478 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingLoadXmlSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingLoadXmlSupportedCheckerTest.java
@@ -43,13 +43,13 @@ class ShardingLoadXmlSupportedCheckerTest {
@Test
void assertCheckWithSingleTable() {
MySQLLoadXMLStatement sqlStatement = new MySQLLoadXMLStatement(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order"))));
- assertDoesNotThrow(() -> new ShardingLoadXmlSupportedChecker().check(rule, mock(), mock(), new LoadXMLStatementContext(sqlStatement, "foo_db")));
+ assertDoesNotThrow(() -> new ShardingLoadXmlSupportedChecker().check(rule, mock(), mock(), new LoadXMLStatementContext(sqlStatement)));
}
@Test
void assertCheckWithShardingTable() {
MySQLLoadXMLStatement sqlStatement = new MySQLLoadXMLStatement(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order"))));
when(rule.isShardingTable("t_order")).thenReturn(true);
- assertThrows(UnsupportedShardingOperationException.class, () -> new ShardingLoadXmlSupportedChecker().check(rule, mock(), mock(), new LoadXMLStatementContext(sqlStatement, "foo_db")));
+ assertThrows(UnsupportedShardingOperationException.class, () -> new ShardingLoadXmlSupportedChecker().check(rule, mock(), mock(), new LoadXMLStatementContext(sqlStatement)));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingUpdateSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingUpdateSupportedCheckerTest.java
index 867ebf0f93d..d49c5da1e35 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingUpdateSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingUpdateSupportedCheckerTest.java
@@ -55,7 +55,7 @@ class ShardingUpdateSupportedCheckerTest {
void assertCheckWhenUpdateSingleTable() {
UpdateStatement updateStatement = createUpdateStatement();
updateStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("user"))));
- UpdateStatementContext sqlStatementContext = new UpdateStatementContext(updateStatement, "foo_db");
+ UpdateStatementContext sqlStatementContext = new UpdateStatementContext(updateStatement);
Collection<String> tableNames = sqlStatementContext.getTablesContext().getTableNames();
when(rule.isAllShardingTables(tableNames)).thenReturn(true);
when(rule.containsShardingTable(tableNames)).thenReturn(true);
@@ -69,7 +69,7 @@ class ShardingUpdateSupportedCheckerTest {
joinTableSegment.setLeft(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("user"))));
joinTableSegment.setRight(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("order"))));
updateStatement.setTable(joinTableSegment);
- UpdateStatementContext sqlStatementContext = new UpdateStatementContext(updateStatement, "foo_db");
+ UpdateStatementContext sqlStatementContext = new UpdateStatementContext(updateStatement);
Collection<String> tableNames = sqlStatementContext.getTablesContext().getTableNames();
when(rule.containsShardingTable(tableNames)).thenReturn(true);
assertThrows(DMLWithMultipleShardingTablesException.class, () -> new ShardingUpdateSupportedChecker().check(rule, mock(), mock(), sqlStatementContext));
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/ShardingDDLResultMergerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/ShardingDDLResultMergerTest.java
index b92876ccb3e..8914d07529f 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/ShardingDDLResultMergerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/ShardingDDLResultMergerTest.java
@@ -77,7 +77,7 @@ class ShardingDDLResultMergerTest {
}
private FetchStatementContext createFetchStatementContext(final ShardingSphereDatabase database) {
- FetchStatementContext result = new FetchStatementContext(mockFetchStatement(), "foo_db");
+ FetchStatementContext result = new FetchStatementContext(mockFetchStatement());
result.setCursorStatementContext(createCursorStatementContext(database));
return result;
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/fetch/FetchStreamMergedResultTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/fetch/FetchStreamMergedResultTest.java
index 6bb043a312b..55f0b15ffe1 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/fetch/FetchStreamMergedResultTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/fetch/FetchStreamMergedResultTest.java
@@ -91,7 +91,7 @@ class FetchStreamMergedResultTest {
}
private static FetchStatementContext createFetchStatementContext(final boolean containsAllDirectionType) {
- FetchStatementContext result = new FetchStatementContext(createFetchStatement(containsAllDirectionType), "foo_db");
+ FetchStatementContext result = new FetchStatementContext(createFetchStatement(containsAllDirectionType));
result.setCursorStatementContext(mockCursorStatementContext());
return result;
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingAlterTableRouteContextCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingAlterTableRouteContextCheckerTest.java
index cf04e3fe042..ec44b25c16c 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingAlterTableRouteContextCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingAlterTableRouteContextCheckerTest.java
@@ -72,7 +72,7 @@ class ShardingAlterTableRouteContextCheckerTest {
routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"), Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
routeUnits.add(new RouteUnit(new RouteMapper("ds_1", "ds_1"), Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
- when(queryContext.getSqlStatementContext()).thenReturn(new AlterTableStatementContext(sqlStatement, "foo_db"));
+ when(queryContext.getSqlStatementContext()).thenReturn(new AlterTableStatementContext(sqlStatement));
assertDoesNotThrow(() -> new ShardingAlterTableRouteContextChecker().check(shardingRule, queryContext, database, mock(ConfigurationProperties.class), routeContext));
}
@@ -85,7 +85,7 @@ class ShardingAlterTableRouteContextCheckerTest {
Collection<RouteUnit> routeUnits = new LinkedList<>();
routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"), Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
- when(queryContext.getSqlStatementContext()).thenReturn(new AlterTableStatementContext(sqlStatement, "foo_db"));
+ when(queryContext.getSqlStatementContext()).thenReturn(new AlterTableStatementContext(sqlStatement));
assertThrows(ShardingDDLRouteException.class, () -> new ShardingAlterTableRouteContextChecker().check(shardingRule, queryContext, database, mock(ConfigurationProperties.class), routeContext));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingCreateTableRouteContextCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingCreateTableRouteContextCheckerTest.java
index f848860a00c..e2f568eb205 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingCreateTableRouteContextCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingCreateTableRouteContextCheckerTest.java
@@ -72,7 +72,7 @@ class ShardingCreateTableRouteContextCheckerTest {
routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"), Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
routeUnits.add(new RouteUnit(new RouteMapper("ds_1", "ds_1"), Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
- when(queryContext.getSqlStatementContext()).thenReturn(new CreateTableStatementContext(sqlStatement, "foo_db"));
+ when(queryContext.getSqlStatementContext()).thenReturn(new CreateTableStatementContext(sqlStatement));
assertDoesNotThrow(() -> new ShardingCreateTableRouteContextChecker().check(shardingRule, queryContext, database, mock(ConfigurationProperties.class), routeContext));
}
@@ -85,7 +85,7 @@ class ShardingCreateTableRouteContextCheckerTest {
Collection<RouteUnit> routeUnits = new LinkedList<>();
routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"), Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
- when(queryContext.getSqlStatementContext()).thenReturn(new CreateTableStatementContext(sqlStatement, "foo_db"));
+ when(queryContext.getSqlStatementContext()).thenReturn(new CreateTableStatementContext(sqlStatement));
assertThrows(ShardingDDLRouteException.class,
() -> new ShardingCreateTableRouteContextChecker().check(shardingRule, queryContext, database, mock(ConfigurationProperties.class), routeContext));
}
@@ -94,7 +94,7 @@ class ShardingCreateTableRouteContextCheckerTest {
void assertCheckWithSameRouteResultBroadcastTableForPostgreSQL() {
PostgreSQLCreateTableStatement sqlStatement = new PostgreSQLCreateTableStatement(false);
sqlStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_config"))));
- when(queryContext.getSqlStatementContext()).thenReturn(new CreateTableStatementContext(sqlStatement, "foo_db"));
+ when(queryContext.getSqlStatementContext()).thenReturn(new CreateTableStatementContext(sqlStatement));
assertDoesNotThrow(() -> new ShardingCreateTableRouteContextChecker().check(shardingRule, queryContext, database, mock(ConfigurationProperties.class), routeContext));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropIndexRouteContextCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropIndexRouteContextCheckerTest.java
index 1118626b51e..9d57556c3ee 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropIndexRouteContextCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropIndexRouteContextCheckerTest.java
@@ -79,7 +79,7 @@ class ShardingDropIndexRouteContextCheckerTest {
routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"), Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
routeUnits.add(new RouteUnit(new RouteMapper("ds_1", "ds_1"), Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
- when(queryContext.getSqlStatementContext()).thenReturn(new DropIndexStatementContext(sqlStatement, "foo_db"));
+ when(queryContext.getSqlStatementContext()).thenReturn(new DropIndexStatementContext(sqlStatement));
assertDoesNotThrow(() -> new ShardingDropIndexRouteContextChecker().check(shardingRule, queryContext, database, mock(ConfigurationProperties.class), routeContext));
}
@@ -98,7 +98,7 @@ class ShardingDropIndexRouteContextCheckerTest {
Collection<RouteUnit> routeUnits = new LinkedList<>();
routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"), Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
- when(queryContext.getSqlStatementContext()).thenReturn(new DropIndexStatementContext(sqlStatement, "foo_db"));
+ when(queryContext.getSqlStatementContext()).thenReturn(new DropIndexStatementContext(sqlStatement));
assertThrows(ShardingDDLRouteException.class, () -> new ShardingDropIndexRouteContextChecker().check(shardingRule, queryContext, database, mock(ConfigurationProperties.class), routeContext));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropTableRouteContextCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropTableRouteContextCheckerTest.java
index 68958c4eda4..4a26cb3d8af 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropTableRouteContextCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropTableRouteContextCheckerTest.java
@@ -94,7 +94,7 @@ class ShardingDropTableRouteContextCheckerTest {
routeUnits.add(routeUnit);
RouteContext routeContext = mock(RouteContext.class);
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
- when(queryContext.getSqlStatementContext()).thenReturn(new DropTableStatementContext(sqlStatement, "foo_db"));
+ when(queryContext.getSqlStatementContext()).thenReturn(new DropTableStatementContext(sqlStatement));
assertThrows(InUsedTablesException.class, () -> new ShardingDropTableRouteContextChecker().check(shardingRule, queryContext, database, mock(ConfigurationProperties.class), routeContext));
}
@@ -127,7 +127,7 @@ class ShardingDropTableRouteContextCheckerTest {
routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"), Collections.singleton(new RouteMapper("t_order", "t_order_0"))));
routeUnits.add(new RouteUnit(new RouteMapper("ds_1", "ds_1"), Collections.singleton(new RouteMapper("t_order", "t_order_0"))));
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
- when(queryContext.getSqlStatementContext()).thenReturn(new DropTableStatementContext(sqlStatement, "foo_db"));
+ when(queryContext.getSqlStatementContext()).thenReturn(new DropTableStatementContext(sqlStatement));
assertDoesNotThrow(() -> new ShardingDropTableRouteContextChecker().check(shardingRule, queryContext, mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS),
mock(ConfigurationProperties.class), routeContext));
}
@@ -141,7 +141,7 @@ class ShardingDropTableRouteContextCheckerTest {
Collection<RouteUnit> routeUnits = new LinkedList<>();
routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"), Collections.singleton(new RouteMapper("t_order", "t_order_0"))));
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
- when(queryContext.getSqlStatementContext()).thenReturn(new DropTableStatementContext(sqlStatement, "foo_db"));
+ when(queryContext.getSqlStatementContext()).thenReturn(new DropTableStatementContext(sqlStatement));
assertThrows(ShardingDDLRouteException.class, () -> new ShardingDropTableRouteContextChecker().check(shardingRule, queryContext, mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS),
mock(ConfigurationProperties.class), routeContext));
}
@@ -155,7 +155,7 @@ class ShardingDropTableRouteContextCheckerTest {
routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"), Collections.singleton(new RouteMapper("t_config", "t_config"))));
routeUnits.add(new RouteUnit(new RouteMapper("ds_1", "ds_1"), Collections.singleton(new RouteMapper("t_config", "t_config"))));
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
- when(queryContext.getSqlStatementContext()).thenReturn(new DropTableStatementContext(sqlStatement, "foo_db"));
+ when(queryContext.getSqlStatementContext()).thenReturn(new DropTableStatementContext(sqlStatement));
assertDoesNotThrow(() -> new ShardingDropTableRouteContextChecker().check(shardingRule, queryContext, mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS),
mock(ConfigurationProperties.class), routeContext));
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingRenameTableRouteContextCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingRenameTableRouteContextCheckerTest.java
index 8500bab365c..5be926ffb60 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingRenameTableRouteContextCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingRenameTableRouteContextCheckerTest.java
@@ -91,6 +91,6 @@ class ShardingRenameTableRouteContextCheckerTest {
renameTableDefinitionSegment.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order"))));
renameTableDefinitionSegment.setRenameTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_user_order"))));
sqlStatement.getRenameTables().add(renameTableDefinitionSegment);
- return new RenameTableStatementContext(sqlStatement, "foo_db");
+ return new RenameTableStatementContext(sqlStatement);
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/dml/ShardingUpdateRouteContextCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/dml/ShardingUpdateRouteContextCheckerTest.java
index 9ec657382d8..160e2a99264 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/dml/ShardingUpdateRouteContextCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/dml/ShardingUpdateRouteContextCheckerTest.java
@@ -72,7 +72,7 @@ class ShardingUpdateRouteContextCheckerTest {
@Test
void assertCheckWhenNotUpdateShardingColumn() {
- UpdateStatementContext sqlStatementContext = new UpdateStatementContext(createUpdateStatement(), "foo_db");
+ UpdateStatementContext sqlStatementContext = new UpdateStatementContext(createUpdateStatement());
when(queryContext.getSqlStatementContext()).thenReturn(sqlStatementContext);
assertDoesNotThrow(() -> new ShardingUpdateRouteContextChecker().check(shardingRule, queryContext, database, mock(ConfigurationProperties.class), mock(RouteContext.class)));
}
@@ -80,14 +80,14 @@ class ShardingUpdateRouteContextCheckerTest {
@Test
void assertCheckWhenUpdateShardingColumnWithSameRouteContext() {
mockShardingRuleForUpdateShardingColumn();
- when(queryContext.getSqlStatementContext()).thenReturn(new UpdateStatementContext(createUpdateStatement(), "foo_db"));
+ when(queryContext.getSqlStatementContext()).thenReturn(new UpdateStatementContext(createUpdateStatement()));
assertDoesNotThrow(() -> new ShardingUpdateRouteContextChecker().check(shardingRule, queryContext, database, mock(ConfigurationProperties.class), createSingleRouteContext()));
}
@Test
void assertCheckWhenUpdateShardingColumnWithDifferentRouteContext() {
mockShardingRuleForUpdateShardingColumn();
- when(queryContext.getSqlStatementContext()).thenReturn(new UpdateStatementContext(createUpdateStatement(), "foo_db"));
+ when(queryContext.getSqlStatementContext()).thenReturn(new UpdateStatementContext(createUpdateStatement()));
assertThrows(UnsupportedUpdatingShardingValueException.class,
() -> new ShardingUpdateRouteContextChecker().check(shardingRule, queryContext, database, mock(ConfigurationProperties.class), createFullRouteContext()));
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactoryTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactoryTest.java
index cbbe43c2a27..755d1da8837 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactoryTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactoryTest.java
@@ -160,7 +160,7 @@ class ShardingRouteEngineFactoryTest {
private void assertNewInstanceForDCLForSingleTable(final GrantStatement grantStatement) {
grantStatement.getTables().add(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("tbl"))));
- GrantStatementContext sqlStatementContext = new GrantStatementContext(grantStatement, "foo_db");
+ GrantStatementContext sqlStatementContext = new GrantStatementContext(grantStatement);
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
ShardingRouteEngine actual = ShardingRouteEngineFactory.newInstance(shardingRule, database, queryContext, shardingConditions, Collections.singletonList("tbl"), props);
assertThat(actual, instanceOf(ShardingTableBroadcastRouteEngine.class));
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
index 2ce342a18e8..4d2c328ee12 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
@@ -675,7 +675,7 @@ class ShardingRuleTest {
Collection<SimpleTableSegment> tableSegments = Arrays.asList(
new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("LOGIC_TABLE"))),
new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("SUB_LOGIC_TABLE"))));
- TablesContext tablesContext = new TablesContext(tableSegments, Collections.emptyMap(), databaseType, "foo_db");
+ TablesContext tablesContext = new TablesContext(tableSegments, Collections.emptyMap());
when(sqlStatementContext.getTablesContext()).thenReturn(tablesContext);
when(sqlStatementContext.getDatabaseType()).thenReturn(databaseType);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/segment/table/TablesContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/segment/table/TablesContext.java
index e137bbe16b1..50fb33851a6 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/segment/table/TablesContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/segment/table/TablesContext.java
@@ -27,17 +27,13 @@ import org.apache.shardingsphere.infra.annotation.HighFrequencyInvocation;
import org.apache.shardingsphere.infra.binder.context.segment.select.subquery.SubqueryTableContext;
import org.apache.shardingsphere.infra.binder.context.segment.select.subquery.engine.SubqueryTableContextEngine;
import org.apache.shardingsphere.infra.binder.context.statement.dml.SelectStatementContext;
-import org.apache.shardingsphere.infra.database.core.metadata.database.DialectDatabaseMetaData;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.column.ColumnSegment;
-import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.OwnerSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SubqueryTableSegment;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableSegment;
-import org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue;
import java.util.Collection;
import java.util.Collections;
@@ -69,33 +65,29 @@ public final class TablesContext {
@Getter(AccessLevel.NONE)
private final Map<String, Collection<SubqueryTableContext>> subqueryTables = new HashMap<>();
- private final Map<String, String> tableAliasNameMap = new HashMap<>();
-
- public TablesContext(final SimpleTableSegment table, final DatabaseType databaseType, final String currentDatabaseName) {
- this(null == table ? Collections.emptyList() : Collections.singletonList(table), databaseType, currentDatabaseName);
+ public TablesContext(final SimpleTableSegment table) {
+ this(null == table ? Collections.emptyList() : Collections.singletonList(table));
}
- public TablesContext(final Collection<SimpleTableSegment> tables, final DatabaseType databaseType, final String currentDatabaseName) {
- this(tables, Collections.emptyMap(), databaseType, currentDatabaseName);
+ public TablesContext(final Collection<SimpleTableSegment> tables) {
+ this(tables, Collections.emptyMap());
}
- public TablesContext(final Collection<? extends TableSegment> tables, final Map<Integer, SelectStatementContext> subqueryContexts,
- final DatabaseType databaseType, final String currentDatabaseName) {
+ public TablesContext(final Collection<? extends TableSegment> tables, final Map<Integer, SelectStatementContext> subqueryContexts) {
if (tables.isEmpty()) {
return;
}
this.tables.addAll(tables);
for (TableSegment each : tables) {
if (each instanceof SimpleTableSegment) {
- String tableName = ((SimpleTableSegment) each).getTableName().getIdentifier().getValue();
- if (!"DUAL".equalsIgnoreCase(tableName)) {
- SimpleTableSegment simpleTableSegment = (SimpleTableSegment) each;
+ SimpleTableSegment simpleTableSegment = (SimpleTableSegment) each;
+ TableNameSegment tableName = simpleTableSegment.getTableName();
+ if (!"DUAL".equalsIgnoreCase(tableName.getIdentifier().getValue())) {
simpleTables.add(simpleTableSegment);
- tableNames.add(tableName);
- // TODO use SQL binder result when statement which contains tables support bind logic
- simpleTableSegment.getOwner().ifPresent(optional -> schemaNames.add(optional.getIdentifier().getValue()));
- databaseNames.add(findDatabaseName(simpleTableSegment, databaseType).orElse(currentDatabaseName));
- tableAliasNameMap.put(each.getAlias().map(IdentifierValue::getValue).orElse(tableName).toLowerCase(), tableName.toLowerCase());
+ tableNames.add(tableName.getIdentifier().getValue());
+ // TODO support bind with all statement contains table segement @duanzhengqiang
+ tableName.getTableBoundInfo().ifPresent(optional -> schemaNames.add(optional.getOriginalSchema().getValue()));
+ tableName.getTableBoundInfo().ifPresent(optional -> databaseNames.add(optional.getOriginalDatabase().getValue()));
}
}
if (each instanceof SubqueryTableSegment) {
@@ -104,12 +96,6 @@ public final class TablesContext {
}
}
- private Optional<String> findDatabaseName(final SimpleTableSegment tableSegment, final DatabaseType databaseType) {
- DialectDatabaseMetaData dialectDatabaseMetaData = new DatabaseTypeRegistry(databaseType).getDialectDatabaseMetaData();
- Optional<OwnerSegment> owner = dialectDatabaseMetaData.getDefaultSchema().isPresent() ? tableSegment.getOwner().flatMap(OwnerSegment::getOwner) : tableSegment.getOwner();
- return owner.map(optional -> optional.getIdentifier().getValue());
- }
-
private Map<String, Collection<SubqueryTableContext>> createSubqueryTables(final Map<Integer, SelectStatementContext> subqueryContexts, final SubqueryTableSegment subqueryTable) {
if (!subqueryContexts.containsKey(subqueryTable.getSubquery().getStartIndex())) {
return Collections.emptyMap();
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContextFactory.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContextFactory.java
index fdfdf048fc2..dce944382f9 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContextFactory.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContextFactory.java
@@ -134,10 +134,10 @@ public final class SQLStatementContextFactory {
return getDDLStatementContext(metaData, (DDLStatement) sqlStatement, params, currentDatabaseName);
}
if (sqlStatement instanceof DCLStatement) {
- return getDCLStatementContext((DCLStatement) sqlStatement, currentDatabaseName);
+ return getDCLStatementContext((DCLStatement) sqlStatement);
}
if (sqlStatement instanceof DALStatement) {
- return getDALStatementContext((DALStatement) sqlStatement, currentDatabaseName);
+ return getDALStatementContext((DALStatement) sqlStatement);
}
return new UnknownSQLStatementContext(sqlStatement);
}
@@ -147,22 +147,22 @@ public final class SQLStatementContextFactory {
return new SelectStatementContext(metaData, params, (SelectStatement) sqlStatement, currentDatabaseName, Collections.emptyList());
}
if (sqlStatement instanceof UpdateStatement) {
- return new UpdateStatementContext((UpdateStatement) sqlStatement, currentDatabaseName);
+ return new UpdateStatementContext((UpdateStatement) sqlStatement);
}
if (sqlStatement instanceof DeleteStatement) {
- return new DeleteStatementContext((DeleteStatement) sqlStatement, currentDatabaseName);
+ return new DeleteStatementContext((DeleteStatement) sqlStatement);
}
if (sqlStatement instanceof InsertStatement) {
return new InsertStatementContext(metaData, params, (InsertStatement) sqlStatement, currentDatabaseName);
}
if (sqlStatement instanceof CopyStatement) {
- return new CopyStatementContext((CopyStatement) sqlStatement, currentDatabaseName);
+ return new CopyStatementContext((CopyStatement) sqlStatement);
}
if (sqlStatement instanceof LoadDataStatement) {
- return new LoadDataStatementContext((LoadDataStatement) sqlStatement, currentDatabaseName);
+ return new LoadDataStatementContext((LoadDataStatement) sqlStatement);
}
if (sqlStatement instanceof LoadXMLStatement) {
- return new LoadXMLStatementContext((LoadXMLStatement) sqlStatement, currentDatabaseName);
+ return new LoadXMLStatementContext((LoadXMLStatement) sqlStatement);
}
if (sqlStatement instanceof CallStatement || sqlStatement instanceof DoStatement || sqlStatement instanceof MergeStatement) {
return new UnknownSQLStatementContext(sqlStatement);
@@ -175,87 +175,87 @@ public final class SQLStatementContextFactory {
return new CreateSchemaStatementContext((CreateSchemaStatement) sqlStatement);
}
if (sqlStatement instanceof CreateTableStatement) {
- return new CreateTableStatementContext((CreateTableStatement) sqlStatement, currentDatabaseName);
+ return new CreateTableStatementContext((CreateTableStatement) sqlStatement);
}
if (sqlStatement instanceof AlterTableStatement) {
- return new AlterTableStatementContext((AlterTableStatement) sqlStatement, currentDatabaseName);
+ return new AlterTableStatementContext((AlterTableStatement) sqlStatement);
}
if (sqlStatement instanceof RenameTableStatement) {
- return new RenameTableStatementContext((RenameTableStatement) sqlStatement, currentDatabaseName);
+ return new RenameTableStatementContext((RenameTableStatement) sqlStatement);
}
if (sqlStatement instanceof DropTableStatement) {
- return new DropTableStatementContext((DropTableStatement) sqlStatement, currentDatabaseName);
+ return new DropTableStatementContext((DropTableStatement) sqlStatement);
}
if (sqlStatement instanceof CreateIndexStatement) {
- return new CreateIndexStatementContext((CreateIndexStatement) sqlStatement, currentDatabaseName);
+ return new CreateIndexStatementContext((CreateIndexStatement) sqlStatement);
}
if (sqlStatement instanceof AlterIndexStatement) {
- return new AlterIndexStatementContext((AlterIndexStatement) sqlStatement, currentDatabaseName);
+ return new AlterIndexStatementContext((AlterIndexStatement) sqlStatement);
}
if (sqlStatement instanceof DropIndexStatement) {
- return new DropIndexStatementContext((DropIndexStatement) sqlStatement, currentDatabaseName);
+ return new DropIndexStatementContext((DropIndexStatement) sqlStatement);
}
if (sqlStatement instanceof TruncateStatement) {
- return new TruncateStatementContext((TruncateStatement) sqlStatement, currentDatabaseName);
+ return new TruncateStatementContext((TruncateStatement) sqlStatement);
}
if (sqlStatement instanceof CreateFunctionStatement) {
- return new CreateFunctionStatementContext((CreateFunctionStatement) sqlStatement, currentDatabaseName);
+ return new CreateFunctionStatementContext((CreateFunctionStatement) sqlStatement);
}
if (sqlStatement instanceof CreateProcedureStatement) {
- return new CreateProcedureStatementContext((CreateProcedureStatement) sqlStatement, currentDatabaseName);
+ return new CreateProcedureStatementContext((CreateProcedureStatement) sqlStatement);
}
if (sqlStatement instanceof CreateViewStatement) {
- return new CreateViewStatementContext((CreateViewStatement) sqlStatement, currentDatabaseName);
+ return new CreateViewStatementContext((CreateViewStatement) sqlStatement);
}
if (sqlStatement instanceof AlterViewStatement) {
- return new AlterViewStatementContext((AlterViewStatement) sqlStatement, currentDatabaseName);
+ return new AlterViewStatementContext((AlterViewStatement) sqlStatement);
}
if (sqlStatement instanceof DropViewStatement) {
- return new DropViewStatementContext((DropViewStatement) sqlStatement, currentDatabaseName);
+ return new DropViewStatementContext((DropViewStatement) sqlStatement);
}
if (sqlStatement instanceof PrepareStatement) {
- return new PrepareStatementContext((PrepareStatement) sqlStatement, currentDatabaseName);
+ return new PrepareStatementContext((PrepareStatement) sqlStatement);
}
if (sqlStatement instanceof CommentStatement) {
- return new CommentStatementContext((CommentStatement) sqlStatement, currentDatabaseName);
+ return new CommentStatementContext((CommentStatement) sqlStatement);
}
if (sqlStatement instanceof CursorStatement) {
return new CursorStatementContext(metaData, params, (CursorStatement) sqlStatement, currentDatabaseName);
}
if (sqlStatement instanceof CloseStatement) {
- return new CloseStatementContext((CloseStatement) sqlStatement, currentDatabaseName);
+ return new CloseStatementContext((CloseStatement) sqlStatement);
}
if (sqlStatement instanceof MoveStatement) {
- return new MoveStatementContext((MoveStatement) sqlStatement, currentDatabaseName);
+ return new MoveStatementContext((MoveStatement) sqlStatement);
}
if (sqlStatement instanceof FetchStatement) {
- return new FetchStatementContext((FetchStatement) sqlStatement, currentDatabaseName);
+ return new FetchStatementContext((FetchStatement) sqlStatement);
}
return new UnknownSQLStatementContext(sqlStatement);
}
- private static SQLStatementContext getDCLStatementContext(final DCLStatement sqlStatement, final String currentDatabaseName) {
+ private static SQLStatementContext getDCLStatementContext(final DCLStatement sqlStatement) {
if (sqlStatement instanceof GrantStatement) {
- return new GrantStatementContext((GrantStatement) sqlStatement, currentDatabaseName);
+ return new GrantStatementContext((GrantStatement) sqlStatement);
}
if (sqlStatement instanceof RevokeStatement) {
- return new RevokeStatementContext((RevokeStatement) sqlStatement, currentDatabaseName);
+ return new RevokeStatementContext((RevokeStatement) sqlStatement);
}
if (sqlStatement instanceof DenyUserStatement) {
- return new DenyUserStatementContext((DenyUserStatement) sqlStatement, currentDatabaseName);
+ return new DenyUserStatementContext((DenyUserStatement) sqlStatement);
}
return new UnknownSQLStatementContext(sqlStatement);
}
- private static SQLStatementContext getDALStatementContext(final DALStatement sqlStatement, final String currentDatabaseName) {
+ private static SQLStatementContext getDALStatementContext(final DALStatement sqlStatement) {
if (sqlStatement instanceof ExplainStatement) {
- return new ExplainStatementContext((ExplainStatement) sqlStatement, currentDatabaseName);
+ return new ExplainStatementContext((ExplainStatement) sqlStatement);
}
if (sqlStatement instanceof ShowCreateTableStatement) {
- return new ShowCreateTableStatementContext((ShowCreateTableStatement) sqlStatement, currentDatabaseName);
+ return new ShowCreateTableStatementContext((ShowCreateTableStatement) sqlStatement);
}
if (sqlStatement instanceof ShowColumnsStatement) {
- return new ShowColumnsStatementContext((ShowColumnsStatement) sqlStatement, currentDatabaseName);
+ return new ShowColumnsStatementContext((ShowColumnsStatement) sqlStatement);
}
if (sqlStatement instanceof ShowTablesStatement) {
return new ShowTablesStatementContext((ShowTablesStatement) sqlStatement);
@@ -264,16 +264,16 @@ public final class SQLStatementContextFactory {
return new ShowTableStatusStatementContext((ShowTableStatusStatement) sqlStatement);
}
if (sqlStatement instanceof ShowIndexStatement) {
- return new ShowIndexStatementContext((ShowIndexStatement) sqlStatement, currentDatabaseName);
+ return new ShowIndexStatementContext((ShowIndexStatement) sqlStatement);
}
if (sqlStatement instanceof AnalyzeTableStatement) {
- return new AnalyzeTableStatementContext((AnalyzeTableStatement) sqlStatement, currentDatabaseName);
+ return new AnalyzeTableStatementContext((AnalyzeTableStatement) sqlStatement);
}
if (sqlStatement instanceof FlushStatement) {
- return new FlushStatementContext((FlushStatement) sqlStatement, currentDatabaseName);
+ return new FlushStatementContext((FlushStatement) sqlStatement);
}
if (sqlStatement instanceof OptimizeTableStatement) {
- return new OptimizeTableStatementContext((OptimizeTableStatement) sqlStatement, currentDatabaseName);
+ return new OptimizeTableStatementContext((OptimizeTableStatement) sqlStatement);
}
return new UnknownSQLStatementContext(sqlStatement);
}
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/AnalyzeTableStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/AnalyzeTableStatementContext.java
index a17889aa1a9..8264edfec5d 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/AnalyzeTableStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/AnalyzeTableStatementContext.java
@@ -31,9 +31,9 @@ public final class AnalyzeTableStatementContext extends CommonSQLStatementContex
private final TablesContext tablesContext;
- public AnalyzeTableStatementContext(final AnalyzeTableStatement sqlStatement, final String currentDatabaseName) {
+ public AnalyzeTableStatementContext(final AnalyzeTableStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(sqlStatement.getTables(), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(sqlStatement.getTables());
}
@Override
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ExplainStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ExplainStatementContext.java
index 57ed251ced0..b97ba364c0d 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ExplainStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ExplainStatementContext.java
@@ -37,9 +37,9 @@ public final class ExplainStatementContext extends CommonSQLStatementContext imp
private final TablesContext tablesContext;
- public ExplainStatementContext(final ExplainStatement sqlStatement, final String currentDatabaseName) {
+ public ExplainStatementContext(final ExplainStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(extractTablesFromExplain(sqlStatement), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(extractTablesFromExplain(sqlStatement));
}
private Collection<SimpleTableSegment> extractTablesFromExplain(final ExplainStatement sqlStatement) {
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/FlushStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/FlushStatementContext.java
index 2854ff80d28..0ce573efb18 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/FlushStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/FlushStatementContext.java
@@ -31,9 +31,9 @@ public final class FlushStatementContext extends CommonSQLStatementContext imple
private final TablesContext tablesContext;
- public FlushStatementContext(final FlushStatement sqlStatement, final String currentDatabaseName) {
+ public FlushStatementContext(final FlushStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(sqlStatement.getTables(), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(sqlStatement.getTables());
}
@Override
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/OptimizeTableStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/OptimizeTableStatementContext.java
index bf9cedb7634..2fd4a2c6170 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/OptimizeTableStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/OptimizeTableStatementContext.java
@@ -31,9 +31,9 @@ public final class OptimizeTableStatementContext extends CommonSQLStatementConte
private final TablesContext tablesContext;
- public OptimizeTableStatementContext(final OptimizeTableStatement sqlStatement, final String currentDatabaseName) {
+ public OptimizeTableStatementContext(final OptimizeTableStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(sqlStatement.getTables(), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(sqlStatement.getTables());
}
@Override
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ShowColumnsStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ShowColumnsStatementContext.java
index c0501b12680..7f0279ba3e9 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ShowColumnsStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ShowColumnsStatementContext.java
@@ -36,9 +36,9 @@ public final class ShowColumnsStatementContext extends CommonSQLStatementContext
private final TablesContext tablesContext;
- public ShowColumnsStatementContext(final ShowColumnsStatement sqlStatement, final String currentDatabaseName) {
+ public ShowColumnsStatementContext(final ShowColumnsStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(sqlStatement.getTable(), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(sqlStatement.getTable());
}
@Override
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ShowCreateTableStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ShowCreateTableStatementContext.java
index d626c28aa05..b6ab3f2293d 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ShowCreateTableStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ShowCreateTableStatementContext.java
@@ -31,9 +31,9 @@ public final class ShowCreateTableStatementContext extends CommonSQLStatementCon
private final TablesContext tablesContext;
- public ShowCreateTableStatementContext(final ShowCreateTableStatement sqlStatement, final String currentDatabaseName) {
+ public ShowCreateTableStatementContext(final ShowCreateTableStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(sqlStatement.getTable(), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(sqlStatement.getTable());
}
@Override
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ShowIndexStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ShowIndexStatementContext.java
index 2a0d3bd8a58..653da167b41 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ShowIndexStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ShowIndexStatementContext.java
@@ -36,9 +36,9 @@ public final class ShowIndexStatementContext extends CommonSQLStatementContext i
private final TablesContext tablesContext;
- public ShowIndexStatementContext(final ShowIndexStatement sqlStatement, final String currentDatabaseName) {
+ public ShowIndexStatementContext(final ShowIndexStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(sqlStatement.getTable(), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(sqlStatement.getTable());
}
@Override
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dcl/DenyUserStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dcl/DenyUserStatementContext.java
index 36010fb6302..49341412bb1 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dcl/DenyUserStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dcl/DenyUserStatementContext.java
@@ -31,9 +31,9 @@ public final class DenyUserStatementContext extends CommonSQLStatementContext im
private final TablesContext tablesContext;
- public DenyUserStatementContext(final DenyUserStatement sqlStatement, final String currentDatabaseName) {
+ public DenyUserStatementContext(final DenyUserStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(sqlStatement.getTable(), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(sqlStatement.getTable());
}
@Override
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dcl/GrantStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dcl/GrantStatementContext.java
index 3c7acfa3d1d..b7e62ab8007 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dcl/GrantStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dcl/GrantStatementContext.java
@@ -31,9 +31,9 @@ public final class GrantStatementContext extends CommonSQLStatementContext imple
private final TablesContext tablesContext;
- public GrantStatementContext(final GrantStatement sqlStatement, final String currentDatabaseName) {
+ public GrantStatementContext(final GrantStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(sqlStatement.getTables(), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(sqlStatement.getTables());
}
@Override
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dcl/RevokeStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dcl/RevokeStatementContext.java
index 6a5ff0fb897..eec51964612 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dcl/RevokeStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dcl/RevokeStatementContext.java
@@ -31,9 +31,9 @@ public final class RevokeStatementContext extends CommonSQLStatementContext impl
private final TablesContext tablesContext;
- public RevokeStatementContext(final RevokeStatement sqlStatement, final String currentDatabaseName) {
+ public RevokeStatementContext(final RevokeStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(sqlStatement.getTables(), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(sqlStatement.getTables());
}
@Override
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/AlterIndexStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/AlterIndexStatementContext.java
index 15da776f23e..28b335fdfa8 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/AlterIndexStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/AlterIndexStatementContext.java
@@ -39,10 +39,10 @@ public final class AlterIndexStatementContext extends CommonSQLStatementContext
private final TablesContext tablesContext;
- public AlterIndexStatementContext(final AlterIndexStatement sqlStatement, final String currentDatabaseName) {
+ public AlterIndexStatementContext(final AlterIndexStatement sqlStatement) {
super(sqlStatement);
SimpleTableSegment simpleTableSegment = sqlStatement.getSimpleTable().orElse(null);
- tablesContext = new TablesContext(simpleTableSegment, getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(simpleTableSegment);
}
@Override
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/AlterTableStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/AlterTableStatementContext.java
index 3dfe294409b..21be1d92fe5 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/AlterTableStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/AlterTableStatementContext.java
@@ -48,9 +48,9 @@ public final class AlterTableStatementContext extends CommonSQLStatementContext
private final TablesContext tablesContext;
- public AlterTableStatementContext(final AlterTableStatement sqlStatement, final String currentDatabaseName) {
+ public AlterTableStatementContext(final AlterTableStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(getTables(sqlStatement), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(getTables(sqlStatement));
}
private Collection<SimpleTableSegment> getTables(final AlterTableStatement sqlStatement) {
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/AlterViewStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/AlterViewStatementContext.java
index 5406c78f1be..1b0e25a3c07 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/AlterViewStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/AlterViewStatementContext.java
@@ -38,7 +38,7 @@ public final class AlterViewStatementContext extends CommonSQLStatementContext i
private final TablesContext tablesContext;
- public AlterViewStatementContext(final AlterViewStatement sqlStatement, final String currentDatabaseName) {
+ public AlterViewStatementContext(final AlterViewStatement sqlStatement) {
super(sqlStatement);
Collection<SimpleTableSegment> tables = new LinkedList<>();
tables.add(sqlStatement.getView());
@@ -49,7 +49,7 @@ public final class AlterViewStatementContext extends CommonSQLStatementContext i
tables.addAll(extractor.getRewriteTables());
});
sqlStatement.getRenameView().ifPresent(tables::add);
- tablesContext = new TablesContext(tables, getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(tables);
}
@Override
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CloseStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CloseStatementContext.java
index 95bb62adeb9..e8b4a9c867d 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CloseStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CloseStatementContext.java
@@ -44,9 +44,9 @@ public final class CloseStatementContext extends CommonSQLStatementContext imple
private TablesContext tablesContext;
- public CloseStatementContext(final CloseStatement sqlStatement, final String currentDatabaseName) {
+ public CloseStatementContext(final CloseStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(Collections.emptyList(), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(Collections.emptyList());
}
@Override
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CommentStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CommentStatementContext.java
index 79605ca3ba4..1fa10fbbc4f 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CommentStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CommentStatementContext.java
@@ -33,9 +33,9 @@ public final class CommentStatementContext extends CommonSQLStatementContext imp
private final TablesContext tablesContext;
- public CommentStatementContext(final CommentStatement sqlStatement, final String currentDatabaseName) {
+ public CommentStatementContext(final CommentStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(null == sqlStatement.getTable() ? Collections.emptyList() : Collections.singletonList(sqlStatement.getTable()), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(null == sqlStatement.getTable() ? Collections.emptyList() : Collections.singletonList(sqlStatement.getTable()));
}
@Override
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateFunctionStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateFunctionStatementContext.java
index a07f00f2a20..0264709615d 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateFunctionStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateFunctionStatementContext.java
@@ -37,11 +37,11 @@ public final class CreateFunctionStatementContext extends CommonSQLStatementCont
private final TablesContext tablesContext;
- public CreateFunctionStatementContext(final CreateFunctionStatement sqlStatement, final String currentDatabaseName) {
+ public CreateFunctionStatementContext(final CreateFunctionStatement sqlStatement) {
super(sqlStatement);
Optional<RoutineBodySegment> routineBodySegment = sqlStatement.getRoutineBody();
Collection<SimpleTableSegment> tables = routineBodySegment.map(optional -> new TableExtractor().extractExistTableFromRoutineBody(optional)).orElseGet(Collections::emptyList);
- tablesContext = new TablesContext(tables, getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(tables);
}
@Override
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateIndexStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateIndexStatementContext.java
index 0b08db3bfaa..e43ff274ecc 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateIndexStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateIndexStatementContext.java
@@ -42,9 +42,9 @@ public final class CreateIndexStatementContext extends CommonSQLStatementContext
private final boolean generatedIndex;
- public CreateIndexStatementContext(final CreateIndexStatement sqlStatement, final String currentDatabaseName) {
+ public CreateIndexStatementContext(final CreateIndexStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(sqlStatement.getTable(), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(sqlStatement.getTable());
generatedIndex = null == sqlStatement.getIndex();
}
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateProcedureStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateProcedureStatementContext.java
index b9ba75d0104..1bf88c04698 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateProcedureStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateProcedureStatementContext.java
@@ -37,11 +37,11 @@ public final class CreateProcedureStatementContext extends CommonSQLStatementCon
private final TablesContext tablesContext;
- public CreateProcedureStatementContext(final CreateProcedureStatement sqlStatement, final String currentDatabaseName) {
+ public CreateProcedureStatementContext(final CreateProcedureStatement sqlStatement) {
super(sqlStatement);
Optional<RoutineBodySegment> routineBodySegment = sqlStatement.getRoutineBody();
Collection<SimpleTableSegment> tables = routineBodySegment.map(optional -> new TableExtractor().extractExistTableFromRoutineBody(optional)).orElseGet(Collections::emptyList);
- tablesContext = new TablesContext(tables, getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(tables);
}
@Override
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateTableStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateTableStatementContext.java
index d12cc0aa63b..091fac0a2b5 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateTableStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateTableStatementContext.java
@@ -42,9 +42,9 @@ public final class CreateTableStatementContext extends CommonSQLStatementContext
private final TablesContext tablesContext;
- public CreateTableStatementContext(final CreateTableStatement sqlStatement, final String currentDatabaseName) {
+ public CreateTableStatementContext(final CreateTableStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(getTables(sqlStatement), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(getTables(sqlStatement));
}
private Collection<SimpleTableSegment> getTables(final CreateTableStatement sqlStatement) {
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateViewStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateViewStatementContext.java
index 83d2f8fd8d6..730d89b76db 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateViewStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateViewStatementContext.java
@@ -32,11 +32,11 @@ public final class CreateViewStatementContext extends CommonSQLStatementContext
private final TablesContext tablesContext;
- public CreateViewStatementContext(final CreateViewStatement sqlStatement, final String currentDatabaseName) {
+ public CreateViewStatementContext(final CreateViewStatement sqlStatement) {
super(sqlStatement);
TableExtractor extractor = new TableExtractor();
extractor.extractTablesFromCreateViewStatement(sqlStatement);
- tablesContext = new TablesContext(extractor.getRewriteTables(), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(extractor.getRewriteTables());
}
@Override
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CursorStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CursorStatementContext.java
index 4d6e67c71fe..22c316fa344 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CursorStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CursorStatementContext.java
@@ -25,13 +25,13 @@ import org.apache.shardingsphere.infra.binder.context.type.CursorAvailable;
import org.apache.shardingsphere.infra.binder.context.type.TableAvailable;
import org.apache.shardingsphere.infra.binder.context.type.WhereAvailable;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.sql.parser.statement.core.extractor.TableExtractor;
import org.apache.shardingsphere.sql.parser.statement.core.segment.ddl.cursor.CursorNameSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.column.ColumnSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.BinaryOperationExpression;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.predicate.WhereSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.CursorStatement;
-import org.apache.shardingsphere.sql.parser.statement.core.extractor.TableExtractor;
import java.util.Collection;
import java.util.Collections;
@@ -57,7 +57,7 @@ public final class CursorStatementContext extends CommonSQLStatementContext impl
public CursorStatementContext(final ShardingSphereMetaData metaData, final List<Object> params, final CursorStatement sqlStatement, final String currentDatabaseName) {
super(sqlStatement);
- tablesContext = new TablesContext(getSimpleTableSegments(), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(getSimpleTableSegments());
selectStatementContext = new SelectStatementContext(metaData, params, sqlStatement.getSelect(), currentDatabaseName, Collections.emptyList());
whereSegments.addAll(selectStatementContext.getWhereSegments());
columnSegments.addAll(selectStatementContext.getColumnSegments());
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/DropIndexStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/DropIndexStatementContext.java
index 0389b137afe..88b389a5a11 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/DropIndexStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/DropIndexStatementContext.java
@@ -38,10 +38,10 @@ public final class DropIndexStatementContext extends CommonSQLStatementContext i
private final TablesContext tablesContext;
- public DropIndexStatementContext(final DropIndexStatement sqlStatement, final String currentDatabaseName) {
+ public DropIndexStatementContext(final DropIndexStatement sqlStatement) {
super(sqlStatement);
SimpleTableSegment simpleTableSegment = sqlStatement.getSimpleTable().orElse(null);
- tablesContext = new TablesContext(simpleTableSegment, getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(simpleTableSegment);
}
@Override
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/DropTableStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/DropTableStatementContext.java
index 8babf0c8fa3..9741d893d0d 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/DropTableStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/DropTableStatementContext.java
@@ -31,9 +31,9 @@ public final class DropTableStatementContext extends CommonSQLStatementContext i
private final TablesContext tablesContext;
- public DropTableStatementContext(final DropTableStatement sqlStatement, final String currentDatabaseName) {
+ public DropTableStatementContext(final DropTableStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(sqlStatement.getTables(), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(sqlStatement.getTables());
}
@Override
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/DropViewStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/DropViewStatementContext.java
index 99ae13b289f..6c5d158a01c 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/DropViewStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/DropViewStatementContext.java
@@ -31,9 +31,9 @@ public final class DropViewStatementContext extends CommonSQLStatementContext im
private final TablesContext tablesContext;
- public DropViewStatementContext(final DropViewStatement sqlStatement, final String currentDatabaseName) {
+ public DropViewStatementContext(final DropViewStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(sqlStatement.getViews(), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(sqlStatement.getViews());
}
@Override
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/FetchStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/FetchStatementContext.java
index 385b1736a17..2dbb0dd9508 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/FetchStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/FetchStatementContext.java
@@ -44,9 +44,9 @@ public final class FetchStatementContext extends CommonSQLStatementContext imple
private TablesContext tablesContext;
- public FetchStatementContext(final FetchStatement sqlStatement, final String currentDatabaseName) {
+ public FetchStatementContext(final FetchStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(Collections.emptyList(), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(Collections.emptyList());
}
@Override
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/MoveStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/MoveStatementContext.java
index d3f91659fc6..380ea200bb9 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/MoveStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/MoveStatementContext.java
@@ -44,9 +44,9 @@ public final class MoveStatementContext extends CommonSQLStatementContext implem
private TablesContext tablesContext;
- public MoveStatementContext(final MoveStatement sqlStatement, final String currentDatabaseName) {
+ public MoveStatementContext(final MoveStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(Collections.emptyList(), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(Collections.emptyList());
}
@Override
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/PrepareStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/PrepareStatementContext.java
index a97c1d8eaa9..007a3eda53d 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/PrepareStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/PrepareStatementContext.java
@@ -36,9 +36,9 @@ public final class PrepareStatementContext extends CommonSQLStatementContext imp
private final TablesContext tablesContext;
- public PrepareStatementContext(final PrepareStatement sqlStatement, final String currentDatabaseName) {
+ public PrepareStatementContext(final PrepareStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(extractTablesFromPreparedStatement(sqlStatement), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(extractTablesFromPreparedStatement(sqlStatement));
}
private Collection<SimpleTableSegment> extractTablesFromPreparedStatement(final PrepareStatement sqlStatement) {
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/RenameTableStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/RenameTableStatementContext.java
index 34d4b87f68f..550f36707ec 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/RenameTableStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/RenameTableStatementContext.java
@@ -36,9 +36,9 @@ public final class RenameTableStatementContext extends CommonSQLStatementContext
private final TablesContext tablesContext;
- public RenameTableStatementContext(final RenameTableStatement sqlStatement, final String currentDatabaseName) {
+ public RenameTableStatementContext(final RenameTableStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(getTables(sqlStatement), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(getTables(sqlStatement));
}
private Collection<SimpleTableSegment> getTables(final RenameTableStatement sqlStatement) {
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/TruncateStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/TruncateStatementContext.java
index b4a5d832395..e97aa018d29 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/TruncateStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/TruncateStatementContext.java
@@ -31,9 +31,9 @@ public final class TruncateStatementContext extends CommonSQLStatementContext im
private final TablesContext tablesContext;
- public TruncateStatementContext(final TruncateStatement sqlStatement, final String currentDatabaseName) {
+ public TruncateStatementContext(final TruncateStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(sqlStatement.getTables(), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(sqlStatement.getTables());
}
@Override
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/CopyStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/CopyStatementContext.java
index 4b157bd6969..ce39780ad48 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/CopyStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/CopyStatementContext.java
@@ -31,9 +31,9 @@ public final class CopyStatementContext extends CommonSQLStatementContext implem
private final TablesContext tablesContext;
- public CopyStatementContext(final CopyStatement sqlStatement, final String currentDatabaseName) {
+ public CopyStatementContext(final CopyStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(sqlStatement.getTableSegment(), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(sqlStatement.getTableSegment());
}
@Override
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/DeleteStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/DeleteStatementContext.java
index 4bde06fb361..d5a01ab9b1e 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/DeleteStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/DeleteStatementContext.java
@@ -50,9 +50,9 @@ public final class DeleteStatementContext extends CommonSQLStatementContext impl
private final Collection<BinaryOperationExpression> joinConditions = new LinkedList<>();
- public DeleteStatementContext(final DeleteStatement sqlStatement, final String currentDatabaseName) {
+ public DeleteStatementContext(final DeleteStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(getAllSimpleTableSegments(), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(getAllSimpleTableSegments());
getSqlStatement().getWhere().ifPresent(whereSegments::add);
ColumnExtractor.extractColumnSegments(columnSegments, whereSegments);
ExpressionExtractor.extractJoinConditions(joinConditions, whereSegments);
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/InsertStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/InsertStatementContext.java
index 2f48a3daada..4b8de3e31b5 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/InsertStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/InsertStatementContext.java
@@ -37,6 +37,7 @@ import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import org.apache.shardingsphere.sql.parser.statement.core.enums.SubqueryType;
+import org.apache.shardingsphere.sql.parser.statement.core.extractor.TableExtractor;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.assignment.ColumnAssignmentSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.assignment.InsertValuesSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.assignment.SetAssignmentSegment;
@@ -49,7 +50,6 @@ import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.subq
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.predicate.WhereSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dml.InsertStatement;
-import org.apache.shardingsphere.sql.parser.statement.core.extractor.TableExtractor;
import java.util.ArrayList;
import java.util.Collection;
@@ -101,7 +101,7 @@ public final class InsertStatementContext extends CommonSQLStatementContext impl
insertValueContexts = getInsertValueContexts(params, parametersOffset, valueExpressions);
insertSelectContext = getInsertSelectContext(metaData, params, parametersOffset, currentDatabaseName).orElse(null);
onDuplicateKeyUpdateValueContext = getOnDuplicateKeyUpdateValueContext(params, parametersOffset).orElse(null);
- tablesContext = new TablesContext(getAllSimpleTableSegments(), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(getAllSimpleTableSegments());
List<String> insertColumnNames = getInsertColumnNames();
ShardingSphereSchema schema = getSchema(metaData, currentDatabaseName);
columnNames = containsInsertColumns()
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/LoadDataStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/LoadDataStatementContext.java
index 6b172406f91..8cb65ff7e9b 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/LoadDataStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/LoadDataStatementContext.java
@@ -31,9 +31,9 @@ public final class LoadDataStatementContext extends CommonSQLStatementContext im
private final TablesContext tablesContext;
- public LoadDataStatementContext(final LoadDataStatement sqlStatement, final String currentDatabaseName) {
+ public LoadDataStatementContext(final LoadDataStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(sqlStatement.getTableSegment(), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(sqlStatement.getTableSegment());
}
@Override
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/LoadXMLStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/LoadXMLStatementContext.java
index d4d804d138c..a3a32ca505e 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/LoadXMLStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/LoadXMLStatementContext.java
@@ -31,9 +31,9 @@ public final class LoadXMLStatementContext extends CommonSQLStatementContext imp
private final TablesContext tablesContext;
- public LoadXMLStatementContext(final LoadXMLStatement sqlStatement, final String currentDatabaseName) {
+ public LoadXMLStatementContext(final LoadXMLStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(sqlStatement.getTableSegment(), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(sqlStatement.getTableSegment());
}
@Override
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/SelectStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/SelectStatementContext.java
index b094b2e3dc7..36d9a28221d 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/SelectStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/SelectStatementContext.java
@@ -120,7 +120,7 @@ public final class SelectStatementContext extends CommonSQLStatementContext impl
Collection<TableSegment> tableSegments = getAllTableSegments(inheritedTables);
ExpressionExtractor.extractJoinConditions(joinConditions, whereSegments);
subqueryContexts = createSubqueryContexts(metaData, params, currentDatabaseName, tableSegments);
- tablesContext = new TablesContext(tableSegments, subqueryContexts, getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(tableSegments, subqueryContexts);
groupByContext = new GroupByContextEngine().createGroupByContext(sqlStatement);
orderByContext = new OrderByContextEngine().createOrderBy(sqlStatement, groupByContext);
projectionsContext = new ProjectionsContextEngine(getDatabaseType()).createProjectionsContext(getSqlStatement().getProjections(), groupByContext, orderByContext);
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/UpdateStatementContext.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/UpdateStatementContext.java
index bf0938e4b04..b8f1ad79bdc 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/UpdateStatementContext.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/UpdateStatementContext.java
@@ -22,14 +22,14 @@ import org.apache.shardingsphere.infra.binder.context.segment.table.TablesContex
import org.apache.shardingsphere.infra.binder.context.statement.CommonSQLStatementContext;
import org.apache.shardingsphere.infra.binder.context.type.TableAvailable;
import org.apache.shardingsphere.infra.binder.context.type.WhereAvailable;
+import org.apache.shardingsphere.sql.parser.statement.core.extractor.ColumnExtractor;
+import org.apache.shardingsphere.sql.parser.statement.core.extractor.ExpressionExtractor;
import org.apache.shardingsphere.sql.parser.statement.core.extractor.TableExtractor;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.column.ColumnSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.BinaryOperationExpression;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.predicate.WhereSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dml.UpdateStatement;
-import org.apache.shardingsphere.sql.parser.statement.core.extractor.ColumnExtractor;
-import org.apache.shardingsphere.sql.parser.statement.core.extractor.ExpressionExtractor;
import java.util.Collection;
import java.util.LinkedList;
@@ -48,9 +48,9 @@ public final class UpdateStatementContext extends CommonSQLStatementContext impl
private final Collection<BinaryOperationExpression> joinConditions = new LinkedList<>();
- public UpdateStatementContext(final UpdateStatement sqlStatement, final String currentDatabaseName) {
+ public UpdateStatementContext(final UpdateStatement sqlStatement) {
super(sqlStatement);
- tablesContext = new TablesContext(getAllSimpleTableSegments(), getDatabaseType(), currentDatabaseName);
+ tablesContext = new TablesContext(getAllSimpleTableSegments());
getSqlStatement().getWhere().ifPresent(whereSegments::add);
ColumnExtractor.extractColumnSegments(columnSegments, whereSegments);
ExpressionExtractor.extractJoinConditions(joinConditions, whereSegments);
diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/from/type/SimpleTableSegmentBinder.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/from/type/SimpleTableSegmentBinder.java
index e77dc4f7f4e..be851ce3896 100644
--- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/from/type/SimpleTableSegmentBinder.java
+++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/from/type/SimpleTableSegmentBinder.java
@@ -89,6 +89,7 @@ public final class SimpleTableSegmentBinder {
tableBinderContexts.put(new CaseInsensitiveString(segment.getAliasName().orElseGet(tableName::getValue)),
createSimpleTableBinderContext(segment, schema, databaseName, schemaName, binderContext));
TableNameSegment tableNameSegment = new TableNameSegment(segment.getTableName().getStartIndex(), segment.getTableName().getStopIndex(), tableName);
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(databaseName, schemaName));
SimpleTableSegment result = new SimpleTableSegment(tableNameSegment);
segment.getOwner().ifPresent(result::setOwner);
segment.getAliasSegment().ifPresent(result::setAlias);
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/engine/ProjectionsContextEngineTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/engine/ProjectionsContextEngineTest.java
index 3abaf2d0df1..145801229a9 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/engine/ProjectionsContextEngineTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/engine/ProjectionsContextEngineTest.java
@@ -36,6 +36,7 @@ import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.order.ite
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.order.item.IndexOrderByItemSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.AliasSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.OwnerSegment;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SubqueryTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
@@ -126,6 +127,7 @@ class ProjectionsContextEngineTest {
selectStatement.setProjections(projectionsSegment);
ShorthandProjectionSegment shorthandProjectionSegment = new ShorthandProjectionSegment(0, 10);
OwnerSegment owner = new OwnerSegment(0, 10, new IdentifierValue("name"));
+ owner.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
shorthandProjectionSegment.setOwner(owner);
projectionsSegment.getProjections().add(shorthandProjectionSegment);
SelectStatementContext selectStatementContext = createSelectStatementContext(selectStatement);
@@ -164,6 +166,7 @@ class ProjectionsContextEngineTest {
selectStatement.setProjections(projectionsSegment);
ShorthandProjectionSegment shorthandProjectionSegment = new ShorthandProjectionSegment(0, 10);
OwnerSegment owner = new OwnerSegment(0, 10, new IdentifierValue("name"));
+ owner.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
shorthandProjectionSegment.setOwner(owner);
projectionsSegment.getProjections().add(shorthandProjectionSegment);
OrderByItem orderByItem = new OrderByItem(new IndexOrderByItemSegment(0, 1, 0, OrderDirection.ASC, NullsOrderType.FIRST));
@@ -204,6 +207,7 @@ class ProjectionsContextEngineTest {
selectStatement.setProjections(projectionsSegment);
ShorthandProjectionSegment shorthandProjectionSegment = new ShorthandProjectionSegment(0, 10);
OwnerSegment owner = new OwnerSegment(0, 10, new IdentifierValue("name"));
+ owner.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
shorthandProjectionSegment.setOwner(owner);
projectionsSegment.getProjections().add(shorthandProjectionSegment);
OrderByItem orderByItem = new OrderByItem(new ExpressionOrderByItemSegment(0, 1, "", OrderDirection.ASC, NullsOrderType.FIRST));
@@ -248,9 +252,12 @@ class ProjectionsContextEngineTest {
private void assertCreateProjectionsContextWhenColumnOrderByItemSegmentOwnerAbsent(final SelectStatement selectStatement) {
ProjectionsSegment projectionsSegment = new ProjectionsSegment(0, 0);
selectStatement.setProjections(projectionsSegment);
- selectStatement.setFrom(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("name"))));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("name"));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ selectStatement.setFrom(new SimpleTableSegment(tableNameSegment));
ShorthandProjectionSegment shorthandProjectionSegment = new ShorthandProjectionSegment(0, 10);
OwnerSegment owner = new OwnerSegment(0, 10, new IdentifierValue("name"));
+ owner.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
shorthandProjectionSegment.setOwner(owner);
projectionsSegment.getProjections().add(shorthandProjectionSegment);
OrderByItem orderByItem = new OrderByItem(new ColumnOrderByItemSegment(new ColumnSegment(0, 0, new IdentifierValue("name")), OrderDirection.ASC, NullsOrderType.FIRST));
@@ -289,9 +296,12 @@ class ProjectionsContextEngineTest {
private void assertCreateProjectionsContextWhenColumnOrderByItemSegmentOwnerPresent(final SelectStatement selectStatement) {
ProjectionsSegment projectionsSegment = new ProjectionsSegment(0, 0);
selectStatement.setProjections(projectionsSegment);
- selectStatement.setFrom(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("name"))));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("name"));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ selectStatement.setFrom(new SimpleTableSegment(tableNameSegment));
ShorthandProjectionSegment shorthandProjectionSegment = new ShorthandProjectionSegment(0, 10);
OwnerSegment owner = new OwnerSegment(0, 10, new IdentifierValue("name"));
+ owner.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
shorthandProjectionSegment.setOwner(owner);
projectionsSegment.getProjections().add(shorthandProjectionSegment);
OrderByItem orderByItem = new OrderByItem(new ColumnOrderByItemSegment(new ColumnSegment(0, 0, new IdentifierValue("name")), OrderDirection.ASC, NullsOrderType.FIRST));
@@ -328,14 +338,17 @@ class ProjectionsContextEngineTest {
}
private void assertCreateProjectionsContextWhenColumnOrderByItemSegmentOwnerPresentAndTablePresent(final SelectStatement selectStatement) {
- SimpleTableSegment tableSegment = new SimpleTableSegment(new TableNameSegment(0, 10, new IdentifierValue("name")));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 10, new IdentifierValue("name"));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ SimpleTableSegment tableSegment = new SimpleTableSegment(tableNameSegment);
ProjectionsSegment projectionsSegment = new ProjectionsSegment(0, 0);
selectStatement.setProjections(projectionsSegment);
tableSegment.setOwner(new OwnerSegment(0, 0, new IdentifierValue("foo_db")));
selectStatement.setFrom(tableSegment);
ShorthandProjectionSegment shorthandProjectionSegment = new ShorthandProjectionSegment(0, 10);
- SimpleTableSegment table = new SimpleTableSegment(new TableNameSegment(0, 10, new IdentifierValue("name")));
+ SimpleTableSegment table = new SimpleTableSegment(tableNameSegment);
OwnerSegment owner = new OwnerSegment(0, 10, new IdentifierValue("name"));
+ owner.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
table.setOwner(new OwnerSegment(0, 10, new IdentifierValue("name")));
shorthandProjectionSegment.setOwner(owner);
ColumnSegment columnSegment = new ColumnSegment(0, 0, new IdentifierValue("col"));
@@ -447,7 +460,9 @@ class ProjectionsContextEngineTest {
ProjectionsSegment projectionsSegment = new ProjectionsSegment(0, 0);
projectionsSegment.getProjections().add(new ShorthandProjectionSegment(0, 0));
selectStatement.setProjections(projectionsSegment);
- selectStatement.setFrom(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order"))));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("t_order"));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ selectStatement.setFrom(new SimpleTableSegment(tableNameSegment));
OrderByItem orderByItem = new OrderByItem(new ExpressionOrderByItemSegment(0, 0, "id + 1", OrderDirection.ASC, NullsOrderType.FIRST));
OrderByContext orderByContext = new OrderByContext(Collections.singleton(orderByItem), false);
SelectStatementContext selectStatementContext = createSelectStatementContext(selectStatement);
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/table/TablesContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/table/TablesContextTest.java
index 6beda71aba1..377c317dfb3 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/table/TablesContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/table/TablesContextTest.java
@@ -17,14 +17,13 @@
package org.apache.shardingsphere.infra.binder.context.segment.table;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereColumn;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.column.ColumnSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.AliasSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.OwnerSegment;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableSegment;
@@ -47,92 +46,94 @@ import static org.mockito.Mockito.when;
class TablesContextTest {
- private final DatabaseType databaseType = TypedSPILoader.getService(DatabaseType.class, "FIXTURE");
-
@Test
void assertGetTableNamesWithoutTableSegments() {
- assertTrue(new TablesContext(Collections.emptyList(), Collections.emptyMap(), databaseType, "foo_db").getTableNames().isEmpty());
+ assertTrue(new TablesContext(Collections.emptyList(), Collections.emptyMap()).getTableNames().isEmpty());
}
@Test
void assertGetTableNamesWithoutSimpleTableSegments() {
- assertTrue(new TablesContext(Collections.singleton(mock(TableSegment.class)), Collections.emptyMap(), databaseType, "foo_db").getTableNames().isEmpty());
+ assertTrue(new TablesContext(Collections.singleton(mock(TableSegment.class)), Collections.emptyMap()).getTableNames().isEmpty());
}
@Test
void assertGetTableNames() {
TablesContext tablesContext = new TablesContext(
- Arrays.asList(createTableSegment("table_1", "tbl_1"), createTableSegment("table_2", "tbl_2"), createTableSegment("DUAL", "dual")), databaseType, "foo_db");
+ Arrays.asList(createTableSegment("table_1", "tbl_1", "sharding_db_1"), createTableSegment("table_2", "tbl_2", "sharding_db_1"), createTableSegment("DUAL", "dual", "sharding_db_1")));
assertThat(tablesContext.getTableNames(), is(new HashSet<>(Arrays.asList("table_1", "table_2"))));
}
@Test
void assertInstanceCreatedWhenNoExceptionThrown() {
- SimpleTableSegment tableSegment = new SimpleTableSegment(new TableNameSegment(0, 10, new IdentifierValue("tbl")));
- tableSegment.setOwner(new OwnerSegment(0, 0, new IdentifierValue("schema")));
- TablesContext tablesContext = new TablesContext(Collections.singleton(tableSegment), databaseType, "foo_db");
- assertThat(tablesContext.getDatabaseName(), is(Optional.of("schema")));
- assertThat(tablesContext.getSchemaName(), is(Optional.of("schema")));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 10, new IdentifierValue("tbl"));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_db")));
+ SimpleTableSegment tableSegment = new SimpleTableSegment(tableNameSegment);
+ tableSegment.setOwner(new OwnerSegment(0, 0, new IdentifierValue("foo_db")));
+ TablesContext tablesContext = new TablesContext(Collections.singleton(tableSegment));
+ assertThat(tablesContext.getDatabaseName(), is(Optional.of("foo_db")));
+ assertThat(tablesContext.getSchemaName(), is(Optional.of("foo_db")));
assertThat(tablesContext.getTableNames(), is(Collections.singleton("tbl")));
}
@Test
void assertFindTableNameWhenSingleTable() {
- SimpleTableSegment tableSegment = createTableSegment("table_1", "tbl_1");
+ SimpleTableSegment tableSegment = createTableSegment("table_1", "tbl_1", "sharding_db_1");
ColumnSegment columnSegment = createColumnSegment(null, "col");
- Map<String, String> actual = new TablesContext(Collections.singletonList(tableSegment), databaseType, "foo_db").findTableNames(Collections.singletonList(columnSegment), mock());
+ Map<String, String> actual = new TablesContext(Collections.singletonList(tableSegment)).findTableNames(Collections.singletonList(columnSegment), mock());
assertFalse(actual.isEmpty());
assertThat(actual.get("col"), is("table_1"));
}
@Test
void assertFindTableNameWhenColumnSegmentOwnerPresent() {
- SimpleTableSegment tableSegment1 = createTableSegment("table_1", "tbl_1");
- SimpleTableSegment tableSegment2 = createTableSegment("table_2", "tbl_2");
+ SimpleTableSegment tableSegment1 = createTableSegment("table_1", "tbl_1", "sharding_db_1");
+ SimpleTableSegment tableSegment2 = createTableSegment("table_2", "tbl_2", "sharding_db_1");
ColumnSegment columnSegment = createColumnSegment("table_1", "col");
- Map<String, String> actual = new TablesContext(Arrays.asList(tableSegment1, tableSegment2), databaseType, "foo_db").findTableNames(Collections.singletonList(columnSegment), mock());
+ Map<String, String> actual = new TablesContext(Arrays.asList(tableSegment1, tableSegment2)).findTableNames(Collections.singletonList(columnSegment), mock());
assertFalse(actual.isEmpty());
assertThat(actual.get("table_1.col"), is("table_1"));
}
@Test
void assertFindTableNameWhenColumnSegmentOwnerAbsent() {
- SimpleTableSegment tableSegment1 = createTableSegment("table_1", "tbl_1");
- SimpleTableSegment tableSegment2 = createTableSegment("table_2", "tbl_2");
+ SimpleTableSegment tableSegment1 = createTableSegment("table_1", "tbl_1", "sharding_db_1");
+ SimpleTableSegment tableSegment2 = createTableSegment("table_2", "tbl_2", "sharding_db_1");
ColumnSegment columnSegment = createColumnSegment(null, "col");
- Map<String, String> actual = new TablesContext(Arrays.asList(tableSegment1, tableSegment2), databaseType, "foo_db").findTableNames(Collections.singletonList(columnSegment), mock());
+ Map<String, String> actual = new TablesContext(Arrays.asList(tableSegment1, tableSegment2)).findTableNames(Collections.singletonList(columnSegment), mock());
assertTrue(actual.isEmpty());
}
@Test
void assertFindTableNameWhenColumnSegmentOwnerAbsentAndSchemaMetaDataContainsColumn() {
- SimpleTableSegment tableSegment1 = createTableSegment("table_1", "tbl_1");
- SimpleTableSegment tableSegment2 = createTableSegment("table_2", "tbl_2");
+ SimpleTableSegment tableSegment1 = createTableSegment("table_1", "tbl_1", "sharding_db_1");
+ SimpleTableSegment tableSegment2 = createTableSegment("table_2", "tbl_2", "sharding_db_1");
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(schema.containsTable("table_1")).thenReturn(true);
ShardingSphereTable table = mock(ShardingSphereTable.class);
when(table.containsColumn("col")).thenReturn(true);
when(schema.getTable("table_1")).thenReturn(table);
ColumnSegment columnSegment = createColumnSegment(null, "col");
- Map<String, String> actual = new TablesContext(Arrays.asList(tableSegment1, tableSegment2), databaseType, "foo_db").findTableNames(Collections.singletonList(columnSegment), schema);
+ Map<String, String> actual = new TablesContext(Arrays.asList(tableSegment1, tableSegment2)).findTableNames(Collections.singletonList(columnSegment), schema);
assertThat(actual.get("col"), is("table_1"));
}
@Test
void assertFindTableNameWhenColumnSegmentOwnerAbsentAndSchemaMetaDataContainsColumnInUpperCase() {
- SimpleTableSegment tableSegment1 = createTableSegment("TABLE_1", "TBL_1");
- SimpleTableSegment tableSegment2 = createTableSegment("TABLE_2", "TBL_2");
+ SimpleTableSegment tableSegment1 = createTableSegment("TABLE_1", "TBL_1", "sharding_db_1");
+ SimpleTableSegment tableSegment2 = createTableSegment("TABLE_2", "TBL_2", "sharding_db_1");
ShardingSphereTable table = new ShardingSphereTable("TABLE_1",
Collections.singletonList(new ShardingSphereColumn("COL", 0, false, false, true, true, false, false)), Collections.emptyList(), Collections.emptyList());
ShardingSphereSchema schema = new ShardingSphereSchema("foo_db", Collections.singleton(table), Collections.emptyList());
ColumnSegment columnSegment = createColumnSegment(null, "COL");
- Map<String, String> actual = new TablesContext(Arrays.asList(tableSegment1, tableSegment2), databaseType, "foo_db").findTableNames(Collections.singletonList(columnSegment), schema);
+ Map<String, String> actual = new TablesContext(Arrays.asList(tableSegment1, tableSegment2)).findTableNames(Collections.singletonList(columnSegment), schema);
assertFalse(actual.isEmpty());
assertThat(actual.get("col"), is("TABLE_1"));
}
- private SimpleTableSegment createTableSegment(final String tableName, final String alias) {
- SimpleTableSegment result = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue(tableName)));
+ private SimpleTableSegment createTableSegment(final String tableName, final String alias, final String databaseName) {
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue(tableName));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue(databaseName), new IdentifierValue(databaseName)));
+ SimpleTableSegment result = new SimpleTableSegment(tableNameSegment);
AliasSegment aliasSegment = new AliasSegment(0, 0, new IdentifierValue(alias));
result.setAlias(aliasSegment);
return result;
@@ -148,51 +149,51 @@ class TablesContextTest {
@Test
void assertGetSchemaNameWithSameSchemaAndSameTable() {
- SimpleTableSegment tableSegment1 = createTableSegment("table_1", "tbl_1");
+ SimpleTableSegment tableSegment1 = createTableSegment("table_1", "tbl_1", "sharding_db_1");
tableSegment1.setOwner(new OwnerSegment(0, 0, new IdentifierValue("sharding_db_1")));
- SimpleTableSegment tableSegment2 = createTableSegment("table_1", "tbl_1");
+ SimpleTableSegment tableSegment2 = createTableSegment("table_1", "tbl_1", "sharding_db_1");
tableSegment2.setOwner(new OwnerSegment(0, 0, new IdentifierValue("sharding_db_1")));
- TablesContext tablesContext = new TablesContext(Arrays.asList(tableSegment1, tableSegment2), databaseType, "foo_db");
+ TablesContext tablesContext = new TablesContext(Arrays.asList(tableSegment1, tableSegment2));
assertTrue(tablesContext.getDatabaseName().isPresent());
assertThat(tablesContext.getDatabaseName().get(), is("sharding_db_1"));
}
@Test
void assertGetSchemaNameWithSameSchemaAndDifferentTable() {
- SimpleTableSegment tableSegment1 = createTableSegment("table_1", "tbl_1");
+ SimpleTableSegment tableSegment1 = createTableSegment("table_1", "tbl_1", "sharding_db_1");
tableSegment1.setOwner(new OwnerSegment(0, 0, new IdentifierValue("sharding_db_1")));
- SimpleTableSegment tableSegment2 = createTableSegment("table_2", "tbl_2");
+ SimpleTableSegment tableSegment2 = createTableSegment("table_2", "tbl_2", "sharding_db_1");
tableSegment2.setOwner(new OwnerSegment(0, 0, new IdentifierValue("sharding_db_1")));
- TablesContext tablesContext = new TablesContext(Arrays.asList(tableSegment1, tableSegment2), databaseType, "foo_db");
+ TablesContext tablesContext = new TablesContext(Arrays.asList(tableSegment1, tableSegment2));
assertTrue(tablesContext.getDatabaseName().isPresent());
assertThat(tablesContext.getDatabaseName().get(), is("sharding_db_1"));
}
@Test
void assertGetSchemaNameWithDifferentSchemaAndSameTable() {
- SimpleTableSegment tableSegment1 = createTableSegment("table_1", "tbl_1");
+ SimpleTableSegment tableSegment1 = createTableSegment("table_1", "tbl_1", "sharding_db_1");
tableSegment1.setOwner(new OwnerSegment(0, 0, new IdentifierValue("sharding_db_1")));
- SimpleTableSegment tableSegment2 = createTableSegment("table_1", "tbl_1");
+ SimpleTableSegment tableSegment2 = createTableSegment("table_1", "tbl_1", "sharding_db_2");
tableSegment2.setOwner(new OwnerSegment(0, 0, new IdentifierValue("sharding_db_2")));
- assertThrows(IllegalStateException.class, () -> new TablesContext(Arrays.asList(tableSegment1, tableSegment2), databaseType, "foo_db").getDatabaseName());
+ assertThrows(IllegalStateException.class, () -> new TablesContext(Arrays.asList(tableSegment1, tableSegment2)).getDatabaseName());
}
@Test
void assertGetSchemaNameWithDifferentSchemaAndDifferentTable() {
- SimpleTableSegment tableSegment1 = createTableSegment("table_1", "tbl_1");
+ SimpleTableSegment tableSegment1 = createTableSegment("table_1", "tbl_1", "sharding_db_1");
tableSegment1.setOwner(new OwnerSegment(0, 0, new IdentifierValue("sharding_db_1")));
- SimpleTableSegment tableSegment2 = createTableSegment("table_2", "tbl_2");
+ SimpleTableSegment tableSegment2 = createTableSegment("table_2", "tbl_2", "sharding_db_2");
tableSegment2.setOwner(new OwnerSegment(0, 0, new IdentifierValue("sharding_db_2")));
- assertThrows(IllegalStateException.class, () -> new TablesContext(Arrays.asList(tableSegment1, tableSegment2), databaseType, "foo_db").getDatabaseName());
+ assertThrows(IllegalStateException.class, () -> new TablesContext(Arrays.asList(tableSegment1, tableSegment2)).getDatabaseName());
}
@Test
void assertGetSchemaName() {
- SimpleTableSegment tableSegment1 = createTableSegment("table_1", "tbl_1");
+ SimpleTableSegment tableSegment1 = createTableSegment("table_1", "tbl_1", "sharding_db_1");
tableSegment1.setOwner(new OwnerSegment(0, 0, new IdentifierValue("sharding_db_1")));
- SimpleTableSegment tableSegment2 = createTableSegment("table_2", "tbl_2");
+ SimpleTableSegment tableSegment2 = createTableSegment("table_2", "tbl_2", "sharding_db_1");
tableSegment2.setOwner(new OwnerSegment(0, 0, new IdentifierValue("sharding_db_1")));
- TablesContext tablesContext = new TablesContext(Arrays.asList(tableSegment1, tableSegment2), databaseType, "foo_db");
+ TablesContext tablesContext = new TablesContext(Arrays.asList(tableSegment1, tableSegment2));
assertTrue(tablesContext.getSchemaName().isPresent());
assertThat(tablesContext.getSchemaName().get(), is("sharding_db_1"));
}
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dal/AnalyzeTableStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dal/AnalyzeTableStatementContextTest.java
index b7a3b7c3032..c1df0eb15ad 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dal/AnalyzeTableStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dal/AnalyzeTableStatementContextTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.infra.binder.context.statement.dal;
import org.apache.shardingsphere.infra.binder.context.statement.CommonSQLStatementContext;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.AnalyzeTableStatement;
@@ -36,7 +37,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
class AnalyzeTableStatementContextTest {
@Test
- void assertMysqlNewInstance() {
+ void assertMySQLNewInstance() {
assertNewInstance(new MySQLAnalyzeTableStatement());
}
@@ -46,10 +47,14 @@ class AnalyzeTableStatementContextTest {
}
private void assertNewInstance(final AnalyzeTableStatement analyzeTableStatement) {
- SimpleTableSegment table1 = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("tbl_1")));
- SimpleTableSegment table2 = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("tbl_2")));
+ TableNameSegment tableNameSegment1 = new TableNameSegment(0, 0, new IdentifierValue("tbl_1"));
+ tableNameSegment1.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ TableNameSegment tableNameSegment2 = new TableNameSegment(0, 0, new IdentifierValue("tbl_2"));
+ tableNameSegment2.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ SimpleTableSegment table1 = new SimpleTableSegment(tableNameSegment1);
+ SimpleTableSegment table2 = new SimpleTableSegment(tableNameSegment2);
analyzeTableStatement.getTables().addAll(Arrays.asList(table1, table2));
- AnalyzeTableStatementContext actual = new AnalyzeTableStatementContext(analyzeTableStatement, "foo_db");
+ AnalyzeTableStatementContext actual = new AnalyzeTableStatementContext(analyzeTableStatement);
assertThat(actual, instanceOf(CommonSQLStatementContext.class));
assertThat(actual.getSqlStatement(), is(analyzeTableStatement));
assertThat(actual.getTablesContext().getSimpleTables().stream().map(each -> each.getTableName().getIdentifier().getValue()).collect(Collectors.toList()), is(Arrays.asList("tbl_1", "tbl_2")));
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ExplainStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ExplainStatementContextTest.java
index fda4d10df6e..76b7dc2f309 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ExplainStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ExplainStatementContextTest.java
@@ -48,7 +48,7 @@ class ExplainStatementContextTest {
private void assertNewInstance(final ExplainStatement explainStatement) {
SQLStatement statement = mock(SQLStatement.class);
when(explainStatement.getSqlStatement()).thenReturn(Optional.of(statement));
- ExplainStatementContext actual = new ExplainStatementContext(explainStatement, "foo_db");
+ ExplainStatementContext actual = new ExplainStatementContext(explainStatement);
assertThat(actual, instanceOf(CommonSQLStatementContext.class));
assertThat(actual.getSqlStatement(), is(explainStatement));
assertThat(actual.getSqlStatement().getSqlStatement().orElse(null), is(statement));
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dal/OptimizeTableStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dal/OptimizeTableStatementContextTest.java
index 8fb44f8d550..3e6576d9b27 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dal/OptimizeTableStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dal/OptimizeTableStatementContextTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.infra.binder.context.statement.dal;
import org.apache.shardingsphere.infra.binder.context.statement.CommonSQLStatementContext;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
import org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue;
@@ -36,8 +37,10 @@ class OptimizeTableStatementContextTest {
@Test
void assertNewInstance() {
MySQLOptimizeTableStatement sqlStatement = new MySQLOptimizeTableStatement();
- sqlStatement.getTables().add(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("tbl_1"))));
- OptimizeTableStatementContext actual = new OptimizeTableStatementContext(sqlStatement, "foo_db");
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("tbl_1"));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ sqlStatement.getTables().add(new SimpleTableSegment(tableNameSegment));
+ OptimizeTableStatementContext actual = new OptimizeTableStatementContext(sqlStatement);
assertThat(actual, instanceOf(CommonSQLStatementContext.class));
assertThat(actual.getSqlStatement(), is(sqlStatement));
assertThat(actual.getTablesContext().getSimpleTables().stream().map(each -> each.getTableName().getIdentifier().getValue()).collect(Collectors.toList()),
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ShowColumnsStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ShowColumnsStatementContextTest.java
index 35bbd289fdc..5fb7bc6768e 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ShowColumnsStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ShowColumnsStatementContextTest.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.infra.binder.context.statement.dal;
import org.apache.shardingsphere.infra.binder.context.statement.CommonSQLStatementContext;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dal.FromDatabaseSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.DatabaseSegment;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
import org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue;
@@ -38,10 +39,12 @@ class ShowColumnsStatementContextTest {
@Test
void assertNewInstance() {
MySQLShowColumnsStatement sqlStatement = new MySQLShowColumnsStatement();
- sqlStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("foo_tbl"))));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("foo_tbl"));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ sqlStatement.setTable(new SimpleTableSegment(tableNameSegment));
FromDatabaseSegment fromDatabase = new FromDatabaseSegment(0, 0, new DatabaseSegment(0, 0, new IdentifierValue("foo_db")));
sqlStatement.setFromDatabase(fromDatabase);
- ShowColumnsStatementContext actual = new ShowColumnsStatementContext(sqlStatement, "foo_db");
+ ShowColumnsStatementContext actual = new ShowColumnsStatementContext(sqlStatement);
assertThat(actual, instanceOf(CommonSQLStatementContext.class));
assertThat(actual.getSqlStatement(), is(sqlStatement));
assertThat(actual.getTablesContext().getSimpleTables().stream().map(each -> each.getTableName().getIdentifier().getValue()).collect(Collectors.toList()),
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ShowCreateTableStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ShowCreateTableStatementContextTest.java
index 8495b3f0778..9eb20175d89 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ShowCreateTableStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ShowCreateTableStatementContextTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.infra.binder.context.statement.dal;
import org.apache.shardingsphere.infra.binder.context.statement.CommonSQLStatementContext;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
import org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue;
@@ -36,8 +37,10 @@ class ShowCreateTableStatementContextTest {
@Test
void assertNewInstance() {
MySQLShowCreateTableStatement sqlStatement = new MySQLShowCreateTableStatement();
- sqlStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("foo_tbl"))));
- ShowCreateTableStatementContext actual = new ShowCreateTableStatementContext(sqlStatement, "foo_db");
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("foo_tbl"));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ sqlStatement.setTable(new SimpleTableSegment(tableNameSegment));
+ ShowCreateTableStatementContext actual = new ShowCreateTableStatementContext(sqlStatement);
assertThat(actual, instanceOf(CommonSQLStatementContext.class));
assertThat(actual.getSqlStatement(), is(sqlStatement));
assertThat(actual.getTablesContext().getSimpleTables().stream().map(each -> each.getTableName().getIdentifier().getValue()).collect(Collectors.toList()),
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ShowIndexStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ShowIndexStatementContextTest.java
index 602ebb2c4e9..0893b896fde 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ShowIndexStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dal/ShowIndexStatementContextTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.infra.binder.context.statement.dal;
import org.apache.shardingsphere.infra.binder.context.statement.CommonSQLStatementContext;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
import org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue;
@@ -36,8 +37,10 @@ class ShowIndexStatementContextTest {
@Test
void assertNewInstance() {
MySQLShowIndexStatement sqlStatement = new MySQLShowIndexStatement();
- sqlStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("foo_tbl"))));
- ShowIndexStatementContext actual = new ShowIndexStatementContext(sqlStatement, "foo_db");
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("foo_tbl"));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ sqlStatement.setTable(new SimpleTableSegment(tableNameSegment));
+ ShowIndexStatementContext actual = new ShowIndexStatementContext(sqlStatement);
assertThat(actual, instanceOf(CommonSQLStatementContext.class));
assertThat(actual.getSqlStatement(), is(sqlStatement));
assertThat(actual.getTablesContext().getSimpleTables().stream().map(each -> each.getTableName().getIdentifier().getValue()).collect(Collectors.toList()),
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dcl/DenyUserStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dcl/DenyUserStatementContextTest.java
index ad7f4fabda4..bbd448dc87f 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dcl/DenyUserStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dcl/DenyUserStatementContextTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.infra.binder.context.statement.dcl;
import org.apache.shardingsphere.infra.binder.context.statement.CommonSQLStatementContext;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
import org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue;
@@ -36,9 +37,11 @@ class DenyUserStatementContextTest {
@Test
void assertNewInstance() {
SQLServerDenyUserStatement sqlStatement = new SQLServerDenyUserStatement();
- SimpleTableSegment table = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("foo_tbl")));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("foo_tbl"));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ SimpleTableSegment table = new SimpleTableSegment(tableNameSegment);
sqlStatement.setTable(table);
- DenyUserStatementContext actual = new DenyUserStatementContext(sqlStatement, "foo_db");
+ DenyUserStatementContext actual = new DenyUserStatementContext(sqlStatement);
assertThat(actual, instanceOf(CommonSQLStatementContext.class));
assertThat(actual.getSqlStatement(), is(sqlStatement));
assertThat(actual.getTablesContext().getSimpleTables().stream().map(each -> each.getTableName().getIdentifier().getValue()).collect(Collectors.toList()),
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dcl/GrantStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dcl/GrantStatementContextTest.java
index 08f0b286cae..5d52f83f749 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dcl/GrantStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dcl/GrantStatementContextTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.infra.binder.context.statement.dcl;
import org.apache.shardingsphere.infra.binder.context.statement.CommonSQLStatementContext;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dcl.GrantStatement;
@@ -64,10 +65,14 @@ class GrantStatementContextTest {
}
private void assertNewInstance(final GrantStatement grantStatement) {
- SimpleTableSegment table1 = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("foo_tbl")));
- SimpleTableSegment table2 = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("bar_tbl")));
+ TableNameSegment tableNameSegment1 = new TableNameSegment(0, 0, new IdentifierValue("foo_tbl"));
+ tableNameSegment1.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ TableNameSegment tableNameSegment2 = new TableNameSegment(0, 0, new IdentifierValue("bar_tbl"));
+ tableNameSegment2.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ SimpleTableSegment table1 = new SimpleTableSegment(tableNameSegment1);
+ SimpleTableSegment table2 = new SimpleTableSegment(tableNameSegment2);
grantStatement.getTables().addAll(Arrays.asList(table1, table2));
- GrantStatementContext actual = new GrantStatementContext(grantStatement, "foo_db");
+ GrantStatementContext actual = new GrantStatementContext(grantStatement);
assertThat(actual, instanceOf(CommonSQLStatementContext.class));
assertThat(actual.getSqlStatement(), is(grantStatement));
assertThat(actual.getTablesContext().getSimpleTables().stream().map(each -> each.getTableName().getIdentifier().getValue()).collect(Collectors.toList()),
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dcl/RevokeStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dcl/RevokeStatementContextTest.java
index af3f91c127f..b8a18d75a37 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dcl/RevokeStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dcl/RevokeStatementContextTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.infra.binder.context.statement.dcl;
import org.apache.shardingsphere.infra.binder.context.statement.CommonSQLStatementContext;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dcl.RevokeStatement;
@@ -64,10 +65,14 @@ class RevokeStatementContextTest {
}
private void assertNewInstance(final RevokeStatement revokeStatement) {
- SimpleTableSegment table1 = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("foo_tbl")));
- SimpleTableSegment table2 = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("bar_tbl")));
+ TableNameSegment tableNameSegment1 = new TableNameSegment(0, 0, new IdentifierValue("foo_tbl"));
+ tableNameSegment1.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ TableNameSegment tableNameSegment2 = new TableNameSegment(0, 0, new IdentifierValue("bar_tbl"));
+ tableNameSegment2.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ SimpleTableSegment table1 = new SimpleTableSegment(tableNameSegment1);
+ SimpleTableSegment table2 = new SimpleTableSegment(tableNameSegment2);
revokeStatement.getTables().addAll(Arrays.asList(table1, table2));
- RevokeStatementContext actual = new RevokeStatementContext(revokeStatement, "foo_db");
+ RevokeStatementContext actual = new RevokeStatementContext(revokeStatement);
assertThat(actual, instanceOf(CommonSQLStatementContext.class));
assertThat(actual.getSqlStatement(), is(revokeStatement));
assertThat(actual.getTablesContext().getSimpleTables().stream().map(each -> each.getTableName().getIdentifier().getValue()).collect(Collectors.toList()),
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/AlterIndexStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/AlterIndexStatementContextTest.java
index 3ffcca418e5..dddcf50d788 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/AlterIndexStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/AlterIndexStatementContextTest.java
@@ -57,7 +57,7 @@ class AlterIndexStatementContextTest {
private void assertNewInstance(final AlterIndexStatement alterIndexStatement) {
IndexSegment indexSegment = new IndexSegment(0, 0, new IndexNameSegment(0, 0, new IdentifierValue("index_1")));
when(alterIndexStatement.getIndex()).thenReturn(Optional.of(indexSegment));
- AlterIndexStatementContext actual = new AlterIndexStatementContext(alterIndexStatement, "foo_db");
+ AlterIndexStatementContext actual = new AlterIndexStatementContext(alterIndexStatement);
assertThat(actual, instanceOf(CommonSQLStatementContext.class));
assertThat(actual.getSqlStatement(), is(alterIndexStatement));
assertThat(actual.getTablesContext().getSimpleTables().stream().map(each -> each.getTableName().getIdentifier().getValue()).collect(Collectors.toList()), is(Collections.emptyList()));
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/AlterTableStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/AlterTableStatementContextTest.java
index 8567b81cd23..945ef575558 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/AlterTableStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/AlterTableStatementContextTest.java
@@ -29,6 +29,7 @@ import org.apache.shardingsphere.sql.parser.statement.core.segment.ddl.constrain
import org.apache.shardingsphere.sql.parser.statement.core.segment.ddl.index.DropIndexDefinitionSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.ddl.index.IndexNameSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.ddl.index.IndexSegment;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.AlterTableStatement;
@@ -80,8 +81,12 @@ class AlterTableStatementContextTest {
}
private void assertNewInstance(final AlterTableStatement alterTableStatement) {
- SimpleTableSegment table = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("tbl_1")));
- SimpleTableSegment renameTable = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("rename_tbl_1")));
+ TableNameSegment tableNameSegment1 = new TableNameSegment(0, 0, new IdentifierValue("tbl_1"));
+ tableNameSegment1.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ TableNameSegment tableNameSegment2 = new TableNameSegment(0, 0, new IdentifierValue("rename_tbl_1"));
+ tableNameSegment2.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ SimpleTableSegment table = new SimpleTableSegment(tableNameSegment1);
+ SimpleTableSegment renameTable = new SimpleTableSegment(tableNameSegment2);
alterTableStatement.setTable(table);
alterTableStatement.setRenameTable(renameTable);
Collection<SimpleTableSegment> referencedTables = Collections.singletonList(table);
@@ -110,7 +115,7 @@ class AlterTableStatementContextTest {
DropIndexDefinitionSegment dropIndexDefinitionSegment = mock(DropIndexDefinitionSegment.class);
when(dropIndexDefinitionSegment.getIndexSegment()).thenReturn(new IndexSegment(0, 0, new IndexNameSegment(0, 0, new IdentifierValue("drop_index"))));
alterTableStatement.getDropIndexDefinitions().add(dropIndexDefinitionSegment);
- AlterTableStatementContext actual = new AlterTableStatementContext(alterTableStatement, "foo_db");
+ AlterTableStatementContext actual = new AlterTableStatementContext(alterTableStatement);
assertThat(actual, instanceOf(CommonSQLStatementContext.class));
assertThat(actual.getSqlStatement(), is(alterTableStatement));
assertThat(actual.getTablesContext().getSimpleTables().stream().map(each -> each.getTableName().getIdentifier().getValue()).collect(Collectors.toList()),
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/AlterViewStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/AlterViewStatementContextTest.java
index 1da87742c07..0feea9fbedd 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/AlterViewStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/AlterViewStatementContextTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.infra.binder.context.statement.ddl;
import org.apache.shardingsphere.infra.binder.context.statement.CommonSQLStatementContext;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.AlterViewStatement;
@@ -43,7 +44,9 @@ class AlterViewStatementContextTest {
@BeforeEach
void setUp() {
- view = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("view")));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("view"));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ view = new SimpleTableSegment(tableNameSegment);
}
@Test
@@ -60,12 +63,14 @@ class AlterViewStatementContextTest {
void assertPostgreSQLNewInstance() {
PostgreSQLAlterViewStatement alterViewStatement = new PostgreSQLAlterViewStatement();
alterViewStatement.setView(view);
- alterViewStatement.setRenameView(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("view"))));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("view"));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ alterViewStatement.setRenameView(new SimpleTableSegment(tableNameSegment));
assertNewInstance(alterViewStatement);
}
private void assertNewInstance(final AlterViewStatement alterViewStatement) {
- AlterViewStatementContext actual = new AlterViewStatementContext(alterViewStatement, "foo_db");
+ AlterViewStatementContext actual = new AlterViewStatementContext(alterViewStatement);
assertThat(actual, instanceOf(CommonSQLStatementContext.class));
assertThat(actual.getSqlStatement(), is(alterViewStatement));
assertThat(actual.getTablesContext().getSimpleTables().size(), is(2));
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateFunctionStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateFunctionStatementContextTest.java
index 3a35101c123..59460281348 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateFunctionStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateFunctionStatementContextTest.java
@@ -47,7 +47,7 @@ class CreateFunctionStatementContextTest {
}
private void assertNewInstance(final CreateFunctionStatement createDatabaseStatement) {
- CreateFunctionStatementContext actual = new CreateFunctionStatementContext(createDatabaseStatement, "foo_db");
+ CreateFunctionStatementContext actual = new CreateFunctionStatementContext(createDatabaseStatement);
assertThat(actual, instanceOf(CommonSQLStatementContext.class));
assertThat(actual.getSqlStatement(), is(createDatabaseStatement));
}
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateIndexStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateIndexStatementContextTest.java
index 93af84f0b56..e162431b566 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateIndexStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateIndexStatementContextTest.java
@@ -61,14 +61,14 @@ class CreateIndexStatementContextTest {
}
private void assertNewInstance(final CreateIndexStatement createIndexStatement) {
- CreateIndexStatementContext actual = new CreateIndexStatementContext(createIndexStatement, "foo_db");
+ CreateIndexStatementContext actual = new CreateIndexStatementContext(createIndexStatement);
assertThat(actual, instanceOf(CommonSQLStatementContext.class));
assertThat(actual.getSqlStatement(), is(createIndexStatement));
assertTrue(actual.isGeneratedIndex());
assertThat(actual.getTablesContext().getSimpleTables(), is(Collections.emptyList()));
assertThat(actual.getIndexes(), is(Collections.emptyList()));
when(createIndexStatement.getIndex()).thenReturn(new IndexSegment(0, 0, new IndexNameSegment(0, 0, new IdentifierValue("index_2"))));
- CreateIndexStatementContext actual2 = new CreateIndexStatementContext(createIndexStatement, "foo_db");
+ CreateIndexStatementContext actual2 = new CreateIndexStatementContext(createIndexStatement);
assertThat(actual2.getIndexes().stream().map(each -> each.getIndexName().getIdentifier().getValue()).collect(Collectors.toList()), is(Collections.singletonList("index_2")));
}
}
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateProcedureStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateProcedureStatementContextTest.java
index 3c57c0e7ad7..15af5fd7d38 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateProcedureStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateProcedureStatementContextTest.java
@@ -41,7 +41,7 @@ class CreateProcedureStatementContextTest {
}
private void assertNewInstance(final CreateProcedureStatement createProcedureStatement) {
- CreateProcedureStatementContext actual = new CreateProcedureStatementContext(createProcedureStatement, "foo_db");
+ CreateProcedureStatementContext actual = new CreateProcedureStatementContext(createProcedureStatement);
assertThat(actual, instanceOf(CommonSQLStatementContext.class));
assertThat(actual.getSqlStatement(), is(createProcedureStatement));
}
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateTableStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateTableStatementContextTest.java
index b6acd3c6703..9f256f9c933 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateTableStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateTableStatementContextTest.java
@@ -73,7 +73,7 @@ class CreateTableStatementContextTest {
}
private void assertNewInstance(final CreateTableStatement createTableStatement) {
- CreateTableStatementContext actual = new CreateTableStatementContext(createTableStatement, "foo_db");
+ CreateTableStatementContext actual = new CreateTableStatementContext(createTableStatement);
SimpleTableSegment table = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("tbl_1")));
when(createTableStatement.getTable()).thenReturn(table);
assertThat(actual, instanceOf(CommonSQLStatementContext.class));
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateViewStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateViewStatementContextTest.java
index cd584254ea5..5a59b58cc00 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateViewStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/CreateViewStatementContextTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.infra.binder.context.statement.ddl;
import org.apache.shardingsphere.infra.binder.context.statement.CommonSQLStatementContext;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.CreateViewStatement;
@@ -45,10 +46,12 @@ class CreateViewStatementContextTest {
}
private void assertNewInstance(final CreateViewStatement createViewStatement) {
- SimpleTableSegment view = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("view")));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("view"));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ SimpleTableSegment view = new SimpleTableSegment(tableNameSegment);
createViewStatement.setView(view);
createViewStatement.setSelect(mock(SelectStatement.class));
- CreateViewStatementContext actual = new CreateViewStatementContext(createViewStatement, "foo_db");
+ CreateViewStatementContext actual = new CreateViewStatementContext(createViewStatement);
assertThat(actual, instanceOf(CommonSQLStatementContext.class));
assertThat(actual.getSqlStatement(), is(createViewStatement));
}
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/DropIndexStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/DropIndexStatementContextTest.java
index 59459297a06..30f88aa9eae 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/DropIndexStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/DropIndexStatementContextTest.java
@@ -69,7 +69,7 @@ class DropIndexStatementContextTest {
indexes.add(index1);
indexes.add(index2);
when(dropIndexStatement.getIndexes()).thenReturn(indexes);
- DropIndexStatementContext actual = new DropIndexStatementContext(dropIndexStatement, "foo_db");
+ DropIndexStatementContext actual = new DropIndexStatementContext(dropIndexStatement);
assertThat(actual, instanceOf(CommonSQLStatementContext.class));
assertThat(actual.getSqlStatement(), is(dropIndexStatement));
assertThat(actual.getTablesContext().getSimpleTables(), is(Collections.emptyList()));
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/DropTableStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/DropTableStatementContextTest.java
index 0fe7f4e2f01..54104522fae 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/DropTableStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/DropTableStatementContextTest.java
@@ -65,7 +65,7 @@ class DropTableStatementContextTest {
}
private void assertNewInstance(final DropTableStatement dropTableStatement) {
- DropTableStatementContext actual = new DropTableStatementContext(dropTableStatement, "foo_db");
+ DropTableStatementContext actual = new DropTableStatementContext(dropTableStatement);
SimpleTableSegment table1 = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("tbl_1")));
SimpleTableSegment table2 = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("tbl_2")));
when(dropTableStatement.getTables()).thenReturn(Arrays.asList(table1, table2));
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/DropViewStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/DropViewStatementContextTest.java
index 068deaee097..cdc1720e1be 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/DropViewStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/DropViewStatementContextTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.infra.binder.context.statement.ddl;
import org.apache.shardingsphere.infra.binder.context.statement.CommonSQLStatementContext;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.DropViewStatement;
@@ -45,10 +46,14 @@ class DropViewStatementContextTest {
}
private void assertNewInstance(final DropViewStatement dropViewStatement) {
- SimpleTableSegment table1 = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("tbl_1")));
- SimpleTableSegment table2 = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("tbl_2")));
+ TableNameSegment tableNameSegment1 = new TableNameSegment(0, 0, new IdentifierValue("tbl_1"));
+ tableNameSegment1.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ TableNameSegment tableNameSegment2 = new TableNameSegment(0, 0, new IdentifierValue("tbl_2"));
+ tableNameSegment2.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ SimpleTableSegment table1 = new SimpleTableSegment(tableNameSegment1);
+ SimpleTableSegment table2 = new SimpleTableSegment(tableNameSegment2);
dropViewStatement.getViews().addAll(Arrays.asList(table1, table2));
- DropViewStatementContext actual = new DropViewStatementContext(dropViewStatement, "foo_db");
+ DropViewStatementContext actual = new DropViewStatementContext(dropViewStatement);
assertThat(actual, instanceOf(CommonSQLStatementContext.class));
assertThat(actual.getSqlStatement(), is(dropViewStatement));
}
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/PrepareStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/PrepareStatementContextTest.java
index 5f85b0745eb..4b32d861ac8 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/PrepareStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/PrepareStatementContextTest.java
@@ -21,6 +21,7 @@ import org.apache.shardingsphere.infra.binder.context.statement.CommonSQLStateme
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.assignment.ColumnAssignmentSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.assignment.SetAssignmentSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.column.ColumnSegment;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dml.DeleteStatement;
@@ -52,7 +53,9 @@ class PrepareStatementContextTest {
@BeforeEach
void setUp() {
- table = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("tbl_1")));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("tbl_1"));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ table = new SimpleTableSegment(tableNameSegment);
column = new ColumnSegment(0, 0, new IdentifierValue("col_1"));
}
@@ -63,7 +66,7 @@ class PrepareStatementContextTest {
sqlStatement.setInsert(getInsert());
sqlStatement.setUpdate(getUpdate());
sqlStatement.setDelete(getDelete());
- PrepareStatementContext actual = new PrepareStatementContext(sqlStatement, "foo_db");
+ PrepareStatementContext actual = new PrepareStatementContext(sqlStatement);
assertThat(actual, instanceOf(CommonSQLStatementContext.class));
assertThat(actual.getSqlStatement(), is(sqlStatement));
assertThat(actual.getTablesContext().getSimpleTables().stream().map(each -> each.getTableName().getIdentifier().getValue()).collect(Collectors.toList()),
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/TruncateStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/TruncateStatementContextTest.java
index 6acd2a9bc56..8574372855e 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/TruncateStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/ddl/TruncateStatementContextTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.infra.binder.context.statement.ddl;
import org.apache.shardingsphere.infra.binder.context.statement.CommonSQLStatementContext;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.TruncateStatement;
@@ -58,10 +59,14 @@ class TruncateStatementContextTest {
}
private void assertNewInstance(final TruncateStatement truncateStatement) {
- SimpleTableSegment table1 = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("tbl_1")));
- SimpleTableSegment table2 = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("tbl_2")));
+ TableNameSegment tableNameSegment1 = new TableNameSegment(0, 0, new IdentifierValue("tbl_1"));
+ tableNameSegment1.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ TableNameSegment tableNameSegment2 = new TableNameSegment(0, 0, new IdentifierValue("tbl_2"));
+ tableNameSegment2.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ SimpleTableSegment table1 = new SimpleTableSegment(tableNameSegment1);
+ SimpleTableSegment table2 = new SimpleTableSegment(tableNameSegment2);
truncateStatement.getTables().addAll(Arrays.asList(table1, table2));
- TruncateStatementContext actual = new TruncateStatementContext(truncateStatement, "foo_db");
+ TruncateStatementContext actual = new TruncateStatementContext(truncateStatement);
assertThat(actual, instanceOf(CommonSQLStatementContext.class));
assertThat(actual.getSqlStatement(), is(truncateStatement));
assertThat(actual.getTablesContext().getSimpleTables().stream().map(each -> each.getTableName().getIdentifier().getValue()).collect(Collectors.toList()), is(Arrays.asList("tbl_1", "tbl_2")));
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dml/DeleteStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dml/DeleteStatementContextTest.java
index c010c6ada9c..1b828ebf4e3 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dml/DeleteStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dml/DeleteStatementContextTest.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.infra.binder.context.statement.dml;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.ExpressionSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.predicate.WhereSegment;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.JoinTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
@@ -77,14 +78,18 @@ class DeleteStatementContextTest {
private void assertNewInstance(final DeleteStatement deleteStatement) {
when(whereSegment.getExpr()).thenReturn(mock(ExpressionSegment.class));
- SimpleTableSegment table1 = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("tbl_1")));
- SimpleTableSegment table2 = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("tbl_2")));
+ TableNameSegment tableNameSegment1 = new TableNameSegment(0, 0, new IdentifierValue("tbl_1"));
+ tableNameSegment1.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ TableNameSegment tableNameSegment2 = new TableNameSegment(0, 0, new IdentifierValue("tbl_2"));
+ tableNameSegment2.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ SimpleTableSegment table1 = new SimpleTableSegment(tableNameSegment1);
+ SimpleTableSegment table2 = new SimpleTableSegment(tableNameSegment2);
JoinTableSegment tableSegment = new JoinTableSegment();
tableSegment.setLeft(table1);
tableSegment.setRight(table2);
deleteStatement.setWhere(whereSegment);
deleteStatement.setTable(tableSegment);
- DeleteStatementContext actual = new DeleteStatementContext(deleteStatement, "foo_db");
+ DeleteStatementContext actual = new DeleteStatementContext(deleteStatement);
assertThat(actual.getTablesContext().getTableNames(), is(new HashSet<>(Arrays.asList("tbl_1", "tbl_2"))));
assertThat(actual.getWhereSegments(), is(Collections.singletonList(whereSegment)));
assertThat(actual.getTablesContext().getSimpleTables().stream().map(each -> each.getTableName().getIdentifier().getValue()).collect(Collectors.toList()), is(Arrays.asList("tbl_1", "tbl_2")));
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dml/InsertStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dml/InsertStatementContextTest.java
index 0665b71acfe..17da31d5c80 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dml/InsertStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dml/InsertStatementContextTest.java
@@ -32,6 +32,7 @@ import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.simp
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.subquery.SubquerySegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.item.ProjectionsSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.OwnerSegment;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dml.InsertStatement;
@@ -92,7 +93,9 @@ class InsertStatementContextTest {
}
private void assertInsertStatementContextWithColumnNames(final InsertStatement insertStatement) {
- SimpleTableSegment tableSegment = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("tbl")));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("tbl"));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ SimpleTableSegment tableSegment = new SimpleTableSegment(tableNameSegment);
tableSegment.setOwner(new OwnerSegment(0, 0, new IdentifierValue("foo_db".toUpperCase())));
insertStatement.setTable(tableSegment);
InsertColumnsSegment insertColumnsSegment = new InsertColumnsSegment(0, 0, Arrays.asList(
@@ -125,7 +128,9 @@ class InsertStatementContextTest {
@Test
void assertInsertStatementContextWithoutColumnNames() {
InsertStatement insertStatement = new MySQLInsertStatement();
- insertStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("tbl"))));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("tbl"));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ insertStatement.setTable(new SimpleTableSegment(tableNameSegment));
setUpInsertValues(insertStatement);
InsertStatementContext actual = createInsertStatementContext(Arrays.asList(1, "Tom", 2, "Jerry"), insertStatement);
actual.setUpParameters(Arrays.asList(1, "Tom", 2, "Jerry"));
@@ -135,7 +140,9 @@ class InsertStatementContextTest {
@Test
void assertGetGroupedParametersWithoutOnDuplicateParameter() {
InsertStatement insertStatement = new MySQLInsertStatement();
- insertStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("tbl"))));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("tbl"));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ insertStatement.setTable(new SimpleTableSegment(tableNameSegment));
setUpInsertValues(insertStatement);
InsertStatementContext actual = createInsertStatementContext(Arrays.asList(1, "Tom", 2, "Jerry"), insertStatement);
actual.setUpParameters(Arrays.asList(1, "Tom", 2, "Jerry"));
@@ -147,7 +154,9 @@ class InsertStatementContextTest {
@Test
void assertGetGroupedParametersWithOnDuplicateParameters() {
MySQLInsertStatement insertStatement = new MySQLInsertStatement();
- insertStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("tbl"))));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("tbl"));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ insertStatement.setTable(new SimpleTableSegment(tableNameSegment));
setUpInsertValues(insertStatement);
setUpOnDuplicateValues(insertStatement);
InsertStatementContext actual = createInsertStatementContext(Arrays.asList(1, "Tom", 2, "Jerry", "onDuplicateKeyUpdateColumnValue"), insertStatement);
@@ -165,7 +174,9 @@ class InsertStatementContextTest {
selectStatement.setProjections(new ProjectionsSegment(0, 0));
SubquerySegment insertSelect = new SubquerySegment(0, 0, selectStatement, "");
insertStatement.setInsertSelect(insertSelect);
- insertStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("tbl"))));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("tbl"));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ insertStatement.setTable(new SimpleTableSegment(tableNameSegment));
InsertStatementContext actual = createInsertStatementContext(Collections.singletonList("param"), insertStatement);
actual.setUpParameters(Collections.singletonList("param"));
assertThat(actual.getInsertSelectContext().getParameterCount(), is(1));
@@ -246,7 +257,9 @@ class InsertStatementContextTest {
}
private void assertNotContainsInsertColumns(final InsertStatement insertStatement) {
- insertStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue(""))));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue(""));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ insertStatement.setTable(new SimpleTableSegment(tableNameSegment));
InsertStatementContext insertStatementContext = createInsertStatementContext(Collections.emptyList(), insertStatement);
assertFalse(insertStatementContext.containsInsertColumns());
}
@@ -279,7 +292,9 @@ class InsertStatementContextTest {
private void assertContainsInsertColumns(final InsertStatement insertStatement) {
InsertColumnsSegment insertColumnsSegment = new InsertColumnsSegment(0, 0, Collections.singletonList(new ColumnSegment(0, 0, new IdentifierValue("col"))));
insertStatement.setInsertColumns(insertColumnsSegment);
- insertStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue(""))));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue(""));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ insertStatement.setTable(new SimpleTableSegment(tableNameSegment));
InsertStatementContext insertStatementContext = createInsertStatementContext(Collections.emptyList(), insertStatement);
assertTrue(insertStatementContext.containsInsertColumns());
}
@@ -288,7 +303,9 @@ class InsertStatementContextTest {
void assertContainsInsertColumnsWithSetAssignmentForMySQL() {
MySQLInsertStatement insertStatement = new MySQLInsertStatement();
insertStatement.setSetAssignment(new SetAssignmentSegment(0, 0, Collections.emptyList()));
- insertStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue(""))));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue(""));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ insertStatement.setTable(new SimpleTableSegment(tableNameSegment));
InsertStatementContext insertStatementContext = createInsertStatementContext(Collections.emptyList(), insertStatement);
assertTrue(insertStatementContext.containsInsertColumns());
}
@@ -321,7 +338,9 @@ class InsertStatementContextTest {
private void assertGetValueListCountWithValues(final InsertStatement insertStatement) {
insertStatement.getValues().add(new InsertValuesSegment(0, 0, Collections.singletonList(new LiteralExpressionSegment(0, 0, 1))));
insertStatement.getValues().add(new InsertValuesSegment(0, 0, Collections.singletonList(new LiteralExpressionSegment(0, 0, 2))));
- insertStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue(""))));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue(""));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ insertStatement.setTable(new SimpleTableSegment(tableNameSegment));
InsertStatementContext insertStatementContext = createInsertStatementContext(Collections.emptyList(), insertStatement);
assertThat(insertStatementContext.getValueListCount(), is(2));
}
@@ -333,7 +352,9 @@ class InsertStatementContextTest {
columns.add(new ColumnSegment(0, 0, new IdentifierValue("col")));
ColumnAssignmentSegment insertStatementAssignment = new ColumnAssignmentSegment(0, 0, columns, new LiteralExpressionSegment(0, 0, 1));
insertStatement.setSetAssignment(new SetAssignmentSegment(0, 0, Collections.singletonList(insertStatementAssignment)));
- insertStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue(""))));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue(""));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ insertStatement.setTable(new SimpleTableSegment(tableNameSegment));
InsertStatementContext insertStatementContext = createInsertStatementContext(Collections.emptyList(), insertStatement);
assertThat(insertStatementContext.getValueListCount(), is(1));
}
@@ -366,7 +387,9 @@ class InsertStatementContextTest {
private void assertGetInsertColumnNamesForInsertColumns(final InsertStatement insertStatement) {
InsertColumnsSegment insertColumnsSegment = new InsertColumnsSegment(0, 0, Collections.singletonList(new ColumnSegment(0, 0, new IdentifierValue("col"))));
insertStatement.setInsertColumns(insertColumnsSegment);
- insertStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue(""))));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue(""));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ insertStatement.setTable(new SimpleTableSegment(tableNameSegment));
InsertStatementContext insertStatementContext = createInsertStatementContext(Collections.emptyList(), insertStatement);
List<String> columnNames = insertStatementContext.getInsertColumnNames();
assertThat(columnNames.size(), is(1));
@@ -380,7 +403,9 @@ class InsertStatementContextTest {
columns.add(new ColumnSegment(0, 0, new IdentifierValue("col")));
ColumnAssignmentSegment insertStatementAssignment = new ColumnAssignmentSegment(0, 0, columns, new LiteralExpressionSegment(0, 0, 1));
insertStatement.setSetAssignment(new SetAssignmentSegment(0, 0, Collections.singletonList(insertStatementAssignment)));
- insertStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue(""))));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue(""));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ insertStatement.setTable(new SimpleTableSegment(tableNameSegment));
InsertStatementContext insertStatementContext = createInsertStatementContext(Collections.emptyList(), insertStatement);
List<String> columnNames = insertStatementContext.getInsertColumnNames();
assertThat(columnNames.size(), is(1));
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dml/SelectStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dml/SelectStatementContextTest.java
index 54a25eb915a..2f4ebfcd27a 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dml/SelectStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dml/SelectStatementContextTest.java
@@ -48,6 +48,7 @@ import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.order.ite
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.predicate.WhereSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.AliasSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.OwnerSegment;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.JoinTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SubqueryTableSegment;
@@ -108,10 +109,12 @@ class SelectStatementContextTest {
}
private void assertSetIndexForItemsByIndexOrderBy(final SelectStatement selectStatement) {
- ShardingSphereDatabase database = mockDatabase();
selectStatement.setOrderBy(new OrderBySegment(0, 0, Collections.singletonList(createOrderByItemSegment(INDEX_ORDER_BY))));
selectStatement.setProjections(createProjectionsSegment());
- selectStatement.setFrom(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("table"))));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("table"));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ selectStatement.setFrom(new SimpleTableSegment(tableNameSegment));
+ ShardingSphereDatabase database = mockDatabase();
SelectStatementContext selectStatementContext =
new SelectStatementContext(createShardingSphereMetaData(database), Collections.emptyList(), selectStatement, "foo_db", Collections.emptyList());
selectStatementContext.setIndexes(Collections.emptyMap());
@@ -155,7 +158,9 @@ class SelectStatementContextTest {
private void assertSetIndexForItemsByColumnOrderByWithOwner(final SelectStatement selectStatement) {
selectStatement.setOrderBy(new OrderBySegment(0, 0, Collections.singletonList(createOrderByItemSegment(COLUMN_ORDER_BY_WITH_OWNER))));
selectStatement.setProjections(createProjectionsSegment());
- SimpleTableSegment tableSegment = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("table")));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("table"));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ SimpleTableSegment tableSegment = new SimpleTableSegment(tableNameSegment);
tableSegment.setOwner(new OwnerSegment(0, 0, new IdentifierValue("foo_db".toUpperCase())));
selectStatement.setFrom(tableSegment);
ShardingSphereDatabase database = mockDatabase();
@@ -591,7 +596,9 @@ class SelectStatementContextTest {
return new IndexOrderByItemSegment(0, 0, 4, OrderDirection.ASC, NullsOrderType.FIRST);
case COLUMN_ORDER_BY_WITH_OWNER:
ColumnSegment columnSegment = new ColumnSegment(0, 0, new IdentifierValue("name"));
- columnSegment.setOwner(new OwnerSegment(0, 0, new IdentifierValue("table")));
+ OwnerSegment owner = new OwnerSegment(0, 0, new IdentifierValue("table"));
+ owner.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ columnSegment.setOwner(owner);
return new ColumnOrderByItemSegment(columnSegment, OrderDirection.ASC, NullsOrderType.FIRST);
case COLUMN_ORDER_BY_WITH_ALIAS:
return new ColumnOrderByItemSegment(new ColumnSegment(0, 0, new IdentifierValue("n")), OrderDirection.ASC, NullsOrderType.FIRST);
@@ -601,16 +608,17 @@ class SelectStatementContextTest {
}
private ProjectionsSegment createProjectionsSegment() {
- ProjectionsSegment projectionsSegment = new ProjectionsSegment(0, 0);
- projectionsSegment.setDistinctRow(true);
- projectionsSegment.getProjections().addAll(Arrays.asList(getColumnProjectionSegmentWithoutOwner(),
- getColumnProjectionSegmentWithoutOwner(true), getColumnProjectionSegmentWithoutOwner(false)));
- return projectionsSegment;
+ ProjectionsSegment result = new ProjectionsSegment(0, 0);
+ result.setDistinctRow(true);
+ result.getProjections().addAll(Arrays.asList(getColumnProjectionSegmentWithoutOwner(), getColumnProjectionSegmentWithoutOwner(true), getColumnProjectionSegmentWithoutOwner(false)));
+ return result;
}
private ProjectionSegment getColumnProjectionSegmentWithoutOwner() {
ColumnSegment columnSegment = new ColumnSegment(0, 0, new IdentifierValue("name"));
- columnSegment.setOwner(new OwnerSegment(0, 0, new IdentifierValue("table")));
+ OwnerSegment owner = new OwnerSegment(0, 0, new IdentifierValue("table"));
+ owner.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ columnSegment.setOwner(owner);
return new ColumnProjectionSegment(columnSegment);
}
@@ -627,7 +635,9 @@ class SelectStatementContextTest {
projectionsSegment.getProjections().add(new ColumnProjectionSegment(new ColumnSegment(0, 0, new IdentifierValue("order_id"))));
SelectStatement selectStatement = new MySQLSelectStatement();
selectStatement.setProjections(projectionsSegment);
- selectStatement.setFrom(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order"))));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("t_order"));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ selectStatement.setFrom(new SimpleTableSegment(tableNameSegment));
ShardingSphereMetaData metaData = new ShardingSphereMetaData(
Collections.singleton(mockDatabase()), mock(ResourceMetaData.class), mock(RuleMetaData.class), mock(ConfigurationProperties.class));
SelectStatementContext actual = new SelectStatementContext(metaData, Collections.emptyList(), selectStatement, "foo_db", Collections.emptyList());
@@ -650,7 +660,9 @@ class SelectStatementContextTest {
projectionsSegment.getProjections().add(new ColumnProjectionSegment(new ColumnSegment(0, 0, new IdentifierValue("order_id"))));
SelectStatement result = new MySQLSelectStatement();
result.setProjections(projectionsSegment);
- result.setFrom(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order"))));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("t_order"));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ result.setFrom(new SimpleTableSegment(tableNameSegment));
return result;
}
}
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dml/UpdateStatementContextTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dml/UpdateStatementContextTest.java
index e9b80e88fdb..4420b6749c6 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dml/UpdateStatementContextTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dml/UpdateStatementContextTest.java
@@ -22,6 +22,7 @@ import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.column.Co
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.BinaryOperationExpression;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.predicate.WhereSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.OwnerSegment;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.JoinTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
@@ -54,11 +55,17 @@ class UpdateStatementContextTest {
@Test
void assertNewInstance() {
- when(columnSegment.getOwner()).thenReturn(Optional.of(new OwnerSegment(0, 0, new IdentifierValue("tbl_2"))));
+ OwnerSegment ownerSegment = new OwnerSegment(0, 0, new IdentifierValue("tbl_2"));
+ ownerSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ when(columnSegment.getOwner()).thenReturn(Optional.of(ownerSegment));
BinaryOperationExpression expression = new BinaryOperationExpression(0, 0, columnSegment, null, null, null);
when(whereSegment.getExpr()).thenReturn(expression);
- SimpleTableSegment table1 = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("tbl_1")));
- SimpleTableSegment table2 = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("tbl_2")));
+ TableNameSegment tableNameSegment1 = new TableNameSegment(0, 0, new IdentifierValue("tbl_1"));
+ tableNameSegment1.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ TableNameSegment tableNameSegment2 = new TableNameSegment(0, 0, new IdentifierValue("tbl_2"));
+ tableNameSegment2.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ SimpleTableSegment table1 = new SimpleTableSegment(tableNameSegment1);
+ SimpleTableSegment table2 = new SimpleTableSegment(tableNameSegment2);
JoinTableSegment joinTableSegment = new JoinTableSegment();
joinTableSegment.setLeft(table1);
joinTableSegment.setRight(table2);
@@ -66,7 +73,7 @@ class UpdateStatementContextTest {
updateStatement.setWhere(whereSegment);
updateStatement.setTable(joinTableSegment);
updateStatement.setSetAssignment(new SetAssignmentSegment(0, 0, Collections.emptyList()));
- UpdateStatementContext actual = new UpdateStatementContext(updateStatement, "foo_db");
+ UpdateStatementContext actual = new UpdateStatementContext(updateStatement);
assertThat(actual.getTablesContext().getTableNames(), is(new HashSet<>(Arrays.asList("tbl_1", "tbl_2"))));
assertThat(actual.getWhereSegments(), is(Collections.singletonList(whereSegment)));
assertThat(actual.getTablesContext().getSimpleTables().stream().map(each -> each.getTableName().getIdentifier().getValue()).collect(Collectors.toList()),
diff --git a/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessEngineTest.java b/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessEngineTest.java
index 149449f5e1a..88450ae0fbd 100644
--- a/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessEngineTest.java
+++ b/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessEngineTest.java
@@ -26,6 +26,7 @@ import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.session.connection.ConnectionContext;
import org.apache.shardingsphere.infra.session.query.QueryContext;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.assignment.SetAssignmentSegment;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
import org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue;
@@ -65,7 +66,7 @@ class ProcessEngineTest {
ShardingSphereMetaData metaData = mock(ShardingSphereMetaData.class);
ExecutionGroupContext<? extends SQLExecutionUnit> executionGroupContext = mockExecutionGroupContext();
new ProcessEngine().executeSQL(executionGroupContext,
- new QueryContext(new UpdateStatementContext(getSQLStatement(), "foo_db"), null, null, new HintValueContext(), connectionContext, metaData));
+ new QueryContext(new UpdateStatementContext(getSQLStatement()), null, null, new HintValueContext(), connectionContext, metaData));
verify(processRegistry).add(any());
}
@@ -80,7 +81,9 @@ class ProcessEngineTest {
private MySQLUpdateStatement getSQLStatement() {
MySQLUpdateStatement result = new MySQLUpdateStatement();
- result.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("foo_tbl"))));
+ TableNameSegment tableNameSegment = new TableNameSegment(0, 0, new IdentifierValue("foo_tbl"));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ result.setTable(new SimpleTableSegment(tableNameSegment));
result.setSetAssignment(new SetAssignmentSegment(0, 0, Collections.emptyList()));
return result;
}
diff --git a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/checker/sql/SingleDropTableSupportedCheckerTest.java b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/checker/sql/SingleDropTableSupportedCheckerTest.java
index a66b824cb2f..e4206b50d6b 100644
--- a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/checker/sql/SingleDropTableSupportedCheckerTest.java
+++ b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/checker/sql/SingleDropTableSupportedCheckerTest.java
@@ -67,6 +67,6 @@ class SingleDropTableSupportedCheckerTest {
PostgreSQLDropTableStatement dropSchemaStatement = mock(PostgreSQLDropTableStatement.class, RETURNS_DEEP_STUBS);
when(dropSchemaStatement.isContainsCascade()).thenReturn(containsCascade);
when(dropSchemaStatement.getTables()).thenReturn(Collections.emptyList());
- return new DropTableStatementContext(dropSchemaStatement, "foo_db");
+ return new DropTableStatementContext(dropSchemaStatement);
}
}
diff --git a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/route/SingleSQLRouterTest.java b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/route/SingleSQLRouterTest.java
index 4c39da84387..d14c60b38c4 100644
--- a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/route/SingleSQLRouterTest.java
+++ b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/route/SingleSQLRouterTest.java
@@ -42,6 +42,7 @@ import org.apache.shardingsphere.infra.session.query.QueryContext;
import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader;
import org.apache.shardingsphere.single.config.SingleRuleConfiguration;
import org.apache.shardingsphere.single.rule.SingleRule;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.CreateTableStatement;
@@ -215,13 +216,14 @@ class SingleSQLRouterTest {
private QueryContext createQueryContext() {
CreateTableStatement createTableStatement = new MySQLCreateTableStatement(false);
- createTableStatement.setTable(new SimpleTableSegment(new TableNameSegment(1, 2, new IdentifierValue("t_order"))));
+ TableNameSegment tableNameSegment = new TableNameSegment(1, 2, new IdentifierValue("t_order"));
+ tableNameSegment.setTableBoundInfo(new TableSegmentBoundInfo(new IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
+ createTableStatement.setTable(new SimpleTableSegment(tableNameSegment));
ConnectionContext connectionContext = mock(ConnectionContext.class);
when(connectionContext.getCurrentDatabaseName()).thenReturn(Optional.of("foo_db"));
ShardingSphereMetaData metaData = mock(ShardingSphereMetaData.class);
when(metaData.containsDatabase("foo_db")).thenReturn(true);
when(metaData.getDatabase("foo_db")).thenReturn(mock(ShardingSphereDatabase.class));
- return new QueryContext(new CreateTableStatementContext(createTableStatement, "foo_db"), "CREATE TABLE", new LinkedList<>(), new HintValueContext(), connectionContext,
- metaData);
+ return new QueryContext(new CreateTableStatementContext(createTableStatement), "CREATE TABLE", new LinkedList<>(), new HintValueContext(), connectionContext, metaData);
}
}
diff --git a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/extractor/TableExtractor.java b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/extractor/TableExtractor.java
index 7b3ae07a2b0..310f2238af6 100644
--- a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/extractor/TableExtractor.java
+++ b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/extractor/TableExtractor.java
@@ -225,7 +225,9 @@ public final class TableExtractor {
}
private SimpleTableSegment createSimpleTableSegment(final OwnerSegment ownerSegment) {
- SimpleTableSegment result = new SimpleTableSegment(new TableNameSegment(ownerSegment.getStartIndex(), ownerSegment.getStopIndex(), ownerSegment.getIdentifier()));
+ TableNameSegment tableNameSegment = new TableNameSegment(ownerSegment.getStartIndex(), ownerSegment.getStopIndex(), ownerSegment.getIdentifier());
+ ownerSegment.getTableBoundInfo().ifPresent(tableNameSegment::setTableBoundInfo);
+ SimpleTableSegment result = new SimpleTableSegment(tableNameSegment);
ownerSegment.getOwner().ifPresent(result::setOwner);
return result;
}
@@ -235,7 +237,9 @@ public final class TableExtractor {
if (each instanceof ColumnOrderByItemSegment) {
Optional<OwnerSegment> owner = ((ColumnOrderByItemSegment) each).getColumn().getOwner();
if (owner.isPresent() && needRewrite(owner.get())) {
- rewriteTables.add(new SimpleTableSegment(new TableNameSegment(owner.get().getStartIndex(), owner.get().getStopIndex(), owner.get().getIdentifier())));
+ TableNameSegment tableNameSegment = new TableNameSegment(owner.get().getStartIndex(), owner.get().getStopIndex(), owner.get().getIdentifier());
+ owner.get().getTableBoundInfo().ifPresent(tableNameSegment::setTableBoundInfo);
+ rewriteTables.add(new SimpleTableSegment(tableNameSegment));
}
}
}
diff --git a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/segment/generic/table/TableNameSegment.java b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/segment/generic/table/TableNameSegment.java
index d12bf30caad..936abc3d8ee 100644
--- a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/segment/generic/table/TableNameSegment.java
+++ b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/segment/generic/table/TableNameSegment.java
@@ -24,12 +24,13 @@ import org.apache.shardingsphere.sql.parser.statement.core.segment.SQLSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue;
+import java.util.Optional;
+
/**
* Table name segment.
*/
@RequiredArgsConstructor
@Getter
-@Setter
public final class TableNameSegment implements SQLSegment {
private final int startIndex;
@@ -38,5 +39,15 @@ public final class TableNameSegment implements SQLSegment {
private final IdentifierValue identifier;
+ @Setter
private TableSegmentBoundInfo tableBoundInfo;
+
+ /**
+ * Get table bound info.
+ *
+ * @return table bound info
+ */
+ public Optional<TableSegmentBoundInfo> getTableBoundInfo() {
+ return Optional.ofNullable(tableBoundInfo);
+ }
}
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/ProxySQLExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/ProxySQLExecutorTest.java
index e15e19d7bb2..b2dbcc146d3 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/ProxySQLExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/ProxySQLExecutorTest.java
@@ -240,19 +240,19 @@ class ProxySQLExecutorTest {
private CreateTableStatementContext createMySQLCreateTableStatementContext() {
MySQLCreateTableStatement sqlStatement = new MySQLCreateTableStatement(false);
sqlStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order"))));
- return new CreateTableStatementContext(sqlStatement, "foo_db");
+ return new CreateTableStatementContext(sqlStatement);
}
private TruncateStatementContext createMySQLTruncateStatementContext() {
MySQLTruncateStatement sqlStatement = new MySQLTruncateStatement();
sqlStatement.getTables().add(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order"))));
- return new TruncateStatementContext(sqlStatement, "foo_db");
+ return new TruncateStatementContext(sqlStatement);
}
private SQLStatementContext createPostgreSQLTruncateStatementContext() {
PostgreSQLTruncateStatement sqlStatement = new PostgreSQLTruncateStatement();
sqlStatement.getTables().add(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order"))));
- return new TruncateStatementContext(sqlStatement, "foo_db");
+ return new TruncateStatementContext(sqlStatement);
}
private CursorStatementContext createCursorStatementContext() {
@@ -276,7 +276,7 @@ class ProxySQLExecutorTest {
private CreateTableStatementContext createPostgreSQLCreateTableStatementContext() {
PostgreSQLCreateTableStatement sqlStatement = new PostgreSQLCreateTableStatement(false);
sqlStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("t_order"))));
- return new CreateTableStatementContext(sqlStatement, "foo_db");
+ return new CreateTableStatementContext(sqlStatement);
}
private InsertStatementContext createPostgreSQLInsertStatementContext() {
diff --git a/proxy/backend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreatorTest.java b/proxy/backend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreatorTest.java
index bb7ed467d3b..83a46ca8d26 100644
--- a/proxy/backend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreatorTest.java
+++ b/proxy/backend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreatorTest.java
@@ -163,7 +163,7 @@ class PostgreSQLAdminExecutorCreatorTest {
@Test
void assertCreateWithDMLStatement() {
- DeleteStatementContext sqlStatementContext = new DeleteStatementContext(new PostgreSQLDeleteStatement(), "foo_db");
+ DeleteStatementContext sqlStatementContext = new DeleteStatementContext(new PostgreSQLDeleteStatement());
assertThat(new PostgreSQLAdminExecutorCreator().create(sqlStatementContext, "delete from t where id = 1", "", Collections.emptyList()), is(Optional.empty()));
}
}