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 c48501209d4 Add StartTransactionStatement to support openGauss driver 
execute statement in transaction (#37749)
c48501209d4 is described below

commit c48501209d4a46de655341ff9b8ab2cacaed700a
Author: Raigor <[email protected]>
AuthorDate: Thu Jan 15 23:02:52 2026 +0800

    Add StartTransactionStatement to support openGauss driver execute statement 
in transaction (#37749)
    
    * Add StartTransactionStatement to support openGauss driver execute 
statement in transaction
    
    * Update RELEASE-NOTES.md
---
 RELEASE-NOTES.md                                   |  1 +
 .../type/OpenGaussTCLStatementVisitor.java         |  3 ++-
 .../type/PostgreSQLTCLStatementVisitor.java        |  3 ++-
 .../type/tcl/StartTransactionStatement.java        | 30 ++++++++++++++++++++++
 .../command/query/PostgreSQLCommand.java           |  3 ++-
 .../command/query/PostgreSQLCommandTest.java       |  7 +++++
 6 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 486d38f99b4..055ab5a94ec 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -127,6 +127,7 @@
 1. Pipeline: Fix SHOW MIGRATION RULE always display default values when ALTER 
MIGRATION RULE without STREAM_CHANNEL - 
[#37737](https://github.com/apache/shardingsphere/issues/37737)
 1. DistSQL: Fix load single table with specific schema - 
[#37535](https://github.com/apache/shardingsphere/pull/37535)
 1. Transaction: Fix XA data source enlist failure caused connection leaks - 
[37593](https://github.com/apache/shardingsphere/pull/37593)
+1. Proxy: Fix command type error when use openGauss driver to execute 
statements in transaction - 
[37749](https://github.com/apache/shardingsphere/pull/37749)
 
 ### Change Logs
 
diff --git 
a/parser/sql/engine/dialect/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/engine/opengauss/visitor/statement/type/OpenGaussTCLStatementVisitor.java
 
b/parser/sql/engine/dialect/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/engine/opengauss/visitor/statement/type/OpenGaussTCLStatementVisitor.java
index deb40994c35..1218b4a579c 100644
--- 
a/parser/sql/engine/dialect/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/engine/opengauss/visitor/statement/type/OpenGaussTCLStatementVisitor.java
+++ 
b/parser/sql/engine/dialect/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/engine/opengauss/visitor/statement/type/OpenGaussTCLStatementVisitor.java
@@ -41,6 +41,7 @@ import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.Ro
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.SavepointStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.SetConstraintsStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.SetTransactionStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.StartTransactionStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.xa.XACommitStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.xa.XARollbackStatement;
 
@@ -95,7 +96,7 @@ public final class OpenGaussTCLStatementVisitor extends 
OpenGaussStatementVisito
     
     @Override
     public ASTNode visitStartTransaction(final StartTransactionContext ctx) {
-        return new BeginTransactionStatement(getDatabaseType());
+        return new StartTransactionStatement(getDatabaseType());
     }
     
     @Override
diff --git 
a/parser/sql/engine/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/engine/postgresql/visitor/statement/type/PostgreSQLTCLStatementVisitor.java
 
b/parser/sql/engine/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/engine/postgresql/visitor/statement/type/PostgreSQLTCLStatementVisitor.java
index 2064b625966..a0259af0d96 100644
--- 
a/parser/sql/engine/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/engine/postgresql/visitor/statement/type/PostgreSQLTCLStatementVisitor.java
+++ 
b/parser/sql/engine/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/engine/postgresql/visitor/statement/type/PostgreSQLTCLStatementVisitor.java
@@ -46,6 +46,7 @@ import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.Ro
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.SavepointStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.SetConstraintsStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.SetTransactionStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.StartTransactionStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.xa.XACommitStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.xa.XAPrepareStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.xa.XARollbackStatement;
@@ -139,7 +140,7 @@ public final class PostgreSQLTCLStatementVisitor extends 
PostgreSQLStatementVisi
     
     @Override
     public ASTNode visitStartTransaction(final StartTransactionContext ctx) {
-        return new BeginTransactionStatement(getDatabaseType());
+        return new StartTransactionStatement(getDatabaseType());
     }
     
     @Override
diff --git 
a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/type/tcl/StartTransactionStatement.java
 
b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/type/tcl/StartTransactionStatement.java
new file mode 100644
index 00000000000..7343a940bf0
--- /dev/null
+++ 
b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/type/tcl/StartTransactionStatement.java
@@ -0,0 +1,30 @@
+/*
+ * 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.sql.parser.statement.core.statement.type.tcl;
+
+import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+
+/**
+ * Start transaction statement.
+ */
+public final class StartTransactionStatement extends TCLStatement {
+    
+    public StartTransactionStatement(final DatabaseType databaseType) {
+        super(databaseType);
+    }
+}
diff --git 
a/proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/PostgreSQLCommand.java
 
b/proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/PostgreSQLCommand.java
index b2bc1cc9621..0a90deedb3b 100644
--- 
a/proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/PostgreSQLCommand.java
+++ 
b/proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/PostgreSQLCommand.java
@@ -65,6 +65,7 @@ import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.Re
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.RollbackStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.SavepointStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.SetTransactionStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.StartTransactionStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.postgresql.dal.PostgreSQLResetParameterStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.postgresql.dal.PostgreSQLVacuumStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.postgresql.ddl.PostgreSQLDeclareStatement;
@@ -119,7 +120,7 @@ public enum PostgreSQLCommand {
     DROP_VIEW(DropViewStatement.class),
     TRUNCATE_TABLE(TruncateStatement.class),
     BEGIN(BeginTransactionStatement.class),
-    START_TRANSACTION(BeginTransactionStatement.class),
+    START_TRANSACTION(StartTransactionStatement.class),
     COMMIT(CommitStatement.class),
     SAVEPOINT(SavepointStatement.class),
     ROLLBACK(RollbackStatement.class),
diff --git 
a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/PostgreSQLCommandTest.java
 
b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/PostgreSQLCommandTest.java
index eea2226a6c0..f4abf5853c2 100644
--- 
a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/PostgreSQLCommandTest.java
+++ 
b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/PostgreSQLCommandTest.java
@@ -60,6 +60,7 @@ import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.Co
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.ReleaseSavepointStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.RollbackStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.SavepointStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.StartTransactionStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.postgresql.dal.PostgreSQLResetParameterStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.postgresql.dal.PostgreSQLVacuumStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.postgresql.ddl.PostgreSQLDeclareStatement;
@@ -281,6 +282,12 @@ class PostgreSQLCommandTest {
         assertThat(PostgreSQLCommand.BEGIN.getTag(), is("BEGIN"));
     }
     
+    @Test
+    void assertValueOfStartTransactionStatement() {
+        
assertThat(PostgreSQLCommand.valueOf(StartTransactionStatement.class).orElse(null),
 is(PostgreSQLCommand.START_TRANSACTION));
+        assertThat(PostgreSQLCommand.START_TRANSACTION.getTag(), is("START 
TRANSACTION"));
+    }
+    
     @Test
     void assertValueOfCommitStatement() {
         
assertThat(PostgreSQLCommand.valueOf(CommitStatement.class).orElse(null), 
is(PostgreSQLCommand.COMMIT));

Reply via email to