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/05/20 10:25:40 UTC
[shardingsphere] branch master updated: fix pg start transaction &
end transaction parse error (#10402)
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 448054f fix pg start transaction & end transaction parse error (#10402)
448054f is described below
commit 448054fd3f94bdfacd289678ac32f1889bbcd52f
Author: Zhengqiang Duan <st...@gmail.com>
AuthorDate: Thu May 20 18:25:04 2021 +0800
fix pg start transaction & end transaction parse error (#10402)
---
.../sql/parser/autogen/PostgreSQLStatement.g4 | 2 ++
.../statement/impl/PostgreSQLTCLStatementSQLVisitor.java | 14 +++++++++++++-
.../sql/parser/core/visitor/SQLVisitorRule.java | 4 ++++
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/PostgreSQLStatement.g4 b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/PostgreSQLStatement.g4
index 931a3c3..8858efd 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/PostgreSQLStatement.g4
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/PostgreSQLStatement.g4
@@ -33,6 +33,8 @@ execute
| truncateTable
| setTransaction
| beginTransaction
+ | startTransaction
+ | end
| commit
| rollback
| savepoint
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/impl/PostgreSQLTCLStatementSQLVisitor.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/impl/PostgreSQLTCLStatementSQLVisitor.java
index e6c3ee5..b54ee2e 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/impl/PostgreSQLTCLStatementSQLVisitor.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/impl/PostgreSQLTCLStatementSQLVisitor.java
@@ -18,14 +18,16 @@
package org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.impl;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.sql.parser.api.visitor.operation.SQLStatementVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
+import org.apache.shardingsphere.sql.parser.api.visitor.operation.SQLStatementVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.type.TCLSQLVisitor;
import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.BeginTransactionContext;
import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.CommitContext;
+import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.EndContext;
import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.RollbackContext;
import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.SavepointContext;
import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.SetTransactionContext;
+import org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.StartTransactionContext;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.tcl.PostgreSQLBeginTransactionStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.tcl.PostgreSQLCommitStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.tcl.PostgreSQLRollbackStatement;
@@ -68,4 +70,14 @@ public final class PostgreSQLTCLStatementSQLVisitor extends PostgreSQLStatementS
public ASTNode visitSavepoint(final SavepointContext ctx) {
return new PostgreSQLSavepointStatement();
}
+
+ @Override
+ public ASTNode visitStartTransaction(final StartTransactionContext ctx) {
+ return new PostgreSQLBeginTransactionStatement();
+ }
+
+ @Override
+ public ASTNode visitEnd(final EndContext ctx) {
+ return new PostgreSQLCommitStatement();
+ }
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/SQLVisitorRule.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/SQLVisitorRule.java
index d5875ea..1b51188 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/SQLVisitorRule.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/SQLVisitorRule.java
@@ -128,6 +128,10 @@ public enum SQLVisitorRule {
BEGIN_TRANSACTION("BeginTransaction", SQLStatementType.TCL),
+ START_TRANSACTION("StartTransaction", SQLStatementType.TCL),
+
+ END("End", SQLStatementType.TCL),
+
SET_AUTOCOMMIT("SetAutoCommit", SQLStatementType.TCL),
COMMIT("Commit", SQLStatementType.TCL),