You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2021/08/18 12:51:46 UTC
[shardingsphere] branch master updated: Remove SCTL (#11874)
This is an automated email from the ASF dual-hosted git repository.
panjuan 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 7d01c2e Remove SCTL (#11874)
7d01c2e is described below
commit 7d01c2ead86cec1bf65ec375f8bfccdaaf4c68cc
Author: lanchengx <52...@users.noreply.github.com>
AuthorDate: Wed Aug 18 07:51:13 2021 -0500
Remove SCTL (#11874)
* Refactor : Remove sctl package.
* Refactor : Classes needed to move.
* Refactor : Modify the import package path.
* Refactor : Need to modify the class;
* Refactor : Move HintManagerHolder;
---
.../text/TextProtocolBackendHandlerFactory.java | 9 +-
.../ral/common/hint}/HintManagerHolder.java | 4 +-
.../ral/common/hint}/HintShardingType.java | 2 +-
.../AddShardingHintDatabaseValueExecutor.java | 2 +-
.../AddShardingHintTableValueExecutor.java | 2 +-
.../common/hint/executor/ClearHintExecutor.java | 2 +-
.../ClearReadwriteSplittingHintExecutor.java | 2 +-
.../hint/executor/ClearShardingHintExecutor.java | 2 +-
.../SetReadwriteSplittingHintExecutor.java | 2 +-
.../SetShardingHintDatabaseValueExecutor.java | 2 +-
.../ShowReadwriteSplittingHintStatusExecutor.java | 6 +-
.../executor/ShowShardingHintStatusExecutor.java | 24 +--
.../hint/result/ShowShardingHintStatusResult.java} | 6 +-
.../sctl/ShardingCTLBackendHandlerFactory.java | 67 -------
.../backend/text/sctl/ShardingCTLErrorCode.java | 59 ------
.../proxy/backend/text/sctl/ShardingCTLParser.java | 36 ----
.../backend/text/sctl/ShardingCTLStatement.java | 24 ---
.../InvalidShardingCTLFormatException.java | 30 ---
.../text/sctl/exception/ShardingCTLException.java | 33 ----
.../UnsupportedShardingCTLTypeException.java | 30 ---
.../explain/ShardingCTLExplainBackendHandler.java | 108 ----------
.../sctl/explain/ShardingCTLExplainParser.java | 49 -----
.../sctl/explain/ShardingCTLExplainStatement.java | 32 ---
.../sctl/hint/ShardingCTLHintBackendHandler.java | 71 -------
.../text/sctl/hint/ShardingCTLHintParser.java | 132 -------------
.../text/sctl/hint/ShardingCTLHintStatement.java | 33 ----
.../text/sctl/hint/internal/HintCommand.java | 24 ---
.../sctl/hint/internal/HintCommandExecutor.java | 53 -----
.../hint/internal/HintCommandExecutorFactory.java | 77 --------
.../HintAddDatabaseShardingValueCommand.java | 40 ----
.../command/HintAddTableShardingValueCommand.java | 40 ----
.../hint/internal/command/HintClearCommand.java | 30 ---
.../command/HintErrorParameterCommand.java | 26 ---
.../HintSetDatabaseShardingValueCommand.java | 37 ----
.../command/HintSetPrimaryOnlyCommand.java | 36 ----
.../internal/command/HintShowStatusCommand.java | 30 ---
.../command/HintShowTableStatusCommand.java | 30 ---
.../executor/AbstractHintQueryExecutor.java | 67 -------
.../executor/AbstractHintUpdateExecutor.java | 38 ----
.../HintAddDatabaseShardingValueExecutor.java | 35 ----
.../HintAddTableShardingValueExecutor.java | 35 ----
.../hint/internal/executor/HintClearExecutor.java | 36 ----
.../executor/HintErrorParameterExecutor.java | 37 ----
.../HintSetDatabaseShardingValueExecutor.java | 35 ----
.../executor/HintSetPrimaryOnlyExecutor.java | 37 ----
.../internal/executor/HintShowStatusExecutor.java | 58 ------
.../executor/HintShowTableStatusExecutor.java | 104 ----------
.../sctl/set/ShardingCTLSetBackendHandler.java | 65 ------
.../text/sctl/set/ShardingCTLSetParser.java | 51 -----
.../text/sctl/set/ShardingCTLSetStatement.java | 34 ----
.../sctl/show/ShardingCTLShowBackendHandler.java | 83 --------
.../text/sctl/show/ShardingCTLShowParser.java | 49 -----
.../text/sctl/show/ShardingCTLShowStatement.java | 32 ---
.../proxy/backend/text/sctl/utils/SCTLUtils.java | 51 -----
.../TextProtocolBackendHandlerFactoryTest.java | 24 +--
.../text/sctl/ShardingCTLErrorCodeTest.java | 59 ------
.../ShardingCTLExplainBackendHandlerTest.java | 89 ---------
.../hint/ShardingCTLHintBackendHandlerTest.java | 220 ---------------------
.../text/sctl/hint/ShardingCTLHintParserTest.java | 173 ----------------
.../internal/HintCommandExecutorFactoryTest.java | 107 ----------
.../sctl/set/ShardingCTLSetBackendHandlerTest.java | 126 ------------
.../show/ShardingCTLShowBackendHandlerTest.java | 74 -------
.../frontend/exception/ExpectedExceptions.java | 4 +-
.../frontend/exception/ExpectedExceptionsTest.java | 4 +-
.../frontend/mysql/err/MySQLErrPacketFactory.java | 6 -
.../mysql/err/MySQLErrPacketFactoryTest.java | 22 +--
.../sql/parser/sql/common/util/SQLUtil.java | 21 ++
67 files changed, 72 insertions(+), 2896 deletions(-)
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactory.java
index ce4d342..5ad6348 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactory.java
@@ -38,8 +38,6 @@ import org.apache.shardingsphere.proxy.backend.text.data.DatabaseBackendHandlerF
import org.apache.shardingsphere.proxy.backend.text.database.DatabaseOperateBackendHandlerFactory;
import org.apache.shardingsphere.proxy.backend.text.distsql.DistSQLBackendHandlerFactory;
import org.apache.shardingsphere.proxy.backend.text.extra.ExtraTextProtocolBackendHandler;
-import org.apache.shardingsphere.proxy.backend.text.sctl.ShardingCTLBackendHandlerFactory;
-import org.apache.shardingsphere.proxy.backend.text.sctl.utils.SCTLUtils;
import org.apache.shardingsphere.proxy.backend.text.skip.SkipBackendHandler;
import org.apache.shardingsphere.proxy.backend.text.transaction.TransactionBackendHandlerFactory;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
@@ -47,6 +45,7 @@ import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateDatab
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropDatabaseStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.EmptyStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.TCLStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.util.SQLUtil;
import java.sql.SQLException;
import java.util.Collection;
@@ -75,14 +74,10 @@ public final class TextProtocolBackendHandlerFactory {
*/
@SuppressWarnings("unchecked")
public static TextProtocolBackendHandler newInstance(final DatabaseType databaseType, final String sql, final BackendConnection backendConnection) throws SQLException {
- String trimSQL = SCTLUtils.trimComment(sql);
+ String trimSQL = SQLUtil.trimComment(sql);
if (Strings.isNullOrEmpty(trimSQL)) {
return new SkipBackendHandler(new EmptyStatement());
}
- // TODO Parse sctl SQL with ANTLR
- if (trimSQL.toUpperCase().startsWith(ShardingCTLBackendHandlerFactory.SCTL)) {
- return ShardingCTLBackendHandlerFactory.newInstance(trimSQL, backendConnection);
- }
SQLStatement sqlStatement = new ShardingSphereSQLParserEngine(getBackendDatabaseType(databaseType, backendConnection).getName()).parse(sql, false);
if (sqlStatement instanceof DistSQLStatement) {
return DistSQLBackendHandlerFactory.newInstance(databaseType, (DistSQLStatement) sqlStatement, backendConnection);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/HintManagerHolder.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/HintManagerHolder.java
similarity index 89%
rename from shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/HintManagerHolder.java
rename to shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/HintManagerHolder.java
index 8fab953..4ba956b 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/HintManagerHolder.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/HintManagerHolder.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal;
+package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -30,7 +30,7 @@ public final class HintManagerHolder {
private static final ThreadLocal<HintManager> HINT_MANAGER_HOLDER = new ThreadLocal<>();
/**
- * Get a instance for {@code HintManager} from {@code ThreadLocal},if not exist,then create new one.
+ * Get an instance for {@code HintManager} from {@code ThreadLocal},if not exist,then create new one.
*
* @return hint manager
*/
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/HintShardingType.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/HintShardingType.java
similarity index 92%
rename from shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/HintShardingType.java
rename to shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/HintShardingType.java
index a787d91..94eceab 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/HintShardingType.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/HintShardingType.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal;
+package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint;
/**
* Hint sharding type.
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/AddShardingHintDatabaseValueExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/AddShardingHintDatabaseValueExecutor.java
index 390d249..f3e8d33 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/AddShardingHintDatabaseValueExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/AddShardingHintDatabaseValueExecutor.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.exe
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintManagerHolder;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.HintManagerHolder;
import org.apache.shardingsphere.sharding.distsql.parser.statement.hint.AddShardingHintDatabaseValueStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.EmptyStatement;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/AddShardingHintTableValueExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/AddShardingHintTableValueExecutor.java
index 90b0ec9..5a3ffe7 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/AddShardingHintTableValueExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/AddShardingHintTableValueExecutor.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.exe
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintManagerHolder;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.HintManagerHolder;
import org.apache.shardingsphere.sharding.distsql.parser.statement.hint.AddShardingHintTableValueStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.EmptyStatement;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ClearHintExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ClearHintExecutor.java
index 53bfa70..ee75cbc 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ClearHintExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ClearHintExecutor.java
@@ -21,7 +21,7 @@ import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.hint.ClearHintStatement;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintManagerHolder;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.HintManagerHolder;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.EmptyStatement;
/**
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ClearReadwriteSplittingHintExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ClearReadwriteSplittingHintExecutor.java
index ad4a056..8fe599a 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ClearReadwriteSplittingHintExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ClearReadwriteSplittingHintExecutor.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.exe
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintManagerHolder;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.HintManagerHolder;
import org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.hint.ClearReadwriteSplittingHintStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.EmptyStatement;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ClearShardingHintExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ClearShardingHintExecutor.java
index c4a3f68..e954a30 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ClearShardingHintExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ClearShardingHintExecutor.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.exe
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintManagerHolder;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.HintManagerHolder;
import org.apache.shardingsphere.sharding.distsql.parser.statement.hint.ClearShardingHintStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.EmptyStatement;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/SetReadwriteSplittingHintExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/SetReadwriteSplittingHintExecutor.java
index 2a1c54a..5dcc417 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/SetReadwriteSplittingHintExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/SetReadwriteSplittingHintExecutor.java
@@ -21,7 +21,7 @@ import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.HintSourceType;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintManagerHolder;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.HintManagerHolder;
import org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.hint.SetReadwriteSplittingHintStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.EmptyStatement;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/SetShardingHintDatabaseValueExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/SetShardingHintDatabaseValueExecutor.java
index e9e42d8..9f7d5f1 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/SetShardingHintDatabaseValueExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/SetShardingHintDatabaseValueExecutor.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.exe
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintManagerHolder;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.HintManagerHolder;
import org.apache.shardingsphere.sharding.distsql.parser.statement.hint.SetShardingHintDatabaseValueStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.EmptyStatement;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ShowReadwriteSplittingHintStatusExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ShowReadwriteSplittingHintStatusExecutor.java
index 23ffa2f..73ebbb7 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ShowReadwriteSplittingHintStatusExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ShowReadwriteSplittingHintStatusExecutor.java
@@ -21,7 +21,6 @@ import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.hint.HintManager;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintShardingType;
import org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.hint.ShowReadwriteSplittingHintStatusStatement;
import org.apache.shardingsphere.sharding.merge.dal.common.MultipleLocalDataMergedResult;
@@ -45,12 +44,11 @@ public final class ShowReadwriteSplittingHintStatusExecutor extends AbstractHint
@Override
protected MergedResult createMergedResult() {
- HintShardingType shardingType = HintManager.isDatabaseShardingOnly() ? HintShardingType.DATABASES_ONLY : HintShardingType.DATABASES_TABLES;
- List<Object> row = createRow(HintManager.isWriteRouteOnly(), shardingType);
+ List<Object> row = createRow(HintManager.isWriteRouteOnly());
return new MultipleLocalDataMergedResult(Collections.singletonList(row));
}
- private List<Object> createRow(final boolean primaryOnly, final HintShardingType shardingType) {
+ private List<Object> createRow(final boolean primaryOnly) {
List<Object> result = new ArrayList<>(2);
result.add(String.valueOf(primaryOnly).toLowerCase());
return result;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ShowShardingHintStatusExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ShowShardingHintStatusExecutor.java
index 3e1120a..d842685 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ShowShardingHintStatusExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ShowShardingHintStatusExecutor.java
@@ -26,8 +26,8 @@ import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.Bac
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.exception.RuleNotExistedException;
import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintShardingType;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.result.HintShowTableStatusResult;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.HintShardingType;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.result.ShowShardingHintStatusResult;
import org.apache.shardingsphere.sharding.distsql.parser.statement.hint.ShowShardingHintStatusStatement;
import org.apache.shardingsphere.sharding.merge.dal.common.MultipleLocalDataMergedResult;
@@ -59,7 +59,7 @@ public final class ShowShardingHintStatusExecutor extends AbstractHintQueryExecu
@Override
protected MergedResult createMergedResult() {
- Map<String, HintShowTableStatusResult> results = new HashMap<>();
+ Map<String, ShowShardingHintStatusResult> results = new HashMap<>();
ShardingSphereMetaData metaData = ProxyContext.getInstance().getMetaData(backendConnection.getSchemaName());
if (!metaData.isComplete()) {
throw new RuleNotExistedException();
@@ -75,10 +75,10 @@ public final class ShowShardingHintStatusExecutor extends AbstractHintQueryExecu
return convertToMergedResult(results.values());
}
- private void fillShardingValues(final Map<String, HintShowTableStatusResult> results, final String logicTable,
+ private void fillShardingValues(final Map<String, ShowShardingHintStatusResult> results, final String logicTable,
final Collection<Comparable<?>> databaseShardingValues, final Collection<Comparable<?>> tableShardingValues) {
if (!results.containsKey(logicTable)) {
- results.put(logicTable, new HintShowTableStatusResult(logicTable));
+ results.put(logicTable, new ShowShardingHintStatusResult(logicTable));
}
for (Comparable<?> each : databaseShardingValues) {
results.get(logicTable).getDatabaseShardingValues().add(each.toString());
@@ -88,20 +88,20 @@ public final class ShowShardingHintStatusExecutor extends AbstractHintQueryExecu
}
}
- private MergedResult convertToMergedResult(final Collection<HintShowTableStatusResult> hintShowTableStatusResults) {
- Collection<List<Object>> values = new ArrayList<>(hintShowTableStatusResults.size());
- for (HintShowTableStatusResult each : hintShowTableStatusResults) {
+ private MergedResult convertToMergedResult(final Collection<ShowShardingHintStatusResult> showShardingHintStatusResults) {
+ Collection<List<Object>> values = new ArrayList<>(showShardingHintStatusResults.size());
+ for (ShowShardingHintStatusResult each : showShardingHintStatusResults) {
values.add(createRow(each));
}
return new MultipleLocalDataMergedResult(values);
}
- private List<Object> createRow(final HintShowTableStatusResult hintShowTableStatusResult) {
+ private List<Object> createRow(final ShowShardingHintStatusResult showShardingHintStatusResult) {
String shardingType = String.valueOf(HintManager.isDatabaseShardingOnly() ? HintShardingType.DATABASES_ONLY : HintShardingType.DATABASES_TABLES).toLowerCase();
List<Object> result = new ArrayList<>(3);
- result.add(hintShowTableStatusResult.getLogicTable());
- result.add(Joiner.on(",").join(hintShowTableStatusResult.getDatabaseShardingValues()));
- result.add(Joiner.on(",").join(hintShowTableStatusResult.getTableShardingValues()));
+ result.add(showShardingHintStatusResult.getLogicTable());
+ result.add(Joiner.on(",").join(showShardingHintStatusResult.getDatabaseShardingValues()));
+ result.add(Joiner.on(",").join(showShardingHintStatusResult.getTableShardingValues()));
result.add(shardingType);
return result;
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/result/HintShowTableStatusResult.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/result/ShowShardingHintStatusResult.java
similarity index 87%
rename from shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/result/HintShowTableStatusResult.java
rename to shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/result/ShowShardingHintStatusResult.java
index 7fec3e2..2d0ab82 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/result/HintShowTableStatusResult.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/result/ShowShardingHintStatusResult.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.result;
+package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.result;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@@ -24,11 +24,11 @@ import java.util.Collection;
import java.util.LinkedList;
/**
- * Hint show table status result.
+ * Show sharding hint status result.
*/
@Getter
@RequiredArgsConstructor
-public final class HintShowTableStatusResult {
+public final class ShowShardingHintStatusResult {
private final String logicTable;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/ShardingCTLBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/ShardingCTLBackendHandlerFactory.java
deleted file mode 100644
index 7fa92c4..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/ShardingCTLBackendHandlerFactory.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
-import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
-import org.apache.shardingsphere.proxy.backend.text.sctl.explain.ShardingCTLExplainBackendHandler;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.ShardingCTLHintBackendHandler;
-import org.apache.shardingsphere.proxy.backend.text.sctl.set.ShardingCTLSetBackendHandler;
-import org.apache.shardingsphere.proxy.backend.text.sctl.show.ShardingCTLShowBackendHandler;
-
-/**
- * Sharding CTL backend handler factory.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class ShardingCTLBackendHandlerFactory {
-
- public static final String SCTL = "SCTL:";
-
- private static final String SCTL_SET = SCTL + "SET";
-
- private static final String SCTL_SHOW = SCTL + "SHOW";
-
- private static final String SCTL_EXPLAIN = SCTL + "EXPLAIN";
-
- private static final String SCTL_HINT = SCTL + "HINT";
-
- /**
- * Create new instance of sharding CTL backend handler.
- *
- * @param sql SQL to be executed
- * @param backendConnection backend connection
- * @return instance of sharding CTL backend handler
- */
- public static TextProtocolBackendHandler newInstance(final String sql, final BackendConnection backendConnection) {
- if (sql.toUpperCase().startsWith(SCTL_SET)) {
- return new ShardingCTLSetBackendHandler(sql, backendConnection);
- }
- if (sql.toUpperCase().startsWith(SCTL_SHOW)) {
- return new ShardingCTLShowBackendHandler(sql, backendConnection);
- }
- if (sql.toUpperCase().startsWith(SCTL_EXPLAIN)) {
- return new ShardingCTLExplainBackendHandler(sql, backendConnection);
- }
- if (sql.toUpperCase().startsWith(SCTL_HINT)) {
- return new ShardingCTLHintBackendHandler(sql, backendConnection);
- }
- throw new IllegalArgumentException(sql);
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/ShardingCTLErrorCode.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/ShardingCTLErrorCode.java
deleted file mode 100644
index c16e942..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/ShardingCTLErrorCode.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.db.protocol.error.SQLErrorCode;
-import org.apache.shardingsphere.proxy.backend.text.sctl.exception.InvalidShardingCTLFormatException;
-import org.apache.shardingsphere.proxy.backend.text.sctl.exception.ShardingCTLException;
-import org.apache.shardingsphere.proxy.backend.text.sctl.exception.UnsupportedShardingCTLTypeException;
-
-/**
- * Sharding CTL error code.
- */
-@RequiredArgsConstructor
-@Getter
-public enum ShardingCTLErrorCode implements SQLErrorCode {
-
- INVALID_FORMAT(11000, "S11000", "Invalid format for sharding ctl [%s]."),
-
- UNSUPPORTED_TYPE(11001, "S11001", "Could not support sctl type [%s].");
-
- private final int errorCode;
-
- private final String sqlState;
-
- private final String errorMessage;
-
- /**
- * Value of sharding CTL error code.
- *
- * @param exception exception
- * @return sharding CTL error code
- */
- public static ShardingCTLErrorCode valueOf(final ShardingCTLException exception) {
- if (exception instanceof InvalidShardingCTLFormatException) {
- return INVALID_FORMAT;
- }
- if (exception instanceof UnsupportedShardingCTLTypeException) {
- return UNSUPPORTED_TYPE;
- }
- throw new UnsupportedOperationException("Cannot find sharding CTL error code from exception: %s", exception);
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/ShardingCTLParser.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/ShardingCTLParser.java
deleted file mode 100644
index 9ef6fe7..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/ShardingCTLParser.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl;
-
-import java.util.Optional;
-
-/**
- * Sharding CTL parser interface.
- *
- * @param <T> type of sharding CTL statement
- */
-public interface ShardingCTLParser<T extends ShardingCTLStatement> {
-
- /**
- * Do sharding CTL parse.
- *
- * @return sharding CTL statement.
- */
- Optional<T> doParse();
-}
-
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/ShardingCTLStatement.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/ShardingCTLStatement.java
deleted file mode 100644
index 8cf21c4..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/ShardingCTLStatement.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl;
-
-/**
- * Sharding CTL statement.
- */
-public interface ShardingCTLStatement {
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/exception/InvalidShardingCTLFormatException.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/exception/InvalidShardingCTLFormatException.java
deleted file mode 100644
index 8c39316..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/exception/InvalidShardingCTLFormatException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.exception;
-
-/**
- * Invalid sharding CTL exception.
- */
-public final class InvalidShardingCTLFormatException extends ShardingCTLException {
-
- private static final long serialVersionUID = -339768032160731248L;
-
- public InvalidShardingCTLFormatException(final String shardingCTL) {
- super(shardingCTL);
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/exception/ShardingCTLException.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/exception/ShardingCTLException.java
deleted file mode 100644
index 24c9e06..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/exception/ShardingCTLException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.exception;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-
-/**
- * Sharding CTL exception.
- */
-@RequiredArgsConstructor
-@Getter
-public abstract class ShardingCTLException extends RuntimeException {
-
- private static final long serialVersionUID = -9206948159895184071L;
-
- private final String shardingCTL;
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/exception/UnsupportedShardingCTLTypeException.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/exception/UnsupportedShardingCTLTypeException.java
deleted file mode 100644
index 7f316ee..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/exception/UnsupportedShardingCTLTypeException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.exception;
-
-/**
- * Unsupported sharding CTL type exception.
- */
-public final class UnsupportedShardingCTLTypeException extends ShardingCTLException {
-
- private static final long serialVersionUID = -3549135462598846858L;
-
- public UnsupportedShardingCTLTypeException(final String shardingCTL) {
- super(shardingCTL);
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainBackendHandler.java
deleted file mode 100644
index 31d6f08..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainBackendHandler.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.explain;
-
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.binder.LogicSQL;
-import org.apache.shardingsphere.infra.binder.SQLStatementContextFactory;
-import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
-import org.apache.shardingsphere.infra.binder.type.TableAvailable;
-import org.apache.shardingsphere.infra.context.kernel.KernelProcessor;
-import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
-import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
-import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit;
-import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine;
-import org.apache.shardingsphere.proxy.backend.communication.SQLStatementSchemaHolder;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.exception.RuleNotExistedException;
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
-import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
-import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
-import org.apache.shardingsphere.proxy.backend.text.sctl.exception.InvalidShardingCTLFormatException;
-import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
-
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Optional;
-
-/**
- * Sharding CTL explain backend handler.
- */
-@RequiredArgsConstructor
-public final class ShardingCTLExplainBackendHandler implements TextProtocolBackendHandler {
-
- private final String sql;
-
- private final BackendConnection backendConnection;
-
- private final KernelProcessor kernelProcessor = new KernelProcessor();
-
- private List<QueryHeader> queryHeaders;
-
- private Iterator<ExecutionUnit> executionUnits;
-
- @Override
- public ResponseHeader execute() throws SQLException {
- Optional<ShardingCTLExplainStatement> explainStatement = new ShardingCTLExplainParser(sql).doParse();
- if (!explainStatement.isPresent()) {
- throw new InvalidShardingCTLFormatException(sql);
- }
- MetaDataContexts metaDataContexts = ProxyContext.getInstance().getContextManager().getMetaDataContexts();
- String defaultSchemaName = backendConnection.getDefaultSchemaName();
- String databaseType = DatabaseTypeRegistry.getTrunkDatabaseTypeName(metaDataContexts.getMetaData(defaultSchemaName).getResource().getDatabaseType());
- SQLStatement sqlStatement = new ShardingSphereSQLParserEngine(databaseType).parse(explainStatement.get().getSql(), false);
- SQLStatementContext<?> sqlStatementContext = SQLStatementContextFactory.newInstance(metaDataContexts.getMetaDataMap(), Collections.emptyList(), sqlStatement, defaultSchemaName);
- // TODO optimize SQLStatementSchemaHolder
- if (sqlStatementContext instanceof TableAvailable) {
- ((TableAvailable) sqlStatementContext).getTablesContext().getSchemaName().ifPresent(SQLStatementSchemaHolder::set);
- }
- ShardingSphereMetaData metaData = ProxyContext.getInstance().getMetaData(backendConnection.getSchemaName());
- if (!metaData.isComplete()) {
- throw new RuleNotExistedException();
- }
- LogicSQL logicSQL = new LogicSQL(sqlStatementContext, explainStatement.get().getSql(), Collections.emptyList());
- executionUnits = kernelProcessor.generateExecutionContext(logicSQL, metaData, metaDataContexts.getProps()).getExecutionUnits().iterator();
- queryHeaders = new ArrayList<>(2);
- queryHeaders.add(new QueryHeader("", "", "datasource_name", "", Types.CHAR, "CHAR", 255, 0, false, false, false, false));
- queryHeaders.add(new QueryHeader("", "", "sql", "", Types.CHAR, "CHAR", 255, 0, false, false, false, false));
- return new QueryResponseHeader(queryHeaders);
- }
-
- @Override
- public boolean next() {
- return null != executionUnits && executionUnits.hasNext();
- }
-
- @Override
- public Collection<Object> getRowData() {
- ExecutionUnit executionUnit = executionUnits.next();
- Collection<Object> result = new LinkedList<>();
- result.add(executionUnit.getDataSourceName());
- result.add(executionUnit.getSqlUnit().getSql());
- return result;
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainParser.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainParser.java
deleted file mode 100644
index 91036ab..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainParser.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.explain;
-
-import com.google.common.base.Preconditions;
-import org.apache.shardingsphere.proxy.backend.text.sctl.ShardingCTLParser;
-
-import java.util.Optional;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Sharding CTL explain parser.
- */
-public final class ShardingCTLExplainParser implements ShardingCTLParser<ShardingCTLExplainStatement> {
-
- private final String regex = "sctl:explain\\s+([\\s\\S]*)";
-
- private final Matcher matcher;
-
- ShardingCTLExplainParser(final String sql) {
- matcher = Pattern.compile(regex, Pattern.CASE_INSENSITIVE).matcher(sql);
- }
-
- @Override
- public Optional<ShardingCTLExplainStatement> doParse() {
- if (matcher.find()) {
- String value = matcher.group(1);
- Preconditions.checkNotNull(value, "sctl explain sql cannot be null.");
- return Optional.of(new ShardingCTLExplainStatement(value));
- }
- return Optional.empty();
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainStatement.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainStatement.java
deleted file mode 100644
index 151fc5f..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainStatement.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.explain;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.text.sctl.ShardingCTLStatement;
-
-/**
- * Sharding CTL explain statement.
- */
-@RequiredArgsConstructor
-@Getter
-public final class ShardingCTLExplainStatement implements ShardingCTLStatement {
-
- private final String sql;
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintBackendHandler.java
deleted file mode 100644
index f928303..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintBackendHandler.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint;
-
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
-import org.apache.shardingsphere.proxy.backend.text.sctl.exception.InvalidShardingCTLFormatException;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintCommandExecutor;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintCommandExecutorFactory;
-
-import java.sql.SQLException;
-import java.util.Collection;
-import java.util.Optional;
-
-/**
- * Sharding CTL hint backend handler.
- */
-@RequiredArgsConstructor
-public final class ShardingCTLHintBackendHandler implements TextProtocolBackendHandler {
-
- private final String sql;
-
- private final BackendConnection backendConnection;
-
- private HintCommandExecutor hintCommandExecutor;
-
- @SuppressWarnings("unchecked")
- @Override
- public ResponseHeader execute() {
- if (!ProxyContext.getInstance().getContextManager().getMetaDataContexts().getProps().<Boolean>getValue(ConfigurationPropertyKey.PROXY_HINT_ENABLED)) {
- throw new UnsupportedOperationException(String.format("%s should be true, please check your config", ConfigurationPropertyKey.PROXY_HINT_ENABLED.getKey()));
- }
- Optional<ShardingCTLHintStatement> shardingTCLStatement = new ShardingCTLHintParser(sql).doParse();
- if (!shardingTCLStatement.isPresent()) {
- throw new InvalidShardingCTLFormatException(sql);
- }
- HintCommand hintCommand = shardingTCLStatement.get().getHintCommand();
- hintCommandExecutor = HintCommandExecutorFactory.newInstance(hintCommand, backendConnection, sql);
- return hintCommandExecutor.execute(hintCommand);
- }
-
- @Override
- public boolean next() throws SQLException {
- return hintCommandExecutor.next();
- }
-
- @Override
- public Collection<Object> getRowData() throws SQLException {
- return hintCommandExecutor.getQueryResponseRow().getData();
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintParser.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintParser.java
deleted file mode 100644
index bde1a06..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintParser.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint;
-
-import org.apache.shardingsphere.proxy.backend.text.sctl.ShardingCTLParser;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintAddDatabaseShardingValueCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintAddTableShardingValueCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintClearCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintErrorParameterCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintSetDatabaseShardingValueCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintSetPrimaryOnlyCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintShowStatusCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintShowTableStatusCommand;
-
-import java.util.Optional;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Sharding CTL hint parser.
- */
-public final class ShardingCTLHintParser implements ShardingCTLParser<ShardingCTLHintStatement> {
-
- private final String setPrimaryOnlyRegex = "sctl:hint\\s+set\\s+PRIMARY_ONLY=(true|false)\\s*$";
-
- private final String setDatabaseShardingValueRegex = "sctl:hint\\s+set\\s+DatabaseShardingValue=(\\S*)";
-
- private final String addDatabaseShardingValueRegex = "sctl:hint\\s+addDatabaseShardingValue\\s+(\\S*)=(\\S*)";
-
- private final String addTableShardingValueRegex = "sctl:hint\\s+addTableShardingValue\\s+(\\S*)=(\\S*)";
-
- private final String clearRegex = "sctl:hint\\s+clear\\s*$";
-
- private final String showStatusRegex = "sctl:hint\\s+show\\s+status\\s*$";
-
- private final String showTableStatusRegex = "sctl:hint\\s+show\\s+table\\s+status\\s*$";
-
- private final String errorParameterRegex = "sctl:hint\\s+.*";
-
- private final Matcher setPrimaryOnlyMatcher;
-
- private final Matcher setDatabaseShardingValueMatcher;
-
- private final Matcher addDatabaseShardingValueMatcher;
-
- private final Matcher addTableShardingValueMatcher;
-
- private final Matcher clearMatcher;
-
- private final Matcher showStatusMatcher;
-
- private final Matcher showTableStatusMatcher;
-
- private final Matcher errorParameterMatcher;
-
- public ShardingCTLHintParser(final String sql) {
- setPrimaryOnlyMatcher = Pattern.compile(setPrimaryOnlyRegex, Pattern.CASE_INSENSITIVE).matcher(sql);
- setDatabaseShardingValueMatcher = Pattern.compile(setDatabaseShardingValueRegex, Pattern.CASE_INSENSITIVE).matcher(sql);
- addDatabaseShardingValueMatcher = Pattern.compile(addDatabaseShardingValueRegex, Pattern.CASE_INSENSITIVE).matcher(sql);
- addTableShardingValueMatcher = Pattern.compile(addTableShardingValueRegex, Pattern.CASE_INSENSITIVE).matcher(sql);
- clearMatcher = Pattern.compile(clearRegex, Pattern.CASE_INSENSITIVE).matcher(sql);
- showStatusMatcher = Pattern.compile(showStatusRegex, Pattern.CASE_INSENSITIVE).matcher(sql);
- showTableStatusMatcher = Pattern.compile(showTableStatusRegex, Pattern.CASE_INSENSITIVE).matcher(sql);
- errorParameterMatcher = Pattern.compile(errorParameterRegex, Pattern.CASE_INSENSITIVE).matcher(sql);
- }
-
- @Override
- public Optional<ShardingCTLHintStatement> doParse() {
- Optional<ShardingCTLHintStatement> updateShardingCTLHintStatement = parseUpdateShardingCTLHintStatement();
- if (updateShardingCTLHintStatement.isPresent()) {
- return updateShardingCTLHintStatement;
- }
- Optional<ShardingCTLHintStatement> queryShardingCTLHintStatement = parseQueryShardingCTLHintStatement();
- if (queryShardingCTLHintStatement.isPresent()) {
- return queryShardingCTLHintStatement;
- }
- if (errorParameterMatcher.find()) {
- return Optional.of(new ShardingCTLHintStatement(new HintErrorParameterCommand()));
- }
- return Optional.empty();
- }
-
- private Optional<ShardingCTLHintStatement> parseUpdateShardingCTLHintStatement() {
- if (setPrimaryOnlyMatcher.find()) {
- boolean primaryOnly = Boolean.parseBoolean(setPrimaryOnlyMatcher.group(1).toUpperCase());
- return Optional.of(new ShardingCTLHintStatement(new HintSetPrimaryOnlyCommand(primaryOnly)));
- }
- if (setDatabaseShardingValueMatcher.find()) {
- String shardingValue = setDatabaseShardingValueMatcher.group(1);
- return Optional.of(new ShardingCTLHintStatement(new HintSetDatabaseShardingValueCommand(shardingValue)));
- }
- if (addDatabaseShardingValueMatcher.find()) {
- String logicTable = addDatabaseShardingValueMatcher.group(1);
- String shardingValue = addDatabaseShardingValueMatcher.group(2);
- return Optional.of(new ShardingCTLHintStatement(new HintAddDatabaseShardingValueCommand(logicTable, shardingValue)));
- }
- if (addTableShardingValueMatcher.find()) {
- String logicTable = addTableShardingValueMatcher.group(1);
- String shardingValue = addTableShardingValueMatcher.group(2);
- return Optional.of(new ShardingCTLHintStatement(new HintAddTableShardingValueCommand(logicTable, shardingValue)));
- }
- if (clearMatcher.find()) {
- return Optional.of(new ShardingCTLHintStatement(new HintClearCommand()));
- }
- return Optional.empty();
- }
-
- private Optional<ShardingCTLHintStatement> parseQueryShardingCTLHintStatement() {
- if (showStatusMatcher.find()) {
- return Optional.of(new ShardingCTLHintStatement(new HintShowStatusCommand()));
- }
- if (showTableStatusMatcher.find()) {
- return Optional.of(new ShardingCTLHintStatement(new HintShowTableStatusCommand()));
- }
- return Optional.empty();
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintStatement.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintStatement.java
deleted file mode 100644
index eae4391..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintStatement.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.text.sctl.ShardingCTLStatement;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintCommand;
-
-/**
- * Sharding CTL hint statement.
- */
-@RequiredArgsConstructor
-@Getter
-public final class ShardingCTLHintStatement implements ShardingCTLStatement {
-
- private final HintCommand hintCommand;
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/HintCommand.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/HintCommand.java
deleted file mode 100644
index fcd7dec..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/HintCommand.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal;
-
-/**
- * Hint command.
- */
-public interface HintCommand {
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/HintCommandExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/HintCommandExecutor.java
deleted file mode 100644
index 2047cd6..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/HintCommandExecutor.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal;
-
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
-
-import java.sql.SQLException;
-
-/**
- * Hint command executor.
- */
-public interface HintCommandExecutor<T extends HintCommand> {
-
- /**
- * Execute hint command.
- *
- * @param hintCommand hint command
- * @return backend response
- */
- ResponseHeader execute(T hintCommand);
-
- /**
- * Goto next result value.
- *
- * @return has more result value or not
- * @throws SQLException SQL exception
- */
- boolean next() throws SQLException;
-
- /**
- * Get query response row.
- *
- * @return query response row
- * @throws SQLException SQL exception
- */
- QueryResponseRow getQueryResponseRow() throws SQLException;
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/HintCommandExecutorFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/HintCommandExecutorFactory.java
deleted file mode 100644
index 84e891a..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/HintCommandExecutorFactory.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintAddDatabaseShardingValueCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintAddTableShardingValueCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintClearCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintSetDatabaseShardingValueCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintSetPrimaryOnlyCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintShowStatusCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintShowTableStatusCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor.HintAddDatabaseShardingValueExecutor;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor.HintAddTableShardingValueExecutor;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor.HintClearExecutor;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor.HintErrorParameterExecutor;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor.HintSetDatabaseShardingValueExecutor;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor.HintSetPrimaryOnlyExecutor;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor.HintShowStatusExecutor;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor.HintShowTableStatusExecutor;
-
-/**
- * Hint command executor factory.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class HintCommandExecutorFactory {
-
- /**
- * Create hint command executor instance.
- *
- * @param hintCommand hint command
- * @param backendConnection backend connection
- * @param sql SQL
- * @return hint command executor
- */
- public static HintCommandExecutor newInstance(final HintCommand hintCommand, final BackendConnection backendConnection, final String sql) {
- if (hintCommand instanceof HintSetPrimaryOnlyCommand) {
- return new HintSetPrimaryOnlyExecutor();
- }
- if (hintCommand instanceof HintSetDatabaseShardingValueCommand) {
- return new HintSetDatabaseShardingValueExecutor();
- }
- if (hintCommand instanceof HintAddDatabaseShardingValueCommand) {
- return new HintAddDatabaseShardingValueExecutor();
- }
- if (hintCommand instanceof HintAddTableShardingValueCommand) {
- return new HintAddTableShardingValueExecutor();
- }
- if (hintCommand instanceof HintClearCommand) {
- return new HintClearExecutor();
- }
- if (hintCommand instanceof HintShowStatusCommand) {
- return new HintShowStatusExecutor();
- }
- if (hintCommand instanceof HintShowTableStatusCommand) {
- return new HintShowTableStatusExecutor(backendConnection);
- }
- return new HintErrorParameterExecutor(sql);
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/command/HintAddDatabaseShardingValueCommand.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/command/HintAddDatabaseShardingValueCommand.java
deleted file mode 100644
index 475258e..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/command/HintAddDatabaseShardingValueCommand.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintCommand;
-
-/**
- * Hint add sharding value for database command.
- *
- * <p>
- * example: sctl:hint addDatabaseShardingValue xx=yy.
- * xx: logicTable.
- * yy: sharding value.
- * </p>
- */
-@RequiredArgsConstructor
-@Getter
-public final class HintAddDatabaseShardingValueCommand implements HintCommand {
-
- private final String logicTable;
-
- private final String value;
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/command/HintAddTableShardingValueCommand.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/command/HintAddTableShardingValueCommand.java
deleted file mode 100644
index a8db796..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/command/HintAddTableShardingValueCommand.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintCommand;
-
-/**
- * Hint add sharding value for table command.
- *
- * <p>
- * example: sctl:hint addTableShardingValue xx=yy.
- * xx: logicTable.
- * yy: sharding value.
- * </p>
- */
-@RequiredArgsConstructor
-@Getter
-public final class HintAddTableShardingValueCommand implements HintCommand {
-
- private final String logicTable;
-
- private final String value;
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/command/HintClearCommand.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/command/HintClearCommand.java
deleted file mode 100644
index e70ec1e..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/command/HintClearCommand.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command;
-
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintCommand;
-
-/**
- * Hint clear command.
- *
- * <p>
- * example: sctl:hint clear.
- * </p>
- */
-public final class HintClearCommand implements HintCommand {
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/command/HintErrorParameterCommand.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/command/HintErrorParameterCommand.java
deleted file mode 100644
index 69487b7..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/command/HintErrorParameterCommand.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command;
-
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintCommand;
-
-/**
- * Hint error parameter command.
- */
-public final class HintErrorParameterCommand implements HintCommand {
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/command/HintSetDatabaseShardingValueCommand.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/command/HintSetDatabaseShardingValueCommand.java
deleted file mode 100644
index 6b2b883..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/command/HintSetDatabaseShardingValueCommand.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintCommand;
-
-/**
- * Hint set database sharding value command.
- *
- * <p>
- * example: sctl:hint set DatabaseShardingValue=yy.
- * yy: sharding value.
- * </p>
- */
-@RequiredArgsConstructor
-@Getter
-public final class HintSetDatabaseShardingValueCommand implements HintCommand {
-
- private final String value;
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/command/HintSetPrimaryOnlyCommand.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/command/HintSetPrimaryOnlyCommand.java
deleted file mode 100644
index 8591b4b..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/command/HintSetPrimaryOnlyCommand.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintCommand;
-
-/**
- * Hint set primary database only command.
- *
- * <p>
- * example: sctl:hint set PRIMARY_ONLY=true.
- * </p>
- */
-@RequiredArgsConstructor
-@Getter
-public final class HintSetPrimaryOnlyCommand implements HintCommand {
-
- private final boolean primaryOnly;
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/command/HintShowStatusCommand.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/command/HintShowStatusCommand.java
deleted file mode 100644
index 8304c08..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/command/HintShowStatusCommand.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command;
-
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintCommand;
-
-/**
- * Hint show status command.
- *
- * <p>
- * example: sctl:hint show status.
- * </p>
- */
-public final class HintShowStatusCommand implements HintCommand {
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/command/HintShowTableStatusCommand.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/command/HintShowTableStatusCommand.java
deleted file mode 100644
index c8996c7..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/command/HintShowTableStatusCommand.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command;
-
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintCommand;
-
-/**
- * Hint show table status command.
- *
- * <p>
- * example: sctl:hint show table status.
- * </p>
- */
-public final class HintShowTableStatusCommand implements HintCommand {
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/AbstractHintQueryExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/AbstractHintQueryExecutor.java
deleted file mode 100644
index b61c75e..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/AbstractHintQueryExecutor.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor;
-
-import org.apache.shardingsphere.infra.merge.result.MergedResult;
-import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseCell;
-import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
-import org.apache.shardingsphere.proxy.backend.response.data.impl.TextQueryResponseCell;
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
-import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintCommandExecutor;
-
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Abstract hint query command.
- */
-public abstract class AbstractHintQueryExecutor<T extends HintCommand> implements HintCommandExecutor<T> {
-
- private List<QueryHeader> queryHeaders;
-
- private MergedResult mergedResult;
-
- @Override
- public final ResponseHeader execute(final T hintCommand) {
- queryHeaders = createQueryHeaders();
- mergedResult = createMergedResult();
- return new QueryResponseHeader(queryHeaders);
- }
-
- protected abstract List<QueryHeader> createQueryHeaders();
-
- protected abstract MergedResult createMergedResult();
-
- @Override
- public final boolean next() throws SQLException {
- return null != mergedResult && mergedResult.next();
- }
-
- @Override
- public final QueryResponseRow getQueryResponseRow() throws SQLException {
- List<QueryResponseCell> cells = new ArrayList<>(queryHeaders.size());
- for (int i = 0; i < queryHeaders.size(); i++) {
- cells.add(new TextQueryResponseCell(mergedResult.getValue(i + 1, Object.class)));
- }
- return new QueryResponseRow(cells);
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/AbstractHintUpdateExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/AbstractHintUpdateExecutor.java
deleted file mode 100644
index f0cc8ce..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/AbstractHintUpdateExecutor.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor;
-
-import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintCommandExecutor;
-
-/**
- * Abstract hint update command.
- */
-public abstract class AbstractHintUpdateExecutor<T extends HintCommand> implements HintCommandExecutor<T> {
-
- @Override
- public final boolean next() {
- return false;
- }
-
- @Override
- public final QueryResponseRow getQueryResponseRow() {
- return null;
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintAddDatabaseShardingValueExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintAddDatabaseShardingValueExecutor.java
deleted file mode 100644
index 842e6b9..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintAddDatabaseShardingValueExecutor.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor;
-
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintManagerHolder;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintAddDatabaseShardingValueCommand;
-
-/**
- * Hint add sharding value for database command executor.
- */
-public final class HintAddDatabaseShardingValueExecutor extends AbstractHintUpdateExecutor<HintAddDatabaseShardingValueCommand> {
-
- @Override
- public ResponseHeader execute(final HintAddDatabaseShardingValueCommand command) {
- HintManagerHolder.get().addDatabaseShardingValue(command.getLogicTable(), command.getValue());
- return new UpdateResponseHeader(null);
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintAddTableShardingValueExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintAddTableShardingValueExecutor.java
deleted file mode 100644
index 04da2e3..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintAddTableShardingValueExecutor.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor;
-
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintManagerHolder;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintAddTableShardingValueCommand;
-
-/**
- * Hint add sharding value for table command executor.
- */
-public final class HintAddTableShardingValueExecutor extends AbstractHintUpdateExecutor<HintAddTableShardingValueCommand> {
-
- @Override
- public ResponseHeader execute(final HintAddTableShardingValueCommand command) {
- HintManagerHolder.get().addTableShardingValue(command.getLogicTable(), command.getValue());
- return new UpdateResponseHeader(null);
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintClearExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintClearExecutor.java
deleted file mode 100644
index 0649456..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintClearExecutor.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor;
-
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintManagerHolder;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintClearCommand;
-
-/**
- * Hint clear command executor.
- */
-public final class HintClearExecutor extends AbstractHintUpdateExecutor<HintClearCommand> {
-
- @Override
- public ResponseHeader execute(final HintClearCommand command) {
- HintManagerHolder.get().close();
- HintManagerHolder.remove();
- return new UpdateResponseHeader(null);
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintErrorParameterExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintErrorParameterExecutor.java
deleted file mode 100644
index bbd4729..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintErrorParameterExecutor.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor;
-
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import org.apache.shardingsphere.proxy.backend.text.sctl.exception.UnsupportedShardingCTLTypeException;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintErrorParameterCommand;
-
-/**
- * Hint error parameter command executor.
- */
-@RequiredArgsConstructor
-public final class HintErrorParameterExecutor extends AbstractHintUpdateExecutor<HintErrorParameterCommand> {
-
- private final String sql;
-
- @Override
- public ResponseHeader execute(final HintErrorParameterCommand command) {
- throw new UnsupportedShardingCTLTypeException(sql);
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintSetDatabaseShardingValueExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintSetDatabaseShardingValueExecutor.java
deleted file mode 100644
index 93877f4..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintSetDatabaseShardingValueExecutor.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor;
-
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintManagerHolder;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintSetDatabaseShardingValueCommand;
-
-/**
- * Hint set database sharding value command executor.
- */
-public final class HintSetDatabaseShardingValueExecutor extends AbstractHintUpdateExecutor<HintSetDatabaseShardingValueCommand> {
-
- @Override
- public ResponseHeader execute(final HintSetDatabaseShardingValueCommand command) {
- HintManagerHolder.get().setDatabaseShardingValue(command.getValue());
- return new UpdateResponseHeader(null);
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintSetPrimaryOnlyExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintSetPrimaryOnlyExecutor.java
deleted file mode 100644
index 332db6e..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintSetPrimaryOnlyExecutor.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor;
-
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintManagerHolder;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintSetPrimaryOnlyCommand;
-
-/**
- * Hint set primary database only command executor.
- */
-public final class HintSetPrimaryOnlyExecutor extends AbstractHintUpdateExecutor<HintSetPrimaryOnlyCommand> {
-
- @Override
- public ResponseHeader execute(final HintSetPrimaryOnlyCommand command) {
- if (command.isPrimaryOnly()) {
- HintManagerHolder.get().setWriteRouteOnly();
- }
- return new UpdateResponseHeader(null);
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintShowStatusExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintShowStatusExecutor.java
deleted file mode 100644
index a4c1dc4..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintShowStatusExecutor.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor;
-
-import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
-import org.apache.shardingsphere.infra.hint.HintManager;
-import org.apache.shardingsphere.infra.merge.result.MergedResult;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintShardingType;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintShowStatusCommand;
-import org.apache.shardingsphere.sharding.merge.dal.common.MultipleLocalDataMergedResult;
-
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Hint show status command executor.
- */
-public final class HintShowStatusExecutor extends AbstractHintQueryExecutor<HintShowStatusCommand> {
-
- @Override
- protected List<QueryHeader> createQueryHeaders() {
- List<QueryHeader> result = new ArrayList<>(2);
- result.add(new QueryHeader("", "", "primary_only", "", Types.CHAR, "CHAR", 5, 0, false, false, false, false));
- result.add(new QueryHeader("", "", "sharding_type", "", Types.CHAR, "CHAR", 255, 0, false, false, false, false));
- return result;
- }
-
- @Override
- protected MergedResult createMergedResult() {
- HintShardingType shardingType = HintManager.isDatabaseShardingOnly() ? HintShardingType.DATABASES_ONLY : HintShardingType.DATABASES_TABLES;
- List<Object> row = createRow(HintManager.isWriteRouteOnly(), shardingType);
- return new MultipleLocalDataMergedResult(Collections.singletonList(row));
- }
-
- private List<Object> createRow(final boolean primaryOnly, final HintShardingType shardingType) {
- List<Object> result = new ArrayList<>(2);
- result.add(String.valueOf(primaryOnly).toLowerCase());
- result.add(String.valueOf(shardingType).toLowerCase());
- return result;
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintShowTableStatusExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintShowTableStatusExecutor.java
deleted file mode 100644
index 65a07f7..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintShowTableStatusExecutor.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor;
-
-import com.google.common.base.Joiner;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
-import org.apache.shardingsphere.infra.hint.HintManager;
-import org.apache.shardingsphere.infra.merge.result.MergedResult;
-import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.exception.RuleNotExistedException;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintShowTableStatusCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.result.HintShowTableStatusResult;
-import org.apache.shardingsphere.sharding.merge.dal.common.MultipleLocalDataMergedResult;
-
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Hint show table status command executor.
- */
-@RequiredArgsConstructor
-public final class HintShowTableStatusExecutor extends AbstractHintQueryExecutor<HintShowTableStatusCommand> {
-
- private final BackendConnection backendConnection;
-
- @Override
- protected List<QueryHeader> createQueryHeaders() {
- List<QueryHeader> result = new ArrayList<>(3);
- result.add(new QueryHeader("", "", "table_name", "", Types.CHAR, "CHAR", 255, 0, false, false, false, false));
- result.add(new QueryHeader("", "", "database_sharding_values", "", Types.CHAR, "CHAR", 255, 0, false, false, false, false));
- result.add(new QueryHeader("", "", "table_sharding_values", "", Types.CHAR, "CHAR", 255, 0, false, false, false, false));
- return result;
- }
-
- @Override
- protected MergedResult createMergedResult() {
- Map<String, HintShowTableStatusResult> results = new HashMap<>();
- ShardingSphereMetaData metaData = ProxyContext.getInstance().getMetaData(backendConnection.getSchemaName());
- if (!metaData.isComplete()) {
- throw new RuleNotExistedException();
- }
- Collection<String> tableNames = metaData.getSchema().getAllTableNames();
- for (String each : tableNames) {
- if (HintManager.isDatabaseShardingOnly()) {
- fillShardingValues(results, each, HintManager.getDatabaseShardingValues(), Collections.emptyList());
- } else {
- fillShardingValues(results, each, HintManager.getDatabaseShardingValues(each), HintManager.getTableShardingValues(each));
- }
- }
- return convertToMergedResult(results.values());
- }
-
- private void fillShardingValues(final Map<String, HintShowTableStatusResult> results, final String logicTable,
- final Collection<Comparable<?>> databaseShardingValues, final Collection<Comparable<?>> tableShardingValues) {
- if (!results.containsKey(logicTable)) {
- results.put(logicTable, new HintShowTableStatusResult(logicTable));
- }
- for (Comparable<?> each : databaseShardingValues) {
- results.get(logicTable).getDatabaseShardingValues().add(each.toString());
- }
- for (Comparable<?> each : tableShardingValues) {
- results.get(logicTable).getTableShardingValues().add(each.toString());
- }
- }
-
- private MergedResult convertToMergedResult(final Collection<HintShowTableStatusResult> hintShowTableStatusResults) {
- Collection<List<Object>> values = new ArrayList<>(hintShowTableStatusResults.size());
- for (HintShowTableStatusResult each : hintShowTableStatusResults) {
- values.add(createRow(each));
- }
- return new MultipleLocalDataMergedResult(values);
- }
-
- private List<Object> createRow(final HintShowTableStatusResult hintShowTableStatusResult) {
- List<Object> result = new ArrayList<>(3);
- result.add(hintShowTableStatusResult.getLogicTable());
- result.add(Joiner.on(",").join(hintShowTableStatusResult.getDatabaseShardingValues()));
- result.add(Joiner.on(",").join(hintShowTableStatusResult.getTableShardingValues()));
- return result;
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/set/ShardingCTLSetBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/set/ShardingCTLSetBackendHandler.java
deleted file mode 100644
index 482e966..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/set/ShardingCTLSetBackendHandler.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.set;
-
-import org.apache.shardingsphere.infra.exception.ShardingSphereException;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
-import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
-import org.apache.shardingsphere.proxy.backend.text.sctl.exception.InvalidShardingCTLFormatException;
-import org.apache.shardingsphere.proxy.backend.text.sctl.exception.UnsupportedShardingCTLTypeException;
-import org.apache.shardingsphere.transaction.core.TransactionType;
-
-import java.util.Optional;
-
-/**
- * Sharding CTL backend handler.
- */
-public final class ShardingCTLSetBackendHandler implements TextProtocolBackendHandler {
-
- private final String sql;
-
- private final BackendConnection backendConnection;
-
- public ShardingCTLSetBackendHandler(final String sql, final BackendConnection backendConnection) {
- this.sql = sql.toUpperCase().trim();
- this.backendConnection = backendConnection;
- }
-
- @Override
- public ResponseHeader execute() {
- Optional<ShardingCTLSetStatement> shardingTCLStatement = new ShardingCTLSetParser(sql).doParse();
- if (!shardingTCLStatement.isPresent()) {
- throw new InvalidShardingCTLFormatException(sql);
- }
- if ("TRANSACTION_TYPE".equals(shardingTCLStatement.get().getKey())) {
- if (null == backendConnection.getSchemaName()) {
- throw new ShardingSphereException("Please select database, then switch transaction type.");
- }
- try {
- backendConnection.getTransactionStatus().setTransactionType(TransactionType.valueOf(shardingTCLStatement.get().getValue()));
- } catch (final IllegalArgumentException ex) {
- throw new UnsupportedShardingCTLTypeException(sql);
- }
- } else {
- throw new UnsupportedShardingCTLTypeException(sql);
- }
- return new UpdateResponseHeader(null);
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/set/ShardingCTLSetParser.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/set/ShardingCTLSetParser.java
deleted file mode 100644
index ab29c4e5..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/set/ShardingCTLSetParser.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.set;
-
-import com.google.common.base.Preconditions;
-import org.apache.shardingsphere.proxy.backend.text.sctl.ShardingCTLParser;
-
-import java.util.Optional;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Sharding CTL set parser.
- */
-public final class ShardingCTLSetParser implements ShardingCTLParser<ShardingCTLSetStatement> {
-
- private final String regex = "sctl:set\\s+(\\S*)=(\\S*)";
-
- private final Matcher matcher;
-
- ShardingCTLSetParser(final String sql) {
- matcher = Pattern.compile(regex, Pattern.CASE_INSENSITIVE).matcher(sql);
- }
-
- @Override
- public Optional<ShardingCTLSetStatement> doParse() {
- if (matcher.find()) {
- String key = matcher.group(1);
- String value = matcher.group(2);
- Preconditions.checkNotNull(key, "sctl key cannot be null.");
- Preconditions.checkNotNull(value, "sctl value cannot be null.");
- return Optional.of(new ShardingCTLSetStatement(key, value));
- }
- return Optional.empty();
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/set/ShardingCTLSetStatement.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/set/ShardingCTLSetStatement.java
deleted file mode 100644
index edfa6cd..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/set/ShardingCTLSetStatement.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.set;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.text.sctl.ShardingCTLStatement;
-
-/**
- * Sharding CTL set statement.
- */
-@RequiredArgsConstructor
-@Getter
-public final class ShardingCTLSetStatement implements ShardingCTLStatement {
-
- private final String key;
-
- private final String value;
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/show/ShardingCTLShowBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/show/ShardingCTLShowBackendHandler.java
deleted file mode 100644
index 426ffee..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/show/ShardingCTLShowBackendHandler.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.show;
-
-import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
-import org.apache.shardingsphere.infra.merge.result.MergedResult;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
-import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
-import org.apache.shardingsphere.proxy.backend.text.sctl.exception.InvalidShardingCTLFormatException;
-import org.apache.shardingsphere.proxy.backend.text.sctl.exception.UnsupportedShardingCTLTypeException;
-import org.apache.shardingsphere.sharding.merge.dal.common.MultipleLocalDataMergedResult;
-
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Collection;
-import java.util.Optional;
-
-/**
- * Sharding CTL show backend handler.
- */
-public final class ShardingCTLShowBackendHandler implements TextProtocolBackendHandler {
-
- private final String sql;
-
- private final BackendConnection backendConnection;
-
- private MergedResult mergedResult;
-
- public ShardingCTLShowBackendHandler(final String sql, final BackendConnection backendConnection) {
- this.sql = sql.toUpperCase().trim();
- this.backendConnection = backendConnection;
- }
-
- @Override
- public ResponseHeader execute() {
- Optional<ShardingCTLShowStatement> showStatement = new ShardingCTLShowParser(sql).doParse();
- if (!showStatement.isPresent()) {
- throw new InvalidShardingCTLFormatException(sql);
- }
- switch (showStatement.get().getValue()) {
- case "TRANSACTION_TYPE":
- return createResponsePackets("TRANSACTION_TYPE", backendConnection.getTransactionStatus().getTransactionType().name());
- case "CACHED_CONNECTIONS":
- return createResponsePackets("CACHED_CONNECTIONS", backendConnection.getConnectionSize());
- default:
- throw new UnsupportedShardingCTLTypeException(sql);
- }
- }
-
- private ResponseHeader createResponsePackets(final String columnName, final Object... values) {
- mergedResult = new MultipleLocalDataMergedResult(Collections.singletonList(Arrays.asList(values)));
- return new QueryResponseHeader(Collections.singletonList(new QueryHeader("", "", columnName, columnName, Types.VARCHAR, "VARCHAR", 100, 0, false, false, false, false)));
- }
-
- @Override
- public boolean next() throws SQLException {
- return null != mergedResult && mergedResult.next();
- }
-
- @Override
- public Collection<Object> getRowData() throws SQLException {
- return Collections.singletonList(mergedResult.getValue(1, Object.class));
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/show/ShardingCTLShowParser.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/show/ShardingCTLShowParser.java
deleted file mode 100644
index f39e237..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/show/ShardingCTLShowParser.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.show;
-
-import com.google.common.base.Preconditions;
-import org.apache.shardingsphere.proxy.backend.text.sctl.ShardingCTLParser;
-
-import java.util.Optional;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Sharding CTL show parser.
- */
-public final class ShardingCTLShowParser implements ShardingCTLParser<ShardingCTLShowStatement> {
-
- private final String regex = "sctl:show\\s+(\\S*)";
-
- private final Matcher matcher;
-
- ShardingCTLShowParser(final String sql) {
- matcher = Pattern.compile(regex, Pattern.CASE_INSENSITIVE).matcher(sql);
- }
-
- @Override
- public Optional<ShardingCTLShowStatement> doParse() {
- if (matcher.find()) {
- String value = matcher.group(1);
- Preconditions.checkNotNull(value, "sctl show value cannot be null.");
- return Optional.of(new ShardingCTLShowStatement(value));
- }
- return Optional.empty();
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/show/ShardingCTLShowStatement.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/show/ShardingCTLShowStatement.java
deleted file mode 100644
index 76f87bd..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/show/ShardingCTLShowStatement.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.show;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.text.sctl.ShardingCTLStatement;
-
-/**
- * Sharding CTL show statement.
- */
-@RequiredArgsConstructor
-@Getter
-public final class ShardingCTLShowStatement implements ShardingCTLStatement {
-
- private final String value;
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/utils/SCTLUtils.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/utils/SCTLUtils.java
deleted file mode 100644
index c5130de..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/utils/SCTLUtils.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.utils;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-
-/**
- * SCTL utils.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class SCTLUtils {
-
- private static final String COMMENT_PREFIX = "/*";
-
- private static final String COMMENT_SUFFIX = "*/";
-
- private static final String SQL_END = ";";
-
- /**
- * Trim the comment of sql.
- *
- * @param sql SQL to be trim
- * @return remove comment from SQL
- */
- public static String trimComment(final String sql) {
- String result = sql;
- if (sql.startsWith(COMMENT_PREFIX)) {
- result = result.substring(sql.indexOf(COMMENT_SUFFIX) + 2);
- }
- if (sql.endsWith(SQL_END)) {
- result = result.substring(0, result.length() - 1);
- }
- return result.trim();
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/TextProtocolBackendHandlerFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/TextProtocolBackendHandlerFactoryTest.java
index fe6ffd5..bad46a6 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/TextProtocolBackendHandlerFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/TextProtocolBackendHandlerFactoryTest.java
@@ -32,8 +32,9 @@ import org.apache.shardingsphere.proxy.backend.text.admin.DatabaseAdminUpdateBac
import org.apache.shardingsphere.proxy.backend.text.data.impl.BroadcastDatabaseBackendHandler;
import org.apache.shardingsphere.proxy.backend.text.data.impl.SchemaAssignedDatabaseBackendHandler;
import org.apache.shardingsphere.proxy.backend.text.data.impl.UnicastDatabaseBackendHandler;
-import org.apache.shardingsphere.proxy.backend.text.sctl.set.ShardingCTLSetBackendHandler;
-import org.apache.shardingsphere.proxy.backend.text.sctl.show.ShardingCTLShowBackendHandler;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.HintDistSQLBackendHandler;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.SetDistSQLBackendHandler;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.ShowDistSQLBackendHandler;
import org.apache.shardingsphere.proxy.backend.text.skip.SkipBackendHandler;
import org.apache.shardingsphere.proxy.backend.text.transaction.TransactionBackendHandler;
import org.apache.shardingsphere.sql.parser.exception.SQLParsingException;
@@ -100,17 +101,16 @@ public final class TextProtocolBackendHandlerFactoryTest {
}
@Test
- public void assertNewInstanceWithSCTL() throws SQLException {
- String sql = "sctl:set transaction_type=XA";
+ public void assertNewInstanceWithCommonDistSQL() throws SQLException {
+ String sql = "set variable transaction_type=LOCAL";
TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
- assertThat(actual, instanceOf(ShardingCTLSetBackendHandler.class));
- }
-
- @Test
- public void assertNewInstanceSCTLWithComment() throws SQLException {
- String sql = "/*ApplicationName=DataGrip 2018.1.4*/ sctl:show cached_connections;";
- TextProtocolBackendHandler actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
- assertThat(actual, instanceOf(ShardingCTLShowBackendHandler.class));
+ assertThat(actual, instanceOf(SetDistSQLBackendHandler.class));
+ sql = "show variable transaction_type";
+ actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
+ assertThat(actual, instanceOf(ShowDistSQLBackendHandler.class));
+ sql = "set sharding hint database_value=1";
+ actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, backendConnection);
+ assertThat(actual, instanceOf(HintDistSQLBackendHandler.class));
}
@Test
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/ShardingCTLErrorCodeTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/ShardingCTLErrorCodeTest.java
deleted file mode 100644
index 39872a7..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/ShardingCTLErrorCodeTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl;
-
-import org.apache.shardingsphere.proxy.backend.text.sctl.exception.InvalidShardingCTLFormatException;
-import org.apache.shardingsphere.proxy.backend.text.sctl.exception.ShardingCTLException;
-import org.apache.shardingsphere.proxy.backend.text.sctl.exception.UnsupportedShardingCTLTypeException;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.mock;
-
-public final class ShardingCTLErrorCodeTest {
-
- @Test
- public void assertInvalidFormat() {
- assertThat(ShardingCTLErrorCode.INVALID_FORMAT.getErrorCode(), is(11000));
- assertThat(ShardingCTLErrorCode.INVALID_FORMAT.getSqlState(), is("S11000"));
- assertThat(ShardingCTLErrorCode.INVALID_FORMAT.getErrorMessage(), is("Invalid format for sharding ctl [%s]."));
- }
-
- @Test
- public void assertUnsupportedType() {
- assertThat(ShardingCTLErrorCode.UNSUPPORTED_TYPE.getErrorCode(), is(11001));
- assertThat(ShardingCTLErrorCode.UNSUPPORTED_TYPE.getSqlState(), is("S11001"));
- assertThat(ShardingCTLErrorCode.UNSUPPORTED_TYPE.getErrorMessage(), is("Could not support sctl type [%s]."));
- }
-
- @Test
- public void assertValueOfWithInvalidFormat() {
- assertThat(ShardingCTLErrorCode.valueOf(new InvalidShardingCTLFormatException("test")), is(ShardingCTLErrorCode.INVALID_FORMAT));
- }
-
- @Test
- public void assertValueOfWithUnsupportedType() {
- assertThat(ShardingCTLErrorCode.valueOf(new UnsupportedShardingCTLTypeException("test")), is(ShardingCTLErrorCode.UNSUPPORTED_TYPE));
- }
-
- @Test(expected = UnsupportedOperationException.class)
- public void assertValueOfWithUnsupportedUnsupportedOperationException() {
- ShardingCTLErrorCode.valueOf(mock(ShardingCTLException.class));
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainBackendHandlerTest.java
deleted file mode 100644
index 669a1e1..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainBackendHandlerTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package org.apache.shardingsphere.proxy.backend.text.sctl.explain;
-
-import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
-import org.apache.shardingsphere.infra.context.manager.ContextManager;
-import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
-import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
-import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
-import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.infra.metadata.resource.CachedDatabaseMetaData;
-import org.apache.shardingsphere.infra.metadata.resource.DataSourcesMetaData;
-import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
-import org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
-import org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
-import org.apache.shardingsphere.infra.optimize.context.OptimizeContextFactory;
-import org.apache.shardingsphere.infra.persist.DistMetaDataPersistService;
-import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.sql.DataSource;
-import java.lang.reflect.Field;
-import java.sql.SQLException;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public final class ShardingCTLExplainBackendHandlerTest {
-
- private ShardingCTLExplainBackendHandler handler;
-
- @Before
- public void setUp() throws IllegalAccessException, NoSuchFieldException {
- BackendConnection connection = mock(BackendConnection.class);
- when(connection.getSchemaName()).thenReturn("schema");
- when(connection.getDefaultSchemaName()).thenReturn("schema");
- handler = new ShardingCTLExplainBackendHandler("sctl:explain select 1", connection);
- Field contextManagerField = ProxyContext.getInstance().getClass().getDeclaredField("contextManager");
- contextManagerField.setAccessible(true);
- ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
- MetaDataContexts metaDataContexts = new MetaDataContexts(mock(DistMetaDataPersistService.class), getMetaDataMap(),
- mock(ShardingSphereRuleMetaData.class), mock(ExecutorEngine.class), new ConfigurationProperties(new Properties()), mock(OptimizeContextFactory.class));
- when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
- contextManagerField.set(ProxyContext.getInstance(), contextManager);
- }
-
- private Map<String, ShardingSphereMetaData> getMetaDataMap() {
- ShardingSphereResource resource = new ShardingSphereResource(
- Collections.singletonMap("ds0", mock(DataSource.class)), mock(DataSourcesMetaData.class, RETURNS_DEEP_STUBS), mock(CachedDatabaseMetaData.class), new MySQLDatabaseType());
- ShardingSphereMetaData metaData = new ShardingSphereMetaData("schema",
- resource, new ShardingSphereRuleMetaData(Collections.emptyList(), Collections.singleton(mock(ShardingSphereRule.class))), mock(ShardingSphereSchema.class));
- return Collections.singletonMap("schema", metaData);
- }
-
- @Test
- public void assertGetRowData() throws SQLException {
- handler.execute();
- assertTrue(handler.next());
- Iterator<Object> iterator = handler.getRowData().iterator();
- assertThat(iterator.next(), is("ds0"));
- assertThat(iterator.next(), is("select 1"));
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintBackendHandlerTest.java
deleted file mode 100644
index dd56e65..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintBackendHandlerTest.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint;
-
-import com.google.common.collect.ImmutableMap;
-import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
-import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
-import org.apache.shardingsphere.infra.context.manager.ContextManager;
-import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
-import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
-import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
-import org.apache.shardingsphere.infra.hint.HintManager;
-import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
-import org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
-import org.apache.shardingsphere.infra.metadata.schema.model.TableMetaData;
-import org.apache.shardingsphere.infra.optimize.context.OptimizeContextFactory;
-import org.apache.shardingsphere.infra.persist.DistMetaDataPersistService;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
-import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
-import org.apache.shardingsphere.proxy.backend.text.sctl.exception.InvalidShardingCTLFormatException;
-import org.apache.shardingsphere.proxy.backend.text.sctl.exception.UnsupportedShardingCTLTypeException;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintManagerHolder;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-
-import java.lang.reflect.Field;
-import java.sql.SQLException;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
-public final class ShardingCTLHintBackendHandlerTest {
-
- @Mock
- private BackendConnection backendConnection;
-
- @Before
- public void setUp() {
- MetaDataContexts metaDataContexts = mock(MetaDataContexts.class, RETURNS_DEEP_STUBS);
- when(metaDataContexts.getProps().getValue(ConfigurationPropertyKey.PROXY_HINT_ENABLED)).thenReturn(true);
- ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
- when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
- ProxyContext.getInstance().init(contextManager);
- }
-
- @Test(expected = InvalidShardingCTLFormatException.class)
- public void assertInvalidShardingCTLFormat() {
- clearThreadLocal();
- String sql = "sctl:hint1 xx=yy";
- new ShardingCTLHintBackendHandler(sql, backendConnection).execute();
- }
-
- private void clearThreadLocal() {
- HintManagerHolder.get().close();
- HintManagerHolder.remove();
- }
-
- @Test
- public void assertSetPrimaryOnly() {
- clearThreadLocal();
- String sql = "sctl:hint set primary_only=true ";
- ShardingCTLHintBackendHandler hintBackendHandler = new ShardingCTLHintBackendHandler(sql, backendConnection);
- assertThat(hintBackendHandler.execute(), instanceOf(UpdateResponseHeader.class));
- assertTrue(HintManager.isWriteRouteOnly());
- }
-
- @Test
- public void assertSetDatabaseShardingValueTable() {
- clearThreadLocal();
- String sql = "sctl:hint set databaseShardingValue=100";
- ShardingCTLHintBackendHandler hintBackendHandler = new ShardingCTLHintBackendHandler(sql, backendConnection);
- assertThat(hintBackendHandler.execute(), instanceOf(UpdateResponseHeader.class));
- assertThat(HintManager.getDatabaseShardingValues().iterator().next().toString(), is("100"));
- }
-
- @Test
- public void assertAddDatabaseShardingValue() {
- clearThreadLocal();
- String sql = "sctl:hint addDatabaseShardingValue user=100 ";
- ShardingCTLHintBackendHandler hintBackendHandler = new ShardingCTLHintBackendHandler(sql, backendConnection);
- assertThat(hintBackendHandler.execute(), instanceOf(UpdateResponseHeader.class));
- assertThat(HintManager.getDatabaseShardingValues("user").iterator().next().toString(), is("100"));
- }
-
- @Test
- public void assertAddTableShardingValue() {
- clearThreadLocal();
- String sql = "sctl:hint addTableShardingValue user=100 ";
- ShardingCTLHintBackendHandler hintBackendHandler = new ShardingCTLHintBackendHandler(sql, backendConnection);
- assertThat(hintBackendHandler.execute(), instanceOf(UpdateResponseHeader.class));
- assertThat(HintManager.getTableShardingValues("user").iterator().next().toString(), is("100"));
- }
-
- @Test
- public void assertClear() {
- clearThreadLocal();
- String sql = "sctl:hint clear ";
- ShardingCTLHintBackendHandler hintBackendHandler = new ShardingCTLHintBackendHandler(sql, backendConnection);
- assertThat(hintBackendHandler.execute(), instanceOf(UpdateResponseHeader.class));
- assertThat(HintManager.getInstance(), instanceOf(HintManager.class));
- HintManager.clear();
- }
-
- @Test
- public void assertShowStatus() throws SQLException {
- clearThreadLocal();
- String sql = "sctl:hint show status";
- ShardingCTLHintBackendHandler defaultHintBackendHandler = new ShardingCTLHintBackendHandler(sql, backendConnection);
- ResponseHeader responseHeader = defaultHintBackendHandler.execute();
- assertThat(responseHeader, instanceOf(QueryResponseHeader.class));
- assertThat(((QueryResponseHeader) responseHeader).getQueryHeaders().get(0).getColumnLabel(), is("primary_only"));
- assertThat(((QueryResponseHeader) responseHeader).getQueryHeaders().get(1).getColumnLabel(), is("sharding_type"));
- assertTrue(defaultHintBackendHandler.next());
- Iterator<Object> defaultRowData = defaultHintBackendHandler.getRowData().iterator();
- assertThat(defaultRowData.next().toString(), is("false"));
- assertThat(defaultRowData.next().toString(), is("databases_tables"));
- assertFalse(defaultHintBackendHandler.next());
- String setPrimaryOnlySQL = "sctl:hint set primary_only=true";
- String setDatabaseOnlySQL = "sctl:hint set DatabaseShardingValue=100";
- new ShardingCTLHintBackendHandler(setPrimaryOnlySQL, backendConnection).execute();
- new ShardingCTLHintBackendHandler(setDatabaseOnlySQL, backendConnection).execute();
- ShardingCTLHintBackendHandler updateHintBackendHandler = new ShardingCTLHintBackendHandler(sql, backendConnection);
- updateHintBackendHandler.execute();
- assertTrue(updateHintBackendHandler.next());
- Iterator<Object> updateRowData = updateHintBackendHandler.getRowData().iterator();
- assertThat(updateRowData.next().toString(), is("true"));
- assertThat(updateRowData.next().toString(), is("databases_only"));
- assertFalse(updateHintBackendHandler.next());
- }
-
- @Test
- public void assertShowTableStatus() throws SQLException, NoSuchFieldException, IllegalAccessException {
- clearThreadLocal();
- when(backendConnection.getSchemaName()).thenReturn("schema");
- Field contextManagerField = ProxyContext.getInstance().getClass().getDeclaredField("contextManager");
- contextManagerField.setAccessible(true);
- Properties props = new Properties();
- props.setProperty(ConfigurationPropertyKey.PROXY_HINT_ENABLED.getKey(), Boolean.TRUE.toString());
- MetaDataContexts metaDataContexts = new MetaDataContexts(mock(DistMetaDataPersistService.class), getMetaDataMap(), mock(ShardingSphereRuleMetaData.class),
- mock(ExecutorEngine.class), new ConfigurationProperties(props), mock(OptimizeContextFactory.class));
- ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
- when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
- contextManagerField.set(ProxyContext.getInstance(), contextManager);
- String sql = "sctl:hint show table status";
- ShardingCTLHintBackendHandler defaultHintBackendHandler = new ShardingCTLHintBackendHandler(sql, backendConnection);
- ResponseHeader responseHeader = defaultHintBackendHandler.execute();
- assertThat(responseHeader, instanceOf(QueryResponseHeader.class));
- assertThat(((QueryResponseHeader) responseHeader).getQueryHeaders().get(0).getColumnLabel(), is("table_name"));
- assertThat(((QueryResponseHeader) responseHeader).getQueryHeaders().get(1).getColumnLabel(), is("database_sharding_values"));
- assertThat(((QueryResponseHeader) responseHeader).getQueryHeaders().get(2).getColumnLabel(), is("table_sharding_values"));
- assertTrue(defaultHintBackendHandler.next());
- Iterator<Object> defaultRowData = defaultHintBackendHandler.getRowData().iterator();
- assertThat(defaultRowData.next().toString(), is("user"));
- assertThat(defaultRowData.next().toString(), is(""));
- assertThat(defaultRowData.next().toString(), is(""));
- assertFalse(defaultHintBackendHandler.next());
- String addDatabaseShardingValueSQL = "sctl:hint addDatabaseshardingvalue user=100";
- String addTableShardingValueSQL1 = "sctl:hint addTableshardingvalue user=200";
- String addTableShardingValueSQL2 = "sctl:hint addTableshardingvalue user=300";
- new ShardingCTLHintBackendHandler(addDatabaseShardingValueSQL, backendConnection).execute();
- new ShardingCTLHintBackendHandler(addTableShardingValueSQL1, backendConnection).execute();
- new ShardingCTLHintBackendHandler(addTableShardingValueSQL2, backendConnection).execute();
- ShardingCTLHintBackendHandler updateHintBackendHandler = new ShardingCTLHintBackendHandler(sql, backendConnection);
- updateHintBackendHandler.execute();
- assertTrue(updateHintBackendHandler.next());
- Iterator<Object> updateRowData = updateHintBackendHandler.getRowData().iterator();
- assertThat(updateRowData.next().toString(), is("user"));
- assertThat(updateRowData.next().toString(), is("100"));
- assertThat(updateRowData.next().toString(), is("200,300"));
- assertFalse(updateHintBackendHandler.next());
- }
-
- private Map<String, ShardingSphereMetaData> getMetaDataMap() {
- ShardingSphereMetaData metaData = mock(ShardingSphereMetaData.class, RETURNS_DEEP_STUBS);
- when(metaData.getSchema()).thenReturn(new ShardingSphereSchema(ImmutableMap.of("user", mock(TableMetaData.class))));
- when(metaData.isComplete()).thenReturn(true);
- when(metaData.getResource().getDatabaseType()).thenReturn(new H2DatabaseType());
- return Collections.singletonMap("schema", metaData);
- }
-
- @Test(expected = UnsupportedShardingCTLTypeException.class)
- public void assertUnsupportedShardingCTLType() {
- clearThreadLocal();
- String sql = "sctl:hint xx=yy";
- new ShardingCTLHintBackendHandler(sql, backendConnection).execute();
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintParserTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintParserTest.java
deleted file mode 100644
index fd04cbb..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintParserTest.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint;
-
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintAddDatabaseShardingValueCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintAddTableShardingValueCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintClearCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintErrorParameterCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintSetDatabaseShardingValueCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintSetPrimaryOnlyCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintShowStatusCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintShowTableStatusCommand;
-import org.junit.Test;
-
-import java.util.Optional;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-public final class ShardingCTLHintParserTest {
-
- @Test
- public void assertValidSetPrimaryOnlySQL() {
- String sql = "sctl:hint set primary_only=true ";
- Optional<ShardingCTLHintStatement> actual = new ShardingCTLHintParser(sql).doParse();
- assertTrue(actual.isPresent());
- assertTrue(((HintSetPrimaryOnlyCommand) actual.get().getHintCommand()).isPrimaryOnly());
- }
-
- @Test
- public void assertInValidSetPrimaryOnlySQL() {
- String sql = "sctl:hint set primary_only1=true ";
- Optional<ShardingCTLHintStatement> actual = new ShardingCTLHintParser(sql).doParse();
- assertTrue(actual.isPresent());
- assertThat(actual.get().getHintCommand(), instanceOf(HintErrorParameterCommand.class));
- }
-
- @Test
- public void assertValidSetDatabaseShardingValueSQL() {
- String sql = " sctl:HINT set DatabaseShardingValue=100 ";
- Optional<ShardingCTLHintStatement> actual = new ShardingCTLHintParser(sql).doParse();
- assertTrue(actual.isPresent());
- assertThat(((HintSetDatabaseShardingValueCommand) actual.get().getHintCommand()).getValue(), is("100"));
- }
-
- @Test
- public void assertInValidSetDatabaseShardingValueSQL() {
- String sql = " sctl:HINT set DatabaseShardingValue1=100 ";
- Optional<ShardingCTLHintStatement> actual = new ShardingCTLHintParser(sql).doParse();
- assertTrue(actual.isPresent());
- assertThat(actual.get().getHintCommand(), instanceOf(HintErrorParameterCommand.class));
- }
-
- @Test
- public void assertValidAddDatabaseShardingValueSQL() {
- String sql = " sctl:HINT addDatabaseShardingValue user=100 ";
- Optional<ShardingCTLHintStatement> actual = new ShardingCTLHintParser(sql).doParse();
- assertTrue(actual.isPresent());
- HintAddDatabaseShardingValueCommand databaseCommand = (HintAddDatabaseShardingValueCommand) actual.get().getHintCommand();
- assertThat(databaseCommand.getLogicTable(), is("user"));
- assertThat(databaseCommand.getValue(), is("100"));
- }
-
- @Test
- public void assertInValidAddDatabaseShardingValueSQL() {
- String sql = " sctl:HINT addDatabaseShardingValue1 user=100 ";
- Optional<ShardingCTLHintStatement> actual = new ShardingCTLHintParser(sql).doParse();
- assertTrue(actual.isPresent());
- assertThat(actual.get().getHintCommand(), instanceOf(HintErrorParameterCommand.class));
- }
-
- @Test
- public void assertValidAddTableShardingValueSQL() {
- String sql = " sctl:HINT addTableShardingValue order=some ";
- Optional<ShardingCTLHintStatement> actual = new ShardingCTLHintParser(sql).doParse();
- assertTrue(actual.isPresent());
- HintAddTableShardingValueCommand tableCommand = (HintAddTableShardingValueCommand) actual.get().getHintCommand();
- assertThat(tableCommand.getLogicTable(), is("order"));
- assertThat(tableCommand.getValue(), is("some"));
- }
-
- @Test
- public void assertInValidAddTableShardingValueSQL() {
- String sql = " sctl:HINT addTableShardingValue 100 ";
- Optional<ShardingCTLHintStatement> actual = new ShardingCTLHintParser(sql).doParse();
- assertTrue(actual.isPresent());
- assertThat(actual.get().getHintCommand(), instanceOf(HintErrorParameterCommand.class));
- }
-
- @Test
- public void assertInValidAddShardingValueSQL() {
- String databaseSQL = " sctl:HINT addShardingValue1 value_Type=database user=100 ";
- Optional<ShardingCTLHintStatement> databaseSQLActual = new ShardingCTLHintParser(databaseSQL).doParse();
- assertTrue(databaseSQLActual.isPresent());
- assertThat(databaseSQLActual.get().getHintCommand(), instanceOf(HintErrorParameterCommand.class));
- String tableSQL = " sctl:HINT addShardingValue Value_Type=Table1 order=some ";
- Optional<ShardingCTLHintStatement> tableSQLActual = new ShardingCTLHintParser(tableSQL).doParse();
- assertTrue(tableSQLActual.isPresent());
- assertThat(tableSQLActual.get().getHintCommand(), instanceOf(HintErrorParameterCommand.class));
- }
-
- @Test
- public void assertValidClearSQL() {
- String sql = " sctl:HINT clear ";
- Optional<ShardingCTLHintStatement> actual = new ShardingCTLHintParser(sql).doParse();
- assertTrue(actual.isPresent());
- assertThat(actual.get().getHintCommand(), instanceOf(HintClearCommand.class));
- }
-
- @Test
- public void assertInValidClearSQL() {
- String sql = " sctl:HINT clear xxx";
- Optional<ShardingCTLHintStatement> actual = new ShardingCTLHintParser(sql).doParse();
- assertTrue(actual.isPresent());
- assertThat(actual.get().getHintCommand(), instanceOf(HintErrorParameterCommand.class));
- }
-
- @Test
- public void assertValidShowStatusSQL() {
- String sql = " sctl:HINT show status ";
- Optional<ShardingCTLHintStatement> actual = new ShardingCTLHintParser(sql).doParse();
- assertTrue(actual.isPresent());
- assertThat(actual.get().getHintCommand(), instanceOf(HintShowStatusCommand.class));
- }
-
- @Test
- public void assertInValidShowStatusSQL() {
- String sql = " sctl:HINT show status1";
- Optional<ShardingCTLHintStatement> actual = new ShardingCTLHintParser(sql).doParse();
- assertTrue(actual.isPresent());
- assertThat(actual.get().getHintCommand(), instanceOf(HintErrorParameterCommand.class));
- }
-
- @Test
- public void assertValidShowTableStatusSQL() {
- String sql = " sctl:HINT show table status ";
- Optional<ShardingCTLHintStatement> actual = new ShardingCTLHintParser(sql).doParse();
- assertTrue(actual.isPresent());
- assertThat(actual.get().getHintCommand(), instanceOf(HintShowTableStatusCommand.class));
- }
-
- @Test
- public void assertInValidShowTableStatusSQL() {
- String sql = " sctl:HINT show table status1";
- Optional<ShardingCTLHintStatement> actual = new ShardingCTLHintParser(sql).doParse();
- assertTrue(actual.isPresent());
- assertThat(actual.get().getHintCommand(), instanceOf(HintErrorParameterCommand.class));
- }
-
- @Test
- public void assertNotHintSQL() {
- String sql = "sctl:hint1 abcd efg hijk lmn";
- assertFalse(new ShardingCTLHintParser(sql).doParse().isPresent());
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/HintCommandExecutorFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/HintCommandExecutorFactoryTest.java
deleted file mode 100644
index 7e2236f..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/HintCommandExecutorFactoryTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal;
-
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintAddDatabaseShardingValueCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintAddTableShardingValueCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintClearCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintErrorParameterCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintSetDatabaseShardingValueCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintSetPrimaryOnlyCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintShowStatusCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.command.HintShowTableStatusCommand;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor.HintAddDatabaseShardingValueExecutor;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor.HintAddTableShardingValueExecutor;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor.HintClearExecutor;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor.HintErrorParameterExecutor;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor.HintSetDatabaseShardingValueExecutor;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor.HintSetPrimaryOnlyExecutor;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor.HintShowStatusExecutor;
-import org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.executor.HintShowTableStatusExecutor;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.mock;
-
-@RunWith(MockitoJUnitRunner.class)
-public final class HintCommandExecutorFactoryTest {
-
- @Mock
- private BackendConnection backendConnection;
-
- @Test
- public void assertHintSetPrimaryOnlyExecutor() {
- String sql = "sctl:hint set primary_only=false";
- HintCommand hintCommand = mock(HintSetPrimaryOnlyCommand.class);
- assertThat(HintCommandExecutorFactory.newInstance(hintCommand, backendConnection, sql), instanceOf(HintSetPrimaryOnlyExecutor.class));
- }
-
- @Test
- public void assertHintSetDatabaseShardingValueExecutor() {
- String sql = "sctl:hint set DatabaseShardingValue=100";
- HintCommand hintCommand = mock(HintSetDatabaseShardingValueCommand.class);
- assertThat(HintCommandExecutorFactory.newInstance(hintCommand, backendConnection, sql), instanceOf(HintSetDatabaseShardingValueExecutor.class));
- }
-
- @Test
- public void assertHintAddDatabaseShardingValueExecutor() {
- String sql = "sctl:hint addDatabaseShardingValue user=100";
- HintCommand hintCommand = mock(HintAddDatabaseShardingValueCommand.class);
- assertThat(HintCommandExecutorFactory.newInstance(hintCommand, backendConnection, sql), instanceOf(HintAddDatabaseShardingValueExecutor.class));
- }
-
- @Test
- public void assertHintAddTableShardingValueExecutor() {
- String sql = "sctl:hint addTableShardingValue user=100";
- HintCommand hintCommand = mock(HintAddTableShardingValueCommand.class);
- assertThat(HintCommandExecutorFactory.newInstance(hintCommand, backendConnection, sql), instanceOf(HintAddTableShardingValueExecutor.class));
- }
-
- @Test
- public void assertHintClearExecutor() {
- String sql = "sctl:hint clear ";
- HintCommand hintCommand = mock(HintClearCommand.class);
- assertThat(HintCommandExecutorFactory.newInstance(hintCommand, backendConnection, sql), instanceOf(HintClearExecutor.class));
- }
-
- @Test
- public void assertHintShowStatusExecutor() {
- String sql = "sctl:hint show status ";
- HintCommand hintCommand = mock(HintShowStatusCommand.class);
- assertThat(HintCommandExecutorFactory.newInstance(hintCommand, backendConnection, sql), instanceOf(HintShowStatusExecutor.class));
- }
-
- @Test
- public void assertHintShowTableStatusExecutor() {
- String sql = "sctl:hint show table status ";
- HintCommand hintCommand = mock(HintShowTableStatusCommand.class);
- assertThat(HintCommandExecutorFactory.newInstance(hintCommand, backendConnection, sql), instanceOf(HintShowTableStatusExecutor.class));
- }
-
- @Test
- public void assertHintErrorParameterExecutor() {
- String sql = "sctl:hint bad parameters ";
- HintCommand hintCommand = mock(HintErrorParameterCommand.class);
- assertThat(HintCommandExecutorFactory.newInstance(hintCommand, backendConnection, sql), instanceOf(HintErrorParameterExecutor.class));
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/set/ShardingCTLSetBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/set/ShardingCTLSetBackendHandlerTest.java
deleted file mode 100644
index 2c05c8d..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/set/ShardingCTLSetBackendHandlerTest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.set;
-
-import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
-import org.apache.shardingsphere.infra.context.manager.ContextManager;
-import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
-import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
-import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
-import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
-import org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
-import org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
-import org.apache.shardingsphere.infra.optimize.context.OptimizeContextFactory;
-import org.apache.shardingsphere.infra.persist.DistMetaDataPersistService;
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
-import org.apache.shardingsphere.proxy.backend.text.sctl.exception.InvalidShardingCTLFormatException;
-import org.apache.shardingsphere.proxy.backend.text.sctl.exception.UnsupportedShardingCTLTypeException;
-import org.apache.shardingsphere.transaction.core.TransactionType;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.lang.reflect.Field;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public final class ShardingCTLSetBackendHandlerTest {
-
- private static final String SCHEMA_PATTERN = "schema_%s";
-
- private final BackendConnection backendConnection = new BackendConnection(TransactionType.LOCAL);
-
- @Before
- public void setUp() throws NoSuchFieldException, IllegalAccessException {
- Field contextManagerField = ProxyContext.getInstance().getClass().getDeclaredField("contextManager");
- contextManagerField.setAccessible(true);
- ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
- MetaDataContexts metaDataContexts = new MetaDataContexts(mock(DistMetaDataPersistService.class),
- getMetaDataMap(), mock(ShardingSphereRuleMetaData.class), mock(ExecutorEngine.class), new ConfigurationProperties(new Properties()), mock(OptimizeContextFactory.class));
- when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
- contextManagerField.set(ProxyContext.getInstance(), contextManager);
- }
-
- private Map<String, ShardingSphereMetaData> getMetaDataMap() {
- Map<String, ShardingSphereMetaData> result = new HashMap<>(10, 1);
- for (int i = 0; i < 10; i++) {
- ShardingSphereMetaData metaData = mock(ShardingSphereMetaData.class);
- ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
- when(metaData.getResource()).thenReturn(new ShardingSphereResource(Collections.emptyMap(), null, null, new MySQLDatabaseType()));
- when(metaData.getRuleMetaData()).thenReturn(new ShardingSphereRuleMetaData(Collections.emptyList(), Collections.emptyList()));
- when(metaData.getSchema()).thenReturn(schema);
- result.put(String.format(SCHEMA_PATTERN, i), metaData);
- }
- return result;
- }
-
- @Test
- public void assertSwitchTransactionTypeXA() {
- backendConnection.setCurrentSchema(String.format(SCHEMA_PATTERN, 0));
- ShardingCTLSetBackendHandler shardingCTLBackendHandler = new ShardingCTLSetBackendHandler("sctl:set transaction_type=XA", backendConnection);
- ResponseHeader actual = shardingCTLBackendHandler.execute();
- assertThat(actual, instanceOf(UpdateResponseHeader.class));
- assertThat(backendConnection.getTransactionStatus().getTransactionType(), is(TransactionType.XA));
- }
-
- @Test
- public void assertSwitchTransactionTypeBASE() {
- backendConnection.setCurrentSchema(String.format(SCHEMA_PATTERN, 0));
- ShardingCTLSetBackendHandler shardingCTLBackendHandler = new ShardingCTLSetBackendHandler("sctl:set transaction_type=BASE", backendConnection);
- ResponseHeader actual = shardingCTLBackendHandler.execute();
- assertThat(actual, instanceOf(UpdateResponseHeader.class));
- assertThat(backendConnection.getTransactionStatus().getTransactionType(), is(TransactionType.BASE));
- }
-
- @Test
- public void assertSwitchTransactionTypeLOCAL() {
- backendConnection.setCurrentSchema(String.format(SCHEMA_PATTERN, 0));
- ShardingCTLSetBackendHandler shardingCTLBackendHandler = new ShardingCTLSetBackendHandler("sctl:set transaction_type=LOCAL", backendConnection);
- ResponseHeader actual = shardingCTLBackendHandler.execute();
- assertThat(actual, instanceOf(UpdateResponseHeader.class));
- assertThat(backendConnection.getTransactionStatus().getTransactionType(), is(TransactionType.LOCAL));
- }
-
- @Test(expected = UnsupportedShardingCTLTypeException.class)
- public void assertSwitchTransactionTypeFailed() {
- backendConnection.setCurrentSchema(String.format(SCHEMA_PATTERN, 0));
- new ShardingCTLSetBackendHandler("sctl:set transaction_type=XXX", backendConnection).execute();
- }
-
- @Test(expected = UnsupportedShardingCTLTypeException.class)
- public void assertNotSupportedSCTL() {
- new ShardingCTLSetBackendHandler("sctl:set @@session=XXX", backendConnection).execute();
- }
-
- @Test(expected = InvalidShardingCTLFormatException.class)
- public void assertFormatErrorSCTL() {
- new ShardingCTLSetBackendHandler("sctl:set yyyyy", backendConnection).execute();
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/show/ShardingCTLShowBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/show/ShardingCTLShowBackendHandlerTest.java
deleted file mode 100644
index 46ec702..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/show/ShardingCTLShowBackendHandlerTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.text.sctl.show;
-
-import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
-import org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
-import org.apache.shardingsphere.proxy.backend.text.sctl.exception.InvalidShardingCTLFormatException;
-import org.apache.shardingsphere.proxy.backend.text.sctl.exception.UnsupportedShardingCTLTypeException;
-import org.apache.shardingsphere.transaction.core.TransactionType;
-import org.junit.Test;
-
-import java.sql.SQLException;
-import java.util.Collection;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public final class ShardingCTLShowBackendHandlerTest {
-
- private final BackendConnection backendConnection = new BackendConnection(TransactionType.LOCAL);
-
- @Test
- public void assertShowTransactionType() throws SQLException {
- backendConnection.setCurrentSchema("schema");
- ShardingCTLShowBackendHandler backendHandler = new ShardingCTLShowBackendHandler("sctl:show transaction_type", backendConnection);
- ResponseHeader actual = backendHandler.execute();
- assertThat(actual, instanceOf(QueryResponseHeader.class));
- assertThat(((QueryResponseHeader) actual).getQueryHeaders().size(), is(1));
- backendHandler.next();
- Collection<Object> rowData = backendHandler.getRowData();
- assertThat(rowData.iterator().next(), is("LOCAL"));
- }
-
- @Test
- public void assertShowCachedConnections() throws SQLException {
- backendConnection.setCurrentSchema("schema");
- ShardingCTLShowBackendHandler backendHandler = new ShardingCTLShowBackendHandler("sctl:show cached_connections", backendConnection);
- ResponseHeader actual = backendHandler.execute();
- assertThat(actual, instanceOf(QueryResponseHeader.class));
- assertThat(((QueryResponseHeader) actual).getQueryHeaders().size(), is(1));
- backendHandler.next();
- Collection<Object> rowData = backendHandler.getRowData();
- assertThat(rowData.iterator().next(), is(0));
- }
-
- @Test(expected = UnsupportedShardingCTLTypeException.class)
- public void assertShowCachedConnectionFailed() {
- backendConnection.setCurrentSchema("schema");
- new ShardingCTLShowBackendHandler("sctl:show cached_connectionss", backendConnection).execute();
- }
-
- @Test(expected = InvalidShardingCTLFormatException.class)
- public void assertShowCTLFormatError() {
- backendConnection.setCurrentSchema("schema");
- new ShardingCTLShowBackendHandler("sctl:show=xx", backendConnection).execute();
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/exception/ExpectedExceptions.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/exception/ExpectedExceptions.java
index 9055085..cb642d0 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/exception/ExpectedExceptions.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/exception/ExpectedExceptions.java
@@ -22,7 +22,7 @@ import lombok.NoArgsConstructor;
import org.apache.shardingsphere.infra.config.exception.ShardingSphereConfigurationException;
import org.apache.shardingsphere.infra.exception.ShardingSphereException;
import org.apache.shardingsphere.proxy.backend.exception.BackendException;
-import org.apache.shardingsphere.proxy.backend.text.sctl.exception.ShardingCTLException;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.exception.CommonDistSQLException;
import org.apache.shardingsphere.sql.parser.exception.SQLParsingException;
import java.util.Collection;
@@ -40,7 +40,7 @@ public final class ExpectedExceptions {
EXCEPTIONS.add(ShardingSphereException.class);
EXCEPTIONS.add(ShardingSphereConfigurationException.class);
EXCEPTIONS.add(SQLParsingException.class);
- EXCEPTIONS.add(ShardingCTLException.class);
+ EXCEPTIONS.add(CommonDistSQLException.class);
EXCEPTIONS.add(BackendException.class);
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/exception/ExpectedExceptionsTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/exception/ExpectedExceptionsTest.java
index 3d748a1..3fd97f6 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/exception/ExpectedExceptionsTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/exception/ExpectedExceptionsTest.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.infra.config.exception.ShardingSphereConfigurat
import org.apache.shardingsphere.infra.exception.ShardingSphereException;
import org.apache.shardingsphere.proxy.backend.exception.BackendException;
import org.apache.shardingsphere.proxy.backend.exception.NoDatabaseSelectedException;
-import org.apache.shardingsphere.proxy.backend.text.sctl.exception.ShardingCTLException;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.exception.CommonDistSQLException;
import org.apache.shardingsphere.sql.parser.exception.SQLParsingException;
import org.junit.Test;
@@ -35,7 +35,7 @@ public final class ExpectedExceptionsTest {
assertTrue(ExpectedExceptions.isExpected(ShardingSphereException.class));
assertTrue(ExpectedExceptions.isExpected(ShardingSphereConfigurationException.class));
assertTrue(ExpectedExceptions.isExpected(SQLParsingException.class));
- assertTrue(ExpectedExceptions.isExpected(ShardingCTLException.class));
+ assertTrue(ExpectedExceptions.isExpected(CommonDistSQLException.class));
assertTrue(ExpectedExceptions.isExpected(BackendException.class));
assertTrue(ExpectedExceptions.isExpected(NoDatabaseSelectedException.class));
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactory.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactory.java
index d33e74a..f865f89 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactory.java
@@ -35,8 +35,6 @@ import org.apache.shardingsphere.proxy.backend.exception.TableModifyInTransactio
import org.apache.shardingsphere.proxy.backend.exception.UnknownDatabaseException;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.exception.CommonDistSQLErrorCode;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.exception.CommonDistSQLException;
-import org.apache.shardingsphere.proxy.backend.text.sctl.ShardingCTLErrorCode;
-import org.apache.shardingsphere.proxy.backend.text.sctl.exception.ShardingCTLException;
import org.apache.shardingsphere.proxy.frontend.exception.UnsupportedCommandException;
import org.apache.shardingsphere.proxy.frontend.exception.UnsupportedPreparedStatementException;
import org.apache.shardingsphere.scaling.core.common.exception.ScalingJobNotFoundException;
@@ -64,10 +62,6 @@ public final class MySQLErrPacketFactory {
return null == sqlException.getSQLState() ? new MySQLErrPacket(1, MySQLServerErrorCode.ER_INTERNAL_ERROR, cause.getMessage())
: new MySQLErrPacket(1, sqlException.getErrorCode(), sqlException.getSQLState(), sqlException.getMessage());
}
- if (cause instanceof ShardingCTLException) {
- ShardingCTLException shardingCTLException = (ShardingCTLException) cause;
- return new MySQLErrPacket(1, ShardingCTLErrorCode.valueOf(shardingCTLException), shardingCTLException.getShardingCTL());
- }
if (cause instanceof CommonDistSQLException) {
CommonDistSQLException ralCommonException = (CommonDistSQLException) cause;
return new MySQLErrPacket(1, CommonDistSQLErrorCode.valueOf(ralCommonException), ralCommonException.getVariable());
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactoryTest.java
index f886f07..04d0286 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactoryTest.java
@@ -27,8 +27,7 @@ import org.apache.shardingsphere.proxy.backend.exception.DBDropExistsException;
import org.apache.shardingsphere.proxy.backend.exception.NoDatabaseSelectedException;
import org.apache.shardingsphere.proxy.backend.exception.TableModifyInTransactionException;
import org.apache.shardingsphere.proxy.backend.exception.UnknownDatabaseException;
-import org.apache.shardingsphere.proxy.backend.text.sctl.exception.InvalidShardingCTLFormatException;
-import org.apache.shardingsphere.proxy.backend.text.sctl.exception.UnsupportedShardingCTLTypeException;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.exception.UnsupportedVariableException;
import org.apache.shardingsphere.proxy.frontend.exception.UnsupportedCommandException;
import org.apache.shardingsphere.proxy.frontend.exception.UnsupportedPreparedStatementException;
import org.apache.shardingsphere.sharding.route.engine.exception.NoSuchTableException;
@@ -75,21 +74,12 @@ public final class MySQLErrPacketFactoryTest {
}
@Test
- public void assertNewInstanceWithInvalidShardingCTLFormatException() {
- MySQLErrPacket actual = MySQLErrPacketFactory.newInstance(new InvalidShardingCTLFormatException("test"));
+ public void assertNewInstanceWithUnsupportedVariableExceptionException() {
+ MySQLErrPacket actual = MySQLErrPacketFactory.newInstance(new UnsupportedVariableException("test"));
assertThat(actual.getSequenceId(), is(1));
- assertThat(actual.getErrorCode(), is(11000));
- assertThat(actual.getSqlState(), is("S11000"));
- assertThat(actual.getErrorMessage(), is("Invalid format for sharding ctl [test]."));
- }
-
- @Test
- public void assertNewInstanceWithUnsupportedShardingCTLTypeException() {
- MySQLErrPacket actual = MySQLErrPacketFactory.newInstance(new UnsupportedShardingCTLTypeException("sctl:set xxx=xxx"));
- assertThat(actual.getSequenceId(), is(1));
- assertThat(actual.getErrorCode(), is(11001));
- assertThat(actual.getSqlState(), is("S11001"));
- assertThat(actual.getErrorMessage(), is("Could not support sctl type [sctl:set xxx=xxx]."));
+ assertThat(actual.getErrorCode(), is(11002));
+ assertThat(actual.getSqlState(), is("S11002"));
+ assertThat(actual.getErrorMessage(), is("Could not support variable [test]."));
}
@Test
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/SQLUtil.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/SQLUtil.java
index e1c2bfd..a6bfdee 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/SQLUtil.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/SQLUtil.java
@@ -68,6 +68,10 @@ public final class SQLUtil {
private static final String SQL_END = ";";
+ private static final String COMMENT_PREFIX = "/*";
+
+ private static final String COMMENT_SUFFIX = "*/";
+
/**
* Get exactly number value and type.
*
@@ -256,4 +260,21 @@ public final class SQLUtil {
public static String trimSemicolon(final String sql) {
return sql.endsWith(SQL_END) ? sql.substring(0, sql.length() - 1) : sql;
}
+
+ /**
+ * Trim the comment of sql.
+ *
+ * @param sql SQL to be trim
+ * @return remove comment from SQL
+ */
+ public static String trimComment(final String sql) {
+ String result = sql;
+ if (sql.startsWith(COMMENT_PREFIX)) {
+ result = result.substring(sql.indexOf(COMMENT_SUFFIX) + 2);
+ }
+ if (sql.endsWith(SQL_END)) {
+ result = result.substring(0, result.length() - 1);
+ }
+ return result.trim();
+ }
}