This is an automated email from the ASF dual-hosted git repository.

jianglongtao 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 d910224  For #14164, add `SHOW TRANSACTION RULE` syntax to DistSQL. 
(#14319)
d910224 is described below

commit d910224b6f0149769faf1559f75b8590a7fa3e68
Author: yx9o <[email protected]>
AuthorDate: Mon Dec 27 11:55:15 2021 +0800

    For #14164, add `SHOW TRANSACTION RULE` syntax to DistSQL. (#14319)
    
    * For #14164, Add SHOW TRANSACTION RULE syntax to DistSQL.
    
    * Update
---
 .../src/main/antlr4/imports/Keyword.g4             |  4 ++
 .../src/main/antlr4/imports/RQLStatement.g4        |  4 ++
 .../parser/autogen/CommonDistSQLStatement.g4       |  1 +
 .../core/common/CommonDistSQLStatementVisitor.java | 15 +++--
 .../rql/show/ShowTransactionRuleStatement.java}    | 37 ++++--------
 .../distsql/rql/rule/TransactionRuleResultSet.java | 67 ++++++++++++++++++++++
 ...dingsphere.infra.distsql.query.DistSQLResultSet |  1 +
 .../distsql/rql/TransactionRuleResultSetTest.java  | 66 +++++++++++++++++++++
 .../distsql/rql/impl/ShowRulesStatementAssert.java |  5 ++
 .../rule/ShowTransactionRuleStatementAssert.java   | 49 ++++++++++++++++
 .../jaxb/cases/domain/SQLParserTestCases.java      |  5 ++
 .../rql/ShowTransactionRuleStatementTestCase.java  | 39 ++++---------
 .../src/main/resources/case/rql/show.xml           |  2 +
 .../src/main/resources/sql/supported/rql/show.xml  |  1 +
 14 files changed, 237 insertions(+), 59 deletions(-)

diff --git 
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/Keyword.g4
 
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/Keyword.g4
index 79f9189..43b184b 100644
--- 
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/Keyword.g4
+++ 
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/Keyword.g4
@@ -154,6 +154,10 @@ LIST
 TABLE
     : T A B L E
     ;
+    
+TRANSACTION
+    : T R A N S A C T I O N
+    ;
 
 RULES
     : R U L E S
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 4ae5c25..2b1cac3 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
@@ -34,6 +34,10 @@ showAuthorityRule
     : SHOW AUTHORITY RULE
     ;
     
+showTransactionRule
+    : SHOW TRANSACTION RULE
+    ;
+    
 schemaName
     : 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 1e7e0c6..581cdc4 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
@@ -39,5 +39,6 @@ execute
     | refreshTableMetadata
     | showSQLParserRule
     | showAuthorityRule
+    | showTransactionRule
     ) 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 093edbc..2c98cb9 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
@@ -19,8 +19,6 @@ package org.apache.shardingsphere.distsql.parser.core.common;
 
 import org.antlr.v4.runtime.tree.ParseTree;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementBaseVisitor;
-import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.ShowAuthorityRuleContext;
-import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.ShowSQLParserRuleContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.AddResourceContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.AlterDefaultSingleTableRuleContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.AlterResourceContext;
@@ -40,10 +38,13 @@ import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementPa
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.SchemaNameContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.SetVariableContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.ShowAllVariablesContext;
+import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.ShowAuthorityRuleContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.ShowInstanceContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.ShowResourcesContext;
+import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.ShowSQLParserRuleContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.ShowSingleTableContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.ShowSingleTableRulesContext;
+import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.ShowTransactionRuleContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.ShowVariableContext;
 import org.apache.shardingsphere.distsql.parser.segment.DataSourceSegment;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.RefreshTableMetadataStatement;
@@ -51,7 +52,9 @@ import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.hint.ClearH
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.set.SetInstanceStatusStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.set.SetVariableStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowAllVariablesStatement;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowAuthorityRuleStatement;
 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.ShowVariableStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.rdl.alter.AlterResourceStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.rdl.create.AddResourceStatement;
@@ -59,11 +62,10 @@ import 
org.apache.shardingsphere.distsql.parser.statement.rdl.create.AlterDefaul
 import 
org.apache.shardingsphere.distsql.parser.statement.rdl.create.CreateDefaultSingleTableRuleStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.rdl.drop.DropDefaultSingleTableRuleStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.rdl.drop.DropResourceStatement;
-import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowAuthorityRuleStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowResourcesStatement;
-import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowSQLParserRuleStatement;
 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.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;
@@ -234,4 +236,9 @@ public final class CommonDistSQLStatementVisitor extends 
CommonDistSQLStatementB
         result.setResourceName(null == ctx.refreshScope() ? Optional.empty() : 
Optional.ofNullable(getIdentifierValue(ctx.refreshScope().resourceName())));
         return result;
     }
+    
+    @Override
+    public ASTNode visitShowTransactionRule(final ShowTransactionRuleContext 
ctx) {
+        return new ShowTransactionRuleStatement(null);
+    }
 }
diff --git 
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RQLStatement.g4
 
b/shardingsphere-distsql/shardingsphere-distsql-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowTransactionRuleStatement.java
similarity index 64%
copy from 
shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RQLStatement.g4
copy to 
shardingsphere-distsql/shardingsphere-distsql-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowTransactionRuleStatement.java
index 4ae5c25..76a8cd0 100644
--- 
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RQLStatement.g4
+++ 
b/shardingsphere-distsql/shardingsphere-distsql-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/rql/show/ShowTransactionRuleStatement.java
@@ -15,33 +15,16 @@
  * limitations under the License.
  */
 
-grammar RQLStatement;
+package org.apache.shardingsphere.distsql.parser.statement.rql.show;
 
-import Keyword, Literals, Symbol;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.SchemaSegment;
 
-showResources
-    : SHOW SCHEMA RESOURCES (FROM schemaName)?
-    ;
-
-showSingleTableRules
-    : SHOW SINGLE TABLE RULES (FROM schemaName)?
-    ;
-    
-showSingleTable
-    : SHOW SINGLE (table | TABLES)  (FROM schemaName)?;
-    
-showAuthorityRule
-    : SHOW AUTHORITY RULE
-    ;
-    
-schemaName
-    : IDENTIFIER
-    ;
-
-table
-    : TABLE tableName
-    ;
+/**
+ * Show transaction rule statement.
+ */
+public final class ShowTransactionRuleStatement extends ShowRulesStatement {
     
-tableName
-    : IDENTIFIER
-    ;
+    public ShowTransactionRuleStatement(final SchemaSegment schema) {
+        super(schema);
+    }
+}
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
new file mode 100644
index 0000000..c7bcdcd
--- /dev/null
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/rule/TransactionRuleResultSet.java
@@ -0,0 +1,67 @@
+/*
+ * 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 efdaef5..53e3868 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,3 +18,4 @@
 
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/rql/TransactionRuleResultSetTest.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/TransactionRuleResultSetTest.java
new file mode 100644
index 0000000..e3de40f
--- /dev/null
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/TransactionRuleResultSetTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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/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 d433224..02a21d3 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,6 +25,7 @@ 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;
@@ -49,6 +50,7 @@ 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.jaxb.cases.domain.statement.SQLParserTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql.ShowDataBaseDiscoveryRulesStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql.ShowEncryptRulesStatementTestCase;
@@ -63,6 +65,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;
 
 /**
  * Show rule statement assert.
@@ -104,6 +107,8 @@ 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);
         }
     }
 }
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/rql/impl/rule/ShowTransactionRuleStatementAssert.java
new file mode 100644
index 0000000..9df4a4f
--- /dev/null
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/rql/impl/rule/ShowTransactionRuleStatementAssert.java
@@ -0,0 +1,49 @@
+/*
+ * 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.test.sql.parser.parameterized.asserts.statement.distsql.rql.impl.rule;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import 
org.apache.shardingsphere.distsql.parser.statement.rql.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 static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+/**
+ * Show transaction rule statement assert.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class ShowTransactionRuleStatementAssert {
+    
+    /**
+     * Assert show transaction rule statement is correct with expected parser 
result.
+     *
+     * @param assertContext assert context
+     * @param actual actual show transaction rule statement
+     * @param expected expected show transaction rule statement test case
+     */
+    public static void assertIs(final SQLCaseAssertContext assertContext, 
final ShowTransactionRuleStatement actual, final 
ShowTransactionRuleStatementTestCase expected) {
+        if (null == expected) {
+            assertNull(assertContext.getText("Actual statement should not 
exist."), actual);
+        } else {
+            assertNotNull(assertContext.getText("Actual statement should 
exist."), actual);
+        }
+    }
+}
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 938ace2..3c77497 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
@@ -220,6 +220,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.dml.CallStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.dml.CopyStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.dml.DeleteStatementTestCase;
@@ -900,6 +901,9 @@ public final class SQLParserTestCases {
     @XmlElement(name = "show-authority-rule")
     private final List<ShowAuthorityRuleStatementTestCase> 
showAuthorityRuleStatementTestCases = new LinkedList<>();
     
+    @XmlElement(name = "show-transaction-rule")
+    private final List<ShowTransactionRuleStatementTestCase> 
showTransactionRuleStatementTestCases = new LinkedList<>();
+    
     /**
      * Get all SQL parser test cases.
      *
@@ -1124,6 +1128,7 @@ public final class SQLParserTestCases {
         putAll(createDomainStatementTestCases, result);
         putAll(createRuleStatementTestCases, result);
         putAll(showAuthorityRuleStatementTestCases,result);
+        putAll(showTransactionRuleStatementTestCases, result);
         return result;
     }
     // CHECKSTYLE:ON
diff --git 
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RQLStatement.g4
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/distsql/rql/ShowTransactionRuleStatementTestCase.java
similarity index 64%
copy from 
shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RQLStatement.g4
copy to 
shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/distsql/rql/ShowTransactionRuleStatementTestCase.java
index 4ae5c25..952a528 100644
--- 
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RQLStatement.g4
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/distsql/rql/ShowTransactionRuleStatementTestCase.java
@@ -15,33 +15,16 @@
  * limitations under the License.
  */
 
-grammar RQLStatement;
+package 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql;
 
-import Keyword, Literals, Symbol;
+import lombok.Getter;
+import lombok.Setter;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.SQLParserTestCase;
 
-showResources
-    : SHOW SCHEMA RESOURCES (FROM schemaName)?
-    ;
-
-showSingleTableRules
-    : SHOW SINGLE TABLE RULES (FROM schemaName)?
-    ;
-    
-showSingleTable
-    : SHOW SINGLE (table | TABLES)  (FROM schemaName)?;
-    
-showAuthorityRule
-    : SHOW AUTHORITY RULE
-    ;
-    
-schemaName
-    : IDENTIFIER
-    ;
-
-table
-    : TABLE tableName
-    ;
-    
-tableName
-    : IDENTIFIER
-    ;
+/**
+ * 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/rql/show.xml
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/rql/show.xml
index 04f5aea..07fbcee 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
@@ -94,4 +94,6 @@
     <show-sharding-key-generators sql-case-id="show-sharding-key-generators">
         <schema name="sharding_db" start-index="34" stop-index="44"/>
     </show-sharding-key-generators>
+
+    <show-transaction-rule sql-case-id="show-transaction-rule" />
 </sql-parser-test-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 4d6de47..3ad804d 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,4 +36,5 @@
     <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" />
 </sql-cases>

Reply via email to