You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/01/12 12:27:13 UTC
[shardingsphere] branch master updated: Refactor the implementation of SHOW 'GLOBAL' RULE (#14715)
This is an automated email from the ASF dual-hosted git repository.
zhonghongsheng 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 1d36573 Refactor the implementation of SHOW 'GLOBAL' RULE (#14715)
1d36573 is described below
commit 1d36573866a65d7ae14473718b7b58a8091d0ae3
Author: Raigor <ra...@gmail.com>
AuthorDate: Wed Jan 12 20:26:21 2022 +0800
Refactor the implementation of SHOW 'GLOBAL' RULE (#14715)
* Refactor `SHOW TRANSACTION RULE`
---
.../src/main/antlr4/imports/RALStatement.g4 | 56 +++++++++-------
.../src/main/antlr4/imports/RQLStatement.g4 | 14 +---
.../parser/autogen/CommonDistSQLStatement.g4 | 2 +-
.../core/common/CommonDistSQLStatementVisitor.java | 4 +-
.../common}/show/ShowTransactionRuleStatement.java | 10 +--
.../common/show/ShowStatementExecutorFactory.java | 19 ++++--
.../show/executor/ShowAuthorityRuleExecutor.java | 18 +++--
.../show/executor/ShowSQLParserRuleExecutor.java | 9 +--
...cutor.java => ShowTransactionRuleExecutor.java} | 33 +++++----
.../distsql/rql/rule/TransactionRuleResultSet.java | 67 -------------------
...dingsphere.infra.distsql.query.DistSQLResultSet | 1 -
.../show/ShowTransactionRuleExecutorTest.java | 78 ++++++++++++++++++++++
.../distsql/rql/TransactionRuleResultSetTest.java | 66 ------------------
.../ral/impl/CommonDistSQLStatementAssert.java | 15 +++--
.../ShowTransactionRuleStatementAssert.java | 6 +-
.../distsql/rql/impl/ShowRulesStatementAssert.java | 5 --
.../jaxb/cases/domain/SQLParserTestCases.java | 2 +-
.../ShowTransactionRuleStatementTestCase.java | 6 +-
.../src/main/resources/case/ral/common.xml | 11 +--
.../src/main/resources/case/rql/show.xml | 2 -
.../main/resources/sql/supported/ral/common.xml | 5 +-
.../src/main/resources/sql/supported/rql/show.xml | 1 -
22 files changed, 184 insertions(+), 246 deletions(-)
diff --git a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RALStatement.g4 b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RALStatement.g4
index 78fbe9f..061b359 100644
--- a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RALStatement.g4
+++ b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RALStatement.g4
@@ -42,19 +42,7 @@ disableInstance
showInstance
: SHOW INSTANCE LIST
;
-
-showSQLParserRule
- : SHOW SQL_PARSER RULE
- ;
-
-alterSQLParserRule
- : ALTER SQL_PARSER RULE sqlParserRuleDefinition
- ;
-
-sqlParserRuleDefinition
- : (SQL_COMMENT_PARSE_ENABLE EQ sqlCommentParseEnable) (COMMA? PARSE_TREE_CACHE LP parseTreeCache RP)? (COMMA? SQL_STATEMENT_CACHE LP sqlStatementCache RP)?
- ;
-
+
clearHint
: CLEAR HINT
;
@@ -66,7 +54,27 @@ refreshTableMetadata
showTableMetadata
: SHOW TABLE METADATA tableName (COMMA tableName*)? (FROM schemaName)?
;
-
+
+showAuthorityRule
+ : SHOW AUTHORITY RULE
+ ;
+
+showTransactionRule
+ : SHOW TRANSACTION RULE
+ ;
+
+showSQLParserRule
+ : SHOW SQL_PARSER RULE
+ ;
+
+alterSQLParserRule
+ : ALTER SQL_PARSER RULE sqlParserRuleDefinition
+ ;
+
+sqlParserRuleDefinition
+ : (SQL_COMMENT_PARSE_ENABLE EQ sqlCommentParseEnable) (COMMA? PARSE_TREE_CACHE LP parseTreeCache RP)? (COMMA? SQL_STATEMENT_CACHE LP sqlStatementCache RP)?
+ ;
+
variableName
: IDENTIFIER
;
@@ -78,11 +86,11 @@ variableValue
instanceDefination
: IP EQ ip COMMA PORT EQ port
;
-
+
instanceId
: ip AT port
;
-
+
ip
: IDENTIFIER | NUMBER+
;
@@ -90,7 +98,7 @@ ip
port
: INT
;
-
+
refreshScope
: tableName | tableName FROM RESOURCE resourceName
;
@@ -102,31 +110,31 @@ resourceName
tableName
: IDENTIFIER
;
-
+
sqlCommentParseEnable
: TRUE | FALSE
;
-
+
parseTreeCache
: cacheOption
;
-
+
sqlStatementCache
: cacheOption
;
-
+
cacheOption
: (INITIAL_CAPACITY EQ initialCapacity)? (COMMA? MAXIMUM_SIZE EQ maximumSize)? (COMMA? CONCURRENCY_LEVEL EQ concurrencyLevel)?
;
-
+
initialCapacity
: INT
;
-
+
maximumSize
: INT
;
-
+
concurrencyLevel
: INT
;
diff --git a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RQLStatement.g4 b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RQLStatement.g4
index 2b1cac3..c258eca 100644
--- a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RQLStatement.g4
+++ b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RQLStatement.g4
@@ -26,18 +26,10 @@ showResources
showSingleTableRules
: SHOW SINGLE TABLE RULES (FROM schemaName)?
;
-
+
showSingleTable
: SHOW SINGLE (table | TABLES) (FROM schemaName)?;
-
-showAuthorityRule
- : SHOW AUTHORITY RULE
- ;
-
-showTransactionRule
- : SHOW TRANSACTION RULE
- ;
-
+
schemaName
: IDENTIFIER
;
@@ -45,7 +37,7 @@ schemaName
table
: TABLE tableName
;
-
+
tableName
: IDENTIFIER
;
diff --git a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/CommonDistSQLStatement.g4 b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/CommonDistSQLStatement.g4
index 22aa8c3..39ef51f 100644
--- a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/CommonDistSQLStatement.g4
+++ b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/CommonDistSQLStatement.g4
@@ -37,10 +37,10 @@ execute
| alterDefaultSingleTableRule
| dropDefaultSingleTableRule
| refreshTableMetadata
+ | showTableMetadata
| showSQLParserRule
| alterSQLParserRule
| showAuthorityRule
| showTransactionRule
- | showTableMetadata
) SEMI?
;
diff --git a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLStatementVisitor.java b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLStatementVisitor.java
index 2dc8856..ca00fd7 100644
--- a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLStatementVisitor.java
+++ b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLStatementVisitor.java
@@ -72,7 +72,7 @@ import org.apache.shardingsphere.distsql.parser.statement.rdl.drop.DropResourceS
import org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowResourcesStatement;
import org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowSingleTableRulesStatement;
import org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowSingleTableStatement;
-import org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowTransactionRuleStatement;
+import org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowTransactionRuleStatement;
import org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitor;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.SchemaSegment;
@@ -253,7 +253,7 @@ public final class CommonDistSQLStatementVisitor extends CommonDistSQLStatementB
@Override
public ASTNode visitShowTransactionRule(final ShowTransactionRuleContext ctx) {
- return new ShowTransactionRuleStatement(null);
+ return new ShowTransactionRuleStatement();
}
@Override
diff --git a/shardingsphere-distsql/shardingsphere-distsql-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowTransactionRuleStatement.java b/shardingsphere-distsql/shardingsphere-distsql-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/common/show/ShowTransactionRuleStatement.java
similarity index 71%
rename from shardingsphere-distsql/shardingsphere-distsql-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowTransactionRuleStatement.java
rename to shardingsphere-distsql/shardingsphere-distsql-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/common/show/ShowTransactionRuleStatement.java
index 76a8cd0..7c0fdb7 100644
--- a/shardingsphere-distsql/shardingsphere-distsql-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowTransactionRuleStatement.java
+++ b/shardingsphere-distsql/shardingsphere-distsql-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/common/show/ShowTransactionRuleStatement.java
@@ -15,16 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.distsql.parser.statement.rql.show;
+package org.apache.shardingsphere.distsql.parser.statement.ral.common.show;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.SchemaSegment;
+import org.apache.shardingsphere.distsql.parser.statement.ral.common.ShowDistSQLStatement;
/**
* Show transaction rule statement.
*/
-public final class ShowTransactionRuleStatement extends ShowRulesStatement {
-
- public ShowTransactionRuleStatement(final SchemaSegment schema) {
- super(schema);
- }
+public final class ShowTransactionRuleStatement extends ShowDistSQLStatement {
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/ShowStatementExecutorFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/ShowStatementExecutorFactory.java
index 9909315..f209fd8 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/ShowStatementExecutorFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/ShowStatementExecutorFactory.java
@@ -23,6 +23,7 @@ import org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowAu
import org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowInstanceStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowSQLParserRuleStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowTableMetadataStatement;
+import org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowTransactionRuleStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowVariableStatement;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.show.executor.ShowAllVariablesExecutor;
@@ -31,6 +32,7 @@ import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.show.exec
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.show.executor.ShowReadwriteSplittingReadResourcesExecutor;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.show.executor.ShowSQLParserRuleExecutor;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.show.executor.ShowTableMetadataExecutor;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.show.executor.ShowTransactionRuleExecutor;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.show.executor.ShowVariableExecutor;
import org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.ShowReadwriteSplittingReadResourcesStatement;
@@ -53,8 +55,14 @@ public final class ShowStatementExecutorFactory {
if (sqlStatement instanceof ShowInstanceStatement) {
return new ShowInstanceExecutor();
}
- if (sqlStatement instanceof ShowReadwriteSplittingReadResourcesStatement) {
- return new ShowReadwriteSplittingReadResourcesExecutor((ShowReadwriteSplittingReadResourcesStatement) sqlStatement, connectionSession);
+ if (sqlStatement instanceof ShowAuthorityRuleStatement) {
+ return new ShowAuthorityRuleExecutor();
+ }
+ if (sqlStatement instanceof ShowTransactionRuleStatement) {
+ return new ShowTransactionRuleExecutor();
+ }
+ if (sqlStatement instanceof ShowSQLParserRuleStatement) {
+ return new ShowSQLParserRuleExecutor();
}
if (sqlStatement instanceof ShowAllVariablesStatement) {
return new ShowAllVariablesExecutor(connectionSession);
@@ -62,11 +70,8 @@ public final class ShowStatementExecutorFactory {
if (sqlStatement instanceof ShowVariableStatement) {
return new ShowVariableExecutor((ShowVariableStatement) sqlStatement, connectionSession);
}
- if (sqlStatement instanceof ShowSQLParserRuleStatement) {
- return new ShowSQLParserRuleExecutor((ShowSQLParserRuleStatement) sqlStatement, connectionSession);
- }
- if (sqlStatement instanceof ShowAuthorityRuleStatement) {
- return new ShowAuthorityRuleExecutor(connectionSession);
+ if (sqlStatement instanceof ShowReadwriteSplittingReadResourcesStatement) {
+ return new ShowReadwriteSplittingReadResourcesExecutor((ShowReadwriteSplittingReadResourcesStatement) sqlStatement, connectionSession);
}
if (sqlStatement instanceof ShowTableMetadataStatement) {
return new ShowTableMetadataExecutor((ShowTableMetadataStatement) sqlStatement, connectionSession);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowAuthorityRuleExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowAuthorityRuleExecutor.java
index 050af76..e00c9bc 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowAuthorityRuleExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowAuthorityRuleExecutor.java
@@ -22,11 +22,11 @@ import org.apache.shardingsphere.authority.config.AuthorityRuleConfiguration;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.sharding.merge.dal.common.MultipleLocalDataMergedResult;
import java.sql.Types;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -35,15 +35,19 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor
public final class ShowAuthorityRuleExecutor extends AbstractShowExecutor {
-
- private final ConnectionSession connectionSession;
+
+ private static final String USERS = "users";
+
+ private static final String PROVIDER = "provider";
+
+ private static final String PROPS = "props";
@Override
protected List<QueryHeader> createQueryHeaders() {
return Arrays.asList(
- new QueryHeader("", "", "users", "users", Types.VARCHAR, "VARCHAR", 100, 0, false, false, false, false),
- new QueryHeader("", "", "provider", "provider", Types.VARCHAR, "VARCHAR", 100, 0, false, false, false, false),
- new QueryHeader("", "", "props", "props", Types.VARCHAR, "VARCHAR", 100, 0, false, false, false, false));
+ new QueryHeader("", "", USERS, USERS, Types.VARCHAR, "VARCHAR", 100, 0, false, false, false, false),
+ new QueryHeader("", "", PROVIDER, PROVIDER, Types.VARCHAR, "VARCHAR", 100, 0, false, false, false, false),
+ new QueryHeader("", "", PROPS, PROPS, Types.VARCHAR, "VARCHAR", 100, 0, false, false, false, false));
}
@Override
@@ -58,7 +62,7 @@ public final class ShowAuthorityRuleExecutor extends AbstractShowExecutor {
row.add(authorityRuleConfiguration.getUsers().stream().map(each -> each.getGrantee().toString()).collect(Collectors.joining("; ")));
row.add(authorityRuleConfiguration.getProvider().getType());
row.add(authorityRuleConfiguration.getProvider().getProps().size() == 0 ? "" : authorityRuleConfiguration.getProvider().getProps());
- LinkedList<List<Object>> rows = new LinkedList<>();
+ Collection<List<Object>> rows = new LinkedList<>();
rows.add(row);
return new MultipleLocalDataMergedResult(rows);
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowSQLParserRuleExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowSQLParserRuleExecutor.java
index b855bb6..e80b6fd 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowSQLParserRuleExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowSQLParserRuleExecutor.java
@@ -20,16 +20,15 @@ package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.show.exe
import com.google.gson.Gson;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowSQLParserRuleStatement;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.parser.config.SQLParserRuleConfiguration;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.sharding.merge.dal.common.MultipleLocalDataMergedResult;
import java.sql.Types;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -50,10 +49,6 @@ public final class ShowSQLParserRuleExecutor extends AbstractShowExecutor {
private static final String SQL_STATEMENT_CACHE = "sql_statement_cache";
- private final ShowSQLParserRuleStatement sqlStatement;
-
- private final ConnectionSession connectionSession;
-
@Override
protected List<QueryHeader> createQueryHeaders() {
return Arrays.asList(
@@ -75,7 +70,7 @@ public final class ShowSQLParserRuleExecutor extends AbstractShowExecutor {
row.add(String.valueOf(sqlParserRuleConfiguration.isSqlCommentParseEnabled()));
row.add(GSON.toJson(sqlParserRuleConfiguration.getParseTreeCache()));
row.add(GSON.toJson(sqlParserRuleConfiguration.getSqlStatementCache()));
- List<List<Object>> rows = new LinkedList<>();
+ Collection<List<Object>> rows = new LinkedList<>();
rows.add(row);
return new MultipleLocalDataMergedResult(rows);
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowAuthorityRuleExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowTransactionRuleExecutor.java
similarity index 56%
copy from shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowAuthorityRuleExecutor.java
copy to shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowTransactionRuleExecutor.java
index 050af76..05f2106 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowAuthorityRuleExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/executor/ShowTransactionRuleExecutor.java
@@ -18,47 +18,46 @@
package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.show.executor;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.authority.config.AuthorityRuleConfiguration;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.sharding.merge.dal.common.MultipleLocalDataMergedResult;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
import java.sql.Types;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
-import java.util.stream.Collectors;
@RequiredArgsConstructor
-public final class ShowAuthorityRuleExecutor extends AbstractShowExecutor {
-
- private final ConnectionSession connectionSession;
+public final class ShowTransactionRuleExecutor extends AbstractShowExecutor {
+
+ private static final String DEFAULT_TYPE = "default_type";
+
+ private static final String PROVIDER_TYPE = "provider_type";
@Override
protected List<QueryHeader> createQueryHeaders() {
return Arrays.asList(
- new QueryHeader("", "", "users", "users", Types.VARCHAR, "VARCHAR", 100, 0, false, false, false, false),
- new QueryHeader("", "", "provider", "provider", Types.VARCHAR, "VARCHAR", 100, 0, false, false, false, false),
- new QueryHeader("", "", "props", "props", Types.VARCHAR, "VARCHAR", 100, 0, false, false, false, false));
+ new QueryHeader("", "", DEFAULT_TYPE, DEFAULT_TYPE, Types.VARCHAR, "VARCHAR", 64, 0, false, false, false, false),
+ new QueryHeader("", "", PROVIDER_TYPE, PROVIDER_TYPE, Types.VARCHAR, "VARCHAR", 64, 0, false, false, false, false));
}
@Override
protected MergedResult createMergedResult() {
- Optional<AuthorityRuleConfiguration> authorityRuleConfigurationOptional = ProxyContext.getInstance().getContextManager()
- .getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(AuthorityRuleConfiguration.class).stream().findFirst();
- if (!authorityRuleConfigurationOptional.isPresent()) {
+ Optional<TransactionRuleConfiguration> optionalTransactionRuleConfiguration = ProxyContext.getInstance().getContextManager()
+ .getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(TransactionRuleConfiguration.class).stream().findAny();
+ if (!optionalTransactionRuleConfiguration.isPresent()) {
return new MultipleLocalDataMergedResult(Collections.emptyList());
}
- AuthorityRuleConfiguration authorityRuleConfiguration = authorityRuleConfigurationOptional.get();
+ TransactionRuleConfiguration transactionRuleConfiguration = optionalTransactionRuleConfiguration.get();
List<Object> row = new LinkedList<>();
- row.add(authorityRuleConfiguration.getUsers().stream().map(each -> each.getGrantee().toString()).collect(Collectors.joining("; ")));
- row.add(authorityRuleConfiguration.getProvider().getType());
- row.add(authorityRuleConfiguration.getProvider().getProps().size() == 0 ? "" : authorityRuleConfiguration.getProvider().getProps());
- LinkedList<List<Object>> rows = new LinkedList<>();
+ row.add(transactionRuleConfiguration.getDefaultType());
+ row.add(null == transactionRuleConfiguration.getProviderType() ? "" : transactionRuleConfiguration.getProviderType());
+ Collection<List<Object>> rows = new LinkedList<>();
rows.add(row);
return new MultipleLocalDataMergedResult(rows);
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/rule/TransactionRuleResultSet.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/rule/TransactionRuleResultSet.java
deleted file mode 100644
index c7bcdcd..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/rule/TransactionRuleResultSet.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.distsql.rql.rule;
-
-import org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowTransactionRuleStatement;
-import org.apache.shardingsphere.infra.distsql.query.DistSQLResultSet;
-import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
-import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Optional;
-
-/**
- * Result set for show transaction rule.
- */
-public final class TransactionRuleResultSet implements DistSQLResultSet {
-
- private Iterator<TransactionRuleConfiguration> data = Collections.emptyIterator();
-
- @Override
- public void init(final ShardingSphereMetaData metaData, final SQLStatement sqlStatement) {
- Optional<TransactionRuleConfiguration> ruleConfiguration = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getGlobalRuleMetaData().getConfigurations()
- .stream().filter(each -> each instanceof TransactionRuleConfiguration).map(each -> (TransactionRuleConfiguration) each).findAny();
- ruleConfiguration.ifPresent(op -> data = Collections.singletonList(op).iterator());
- }
-
- @Override
- public Collection<String> getColumnNames() {
- return Arrays.asList("default_type", "provider_type");
- }
-
- @Override
- public boolean next() {
- return data.hasNext();
- }
-
- @Override
- public Collection<Object> getRowData() {
- TransactionRuleConfiguration next = data.next();
- return Arrays.asList(next.getDefaultType(), next.getProviderType());
- }
-
- @Override
- public String getType() {
- return ShowTransactionRuleStatement.class.getCanonicalName();
- }
-}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.query.DistSQLResultSet b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.query.DistSQLResultSet
index 53e3868..efdaef5 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.query.DistSQLResultSet
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.query.DistSQLResultSet
@@ -18,4 +18,3 @@
org.apache.shardingsphere.proxy.backend.text.distsql.rql.resource.DataSourceQueryResultSet
org.apache.shardingsphere.proxy.backend.text.distsql.rql.rule.SingleTableQueryResultSet
org.apache.shardingsphere.proxy.backend.text.distsql.rql.rule.SingleTableRulesQueryResultSet
-org.apache.shardingsphere.proxy.backend.text.distsql.rql.rule.TransactionRuleResultSet
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/ShowTransactionRuleExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/ShowTransactionRuleExecutorTest.java
new file mode 100644
index 0000000..57a7923
--- /dev/null
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/ShowTransactionRuleExecutorTest.java
@@ -0,0 +1,78 @@
+/*
+ * 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.distsql.ral.common.show;
+
+import org.apache.shardingsphere.infra.config.RuleConfiguration;
+import org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
+import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.show.executor.ShowTransactionRuleExecutor;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collections;
+
+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;
+
+@RunWith(MockitoJUnitRunner.class)
+public final class ShowTransactionRuleExecutorTest {
+
+ private final ShowTransactionRuleExecutor executor = new ShowTransactionRuleExecutor();
+
+ @Test
+ public void assertExecutorWithXA() throws SQLException {
+ ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+ when(contextManager.getMetaDataContexts().getGlobalRuleMetaData()).thenReturn(getGlobalRuleMetaData("XA", "Atomikos"));
+ ProxyContext.getInstance().init(contextManager);
+ executor.execute();
+ executor.next();
+ QueryResponseRow queryResponseRow = executor.getQueryResponseRow();
+ ArrayList<Object> data = new ArrayList<>(queryResponseRow.getData());
+ assertThat(data.size(), is(2));
+ assertThat(data.get(0), is("XA"));
+ assertThat(data.get(1), is("Atomikos"));
+ }
+
+ @Test
+ public void assertExecutorWithLocal() throws SQLException {
+ ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+ when(contextManager.getMetaDataContexts().getGlobalRuleMetaData()).thenReturn(getGlobalRuleMetaData("LOCAL", null));
+ ProxyContext.getInstance().init(contextManager);
+ executor.execute();
+ executor.next();
+ QueryResponseRow queryResponseRow = executor.getQueryResponseRow();
+ ArrayList<Object> data = new ArrayList<>(queryResponseRow.getData());
+ assertThat(data.size(), is(2));
+ assertThat(data.get(0), is("LOCAL"));
+ assertThat(data.get(1), is(""));
+ }
+
+ private ShardingSphereRuleMetaData getGlobalRuleMetaData(final String defaultType, final String providerType) {
+ RuleConfiguration transactionRuleConfiguration = new TransactionRuleConfiguration(defaultType, providerType);
+ return new ShardingSphereRuleMetaData(Collections.singleton(transactionRuleConfiguration), Collections.emptyList());
+ }
+}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/TransactionRuleResultSetTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/TransactionRuleResultSetTest.java
deleted file mode 100644
index e3de40f..0000000
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/TransactionRuleResultSetTest.java
+++ /dev/null
@@ -1,66 +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.distsql.rql;
-
-import org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowTransactionRuleStatement;
-import org.apache.shardingsphere.infra.distsql.query.DistSQLResultSet;
-import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
-import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.text.distsql.rql.rule.TransactionRuleResultSet;
-import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
-public final class TransactionRuleResultSetTest {
-
- @Before
- public void before() {
- TransactionRuleConfiguration configuration = new TransactionRuleConfiguration("XA", "Atomikos");
- ContextManager manager = mock(ContextManager.class);
- when(manager.getMetaDataContexts()).thenReturn(mock(MetaDataContexts.class));
- when(manager.getMetaDataContexts().getGlobalRuleMetaData()).thenReturn(mock(ShardingSphereRuleMetaData.class));
- when(manager.getMetaDataContexts().getGlobalRuleMetaData().getConfigurations()).thenReturn(Collections.singletonList(configuration));
- ProxyContext.getInstance().init(manager);
- }
-
- @Test
- public void assertGetRowData() {
- DistSQLResultSet resultSet = new TransactionRuleResultSet();
- resultSet.init(mock(ShardingSphereMetaData.class), mock(ShowTransactionRuleStatement.class));
- Collection<Object> actual = resultSet.getRowData();
- assertThat(actual.size(), is(2));
- Iterator<Object> rowData = actual.iterator();
- assertThat(rowData.next(), is("XA"));
- assertThat(rowData.next(), is("Atomikos"));
- }
-}
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/ral/impl/CommonDistSQLStatementAssert.java b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/ral/impl/CommonDistSQLStatementAssert.java
index c15f488..a9659b5 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/ral/impl/CommonDistSQLStatementAssert.java
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/ral/impl/CommonDistSQLStatementAssert.java
@@ -29,6 +29,7 @@ import org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowAu
import org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowInstanceStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowSQLParserRuleStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowTableMetadataStatement;
+import org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowTransactionRuleStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowVariableStatement;
import org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.ShowReadwriteSplittingReadResourcesStatement;
import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.SQLCaseAssertContext;
@@ -42,6 +43,7 @@ import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement
import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.ral.impl.common.ShowSQLParserRuleStatementAssert;
import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.ral.impl.common.ShowTableMetadataStatementAssert;
import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.ral.impl.common.ShowVariableStatementAssert;
+import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.ral.impl.common.ShowTransactionRuleStatementAssert;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.SQLParserTestCase;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.AlterSQLParserRuleStatementTestCase;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.RefreshTableMetadataStatementTestCase;
@@ -53,6 +55,7 @@ import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.ShowSQLParserRuleStatementTestCase;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.ShowTableMetadataStatementTestCase;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.ShowVariableStatementTestCase;
+import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.ShowTransactionRuleStatementTestCase;
/**
* Common dist sql statement assert.
@@ -81,14 +84,16 @@ public final class CommonDistSQLStatementAssert {
(ShowReadwriteSplittingReadResourcesStatementTestCase) expected);
} else if (actual instanceof RefreshTableMetadataStatement) {
RefreshTableMetadataStatementAssert.assertIs(assertContext, (RefreshTableMetadataStatement) actual, (RefreshTableMetadataStatementTestCase) expected);
- } else if (actual instanceof ShowSQLParserRuleStatement) {
- ShowSQLParserRuleStatementAssert.assertIs(assertContext, (ShowSQLParserRuleStatement) actual, (ShowSQLParserRuleStatementTestCase) expected);
+ } else if (actual instanceof ShowTableMetadataStatement) {
+ ShowTableMetadataStatementAssert.assertIs(assertContext, (ShowTableMetadataStatement) actual, (ShowTableMetadataStatementTestCase) expected);
} else if (actual instanceof ShowAuthorityRuleStatement) {
ShowAuthorityRuleStatementAssert.assertIs(assertContext, (ShowAuthorityRuleStatement) actual, (ShowAuthorityRuleStatementTestCase) expected);
+ } else if (actual instanceof ShowTransactionRuleStatement) {
+ ShowTransactionRuleStatementAssert.assertIs(assertContext, (ShowTransactionRuleStatement) actual, (ShowTransactionRuleStatementTestCase) expected);
+ } else if (actual instanceof ShowSQLParserRuleStatement) {
+ ShowSQLParserRuleStatementAssert.assertIs(assertContext, (ShowSQLParserRuleStatement) actual, (ShowSQLParserRuleStatementTestCase) expected);
} else if (actual instanceof AlterSQLParserRuleStatement) {
AlterSQLParserRuleStatementAssert.assertIs(assertContext, (AlterSQLParserRuleStatement) actual, (AlterSQLParserRuleStatementTestCase) expected);
- } else if (actual instanceof ShowTableMetadataStatement) {
- ShowTableMetadataStatementAssert.assertIs(assertContext, (ShowTableMetadataStatement) actual, (ShowTableMetadataStatementTestCase) expected);
- }
+ }
}
}
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/rql/impl/rule/ShowTransactionRuleStatementAssert.java b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/ral/impl/common/ShowTransactionRuleStatementAssert.java
similarity index 90%
rename from shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/rql/impl/rule/ShowTransactionRuleStatementAssert.java
rename to shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/ral/impl/common/ShowTransactionRuleStatementAssert.java
index 9df4a4f..01ab97b 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/rql/impl/rule/ShowTransactionRuleStatementAssert.java
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/ral/impl/common/ShowTransactionRuleStatementAssert.java
@@ -15,13 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.rql.impl.rule;
+package org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.ral.impl.common;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowTransactionRuleStatement;
+import org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowTransactionRuleStatement;
import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.SQLCaseAssertContext;
-import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql.ShowTransactionRuleStatementTestCase;
+import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.ShowTransactionRuleStatementTestCase;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/rql/impl/ShowRulesStatementAssert.java b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/rql/impl/ShowRulesStatementAssert.java
index 15409e3..392d473 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/rql/impl/ShowRulesStatementAssert.java
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/rql/impl/ShowRulesStatementAssert.java
@@ -25,7 +25,6 @@ import org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.ShowDataba
import org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowRulesStatement;
import org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowSingleTableRulesStatement;
import org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowSingleTableStatement;
-import org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowTransactionRuleStatement;
import org.apache.shardingsphere.encrypt.distsql.parser.statement.ShowEncryptRulesStatement;
import org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.ShowReadwriteSplittingRulesStatement;
import org.apache.shardingsphere.shadow.distsql.parser.statement.ShowShadowAlgorithmsStatement;
@@ -54,7 +53,6 @@ import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement
import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.rql.impl.rule.ShowShardingTableRulesStatementAssert;
import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.rql.impl.rule.ShowSingleTableRulesStatementAssert;
import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.rql.impl.rule.ShowSingleTableStatementAssert;
-import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.rql.impl.rule.ShowTransactionRuleStatementAssert;
import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.rql.impl.rule.ShowUnusedShardingAlgorithmsStatementAssert;
import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.rql.impl.rule.ShowUnusedShardingKeyGeneratorsStatementAssert;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.SQLParserTestCase;
@@ -72,7 +70,6 @@ import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql.ShowShardingTableRulesStatementTestCase;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql.ShowSingleTableRulesStatementTestCase;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql.ShowSingleTableStatementTestCase;
-import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql.ShowTransactionRuleStatementTestCase;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql.ShowUnusedShardingAlgorithmsStatementTestCase;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql.ShowUnusedShardingKeyGeneratorsStatementTestCase;
@@ -116,8 +113,6 @@ public final class ShowRulesStatementAssert {
ShowSingleTableRulesStatementAssert.assertIs(assertContext, (ShowSingleTableRulesStatement) actual, (ShowSingleTableRulesStatementTestCase) expected);
} else if (actual instanceof ShowShardingKeyGeneratorsStatement) {
ShowShardingKeyGeneratorsStatementAssert.assertIs(assertContext, (ShowShardingKeyGeneratorsStatement) actual, (ShowShardingKeyGeneratorsStatementTestCase) expected);
- } else if (actual instanceof ShowTransactionRuleStatement) {
- ShowTransactionRuleStatementAssert.assertIs(assertContext, (ShowTransactionRuleStatement) actual, (ShowTransactionRuleStatementTestCase) expected);
} else if (actual instanceof ShowDefaultShardingStrategyStatement) {
ShowDefaultShardingStrategyStatementAssert.assertIs(assertContext, (ShowDefaultShardingStrategyStatement) actual, (ShowDefaultShardingStrategyStatementTestCase) expected);
} else if (actual instanceof ShowUnusedShardingAlgorithmsStatement) {
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
index 68284bc..6691705 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
@@ -242,7 +242,7 @@ import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql.ShowShardingTableRulesStatementTestCase;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql.ShowSingleTableRulesStatementTestCase;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql.ShowSingleTableStatementTestCase;
-import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql.ShowTransactionRuleStatementTestCase;
+import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.ShowTransactionRuleStatementTestCase;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql.ShowUnusedShardingAlgorithmsStatementTestCase;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql.ShowUnusedShardingKeyGeneratorsStatementTestCase;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.dml.CallStatementTestCase;
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/distsql/rql/ShowTransactionRuleStatementTestCase.java b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/distsql/ral/ShowTransactionRuleStatementTestCase.java
similarity index 91%
rename from shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/distsql/rql/ShowTransactionRuleStatementTestCase.java
rename to shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/distsql/ral/ShowTransactionRuleStatementTestCase.java
index 952a528..0a8ae71 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/distsql/rql/ShowTransactionRuleStatementTestCase.java
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/distsql/ral/ShowTransactionRuleStatementTestCase.java
@@ -15,16 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql;
+package org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral;
-import lombok.Getter;
-import lombok.Setter;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.SQLParserTestCase;
/**
* Show transaction rule statement test case.
*/
-@Getter
-@Setter
public final class ShowTransactionRuleStatementTestCase extends SQLParserTestCase {
}
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ral/common.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ral/common.xml
index ac3f5f4..d73d2e7 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ral/common.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ral/common.xml
@@ -31,19 +31,20 @@
<show-sharding-hint-status sql-case-id="show-sharding-hint-status" />
<show-instance sql-case-id="show-instance" />
<show-readwrite-splitting-read-resources sql-case-id="show-readwrite-splitting-read-resources" />
+ <show-table-metadata sql-case-id="show-table-metadata" >
+ <table-name>t_order</table-name>
+ <schema name="schema_name" start-index="33" stop-index="43"/>
+ </show-table-metadata>
<refresh-table-metadata sql-case-id="refresh-table-metadata" />
<refresh-table-metadata sql-case-id="refresh-table-metadata-with-table-name" table-name="t_order" />
<refresh-table-metadata sql-case-id="refresh-table-metadata-with-resource" table-name="t_order" resource-name="ds_0"/>
- <show-sql-parser-rule sql-case-id="show-sql-parser-rule" />
<show-authority-rule sql-case-id="show-authority-rule"/>
+ <show-transaction-rule sql-case-id="show-transaction-rule"/>
+ <show-sql-parser-rule sql-case-id="show-sql-parser-rule" />
<alter-sql-parser-rule sql-case-id="alter-sql-parser-rule">
<sql-parser sqlCommentParseEnabled="false">
<parse-tree-cache initial-capacity="10" maximum-size="11" concurrency-level="1" />
<sql-statement-cache initial-capacity="11" maximum-size="11" concurrency-level="100" />
</sql-parser>
</alter-sql-parser-rule>
- <show-table-metadata sql-case-id="show-table-metadata" >
- <table-name>t_order</table-name>
- <schema name="schema_name" start-index="33" stop-index="43"/>
- </show-table-metadata>
</sql-parser-test-cases>
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/rql/show.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/rql/show.xml
index 79537c5..64e6698 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/rql/show.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/rql/show.xml
@@ -95,8 +95,6 @@
<schema name="sharding_db" start-index="34" stop-index="44"/>
</show-sharding-key-generators>
- <show-transaction-rule sql-case-id="show-transaction-rule"/>
-
<show-default-sharding-strategy sql-case-id="show-default-sharding-strategy">
<schema name="sharding_db" start-index="36" stop-index="46"/>
</show-default-sharding-strategy>
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ral/common.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ral/common.xml
index d5e7cb7..0f98907 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ral/common.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ral/common.xml
@@ -31,11 +31,12 @@
<distsql-case id="show-sharding-hint-status" value="SHOW SHARDING HINT STATUS" />
<distsql-case id="show-instance" value="SHOW INSTANCE LIST" />
<distsql-case id="show-readwrite-splitting-read-resources" value="show readwrite_splitting read resources" />
+ <distsql-case id="show-table-metadata" value="SHOW TABLE METADATA t_order FROM schema_name" />
<distsql-case id="refresh-table-metadata" value="refresh table metadata" />
<distsql-case id="refresh-table-metadata-with-table-name" value="refresh table metadata t_order" />
<distsql-case id="refresh-table-metadata-with-resource" value="refresh table metadata t_order from resource ds_0" />
- <distsql-case id="show-sql-parser-rule" value="SHOW SQL_PARSER RULE" />
<distsql-case id="show-authority-rule" value="SHOW AUTHORITY RULE"/>
+ <distsql-case id="show-transaction-rule" value="SHOW TRANSACTION RULE" />
+ <distsql-case id="show-sql-parser-rule" value="SHOW SQL_PARSER RULE" />
<distsql-case id="alter-sql-parser-rule" value="ALTER SQL_PARSER RULE SQL_COMMENT_PARSE_ENABLE=false,PARSE_TREE_CACHE(INITIAL_CAPACITY=10, MAXIMUM_SIZE=11,CONCURRENCY_LEVEL=1), SQL_STATEMENT_CACHE(INITIAL_CAPACITY=11, MAXIMUM_SIZE=11,CONCURRENCY_LEVEL=100)" />
- <distsql-case id="show-table-metadata" value="SHOW TABLE METADATA t_order FROM schema_name" />
</sql-cases>
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/rql/show.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/rql/show.xml
index dabad51..531af01 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/rql/show.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/rql/show.xml
@@ -36,7 +36,6 @@
<distsql-case id="show-single-table-rules" value="SHOW SINGLE TABLE RULES FROM single_table_db" />
<distsql-case id="show-sharding-table-nodes" value="SHOW SHARDING TABLE NODES t_order FROM sharding_db" />
<distsql-case id="show-sharding-key-generators" value="SHOW SHARDING KEY GENERATORS FROM sharding_db" />
- <distsql-case id="show-transaction-rule" value="SHOW TRANSACTION RULE" />
<distsql-case id="show-default-sharding-strategy" value="SHOW DEFAULT SHARDING STRATEGY FROM sharding_db" />
<distsql-case id="show-unused-sharding-algorithms" value="SHOW UNUSED SHARDING ALGORITHMS FROM schemaName" />
<distsql-case id="show-unused-sharding-key-generators" value="SHOW UNUSED SHARDING KEY GENERATORS FROM schemaName" />