This is an automated email from the ASF dual-hosted git repository.
starocean999 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new fd59cfd3ca6 [Chore](nereids) remove TransactionStmt (#51805)
fd59cfd3ca6 is described below
commit fd59cfd3ca6fca11a2506d606a41bfe434b28349
Author: yaoxiao <[email protected]>
AuthorDate: Tue Jun 24 10:36:57 2025 +0800
[Chore](nereids) remove TransactionStmt (#51805)
---
fe/fe-core/src/main/cup/sql_parser.cup | 19 -----
.../doris/analysis/TransactionBeginStmt.java | 48 -------------
.../doris/analysis/TransactionCommitStmt.java | 22 ------
.../doris/analysis/TransactionRollbackStmt.java | 22 ------
.../org/apache/doris/analysis/TransactionStmt.java | 39 -----------
.../java/org/apache/doris/qe/StmtExecutor.java | 80 +---------------------
.../apache/doris/analysis/InsertArrayStmtTest.java | 44 ------------
7 files changed, 1 insertion(+), 273 deletions(-)
diff --git a/fe/fe-core/src/main/cup/sql_parser.cup
b/fe/fe-core/src/main/cup/sql_parser.cup
index 7d6e555151a..7ba182a2287 100644
--- a/fe/fe-core/src/main/cup/sql_parser.cup
+++ b/fe/fe-core/src/main/cup/sql_parser.cup
@@ -6920,25 +6920,6 @@ truncate_stmt ::=
:}
;
-transaction_stmt ::=
- KW_BEGIN
- {:
- RESULT = new TransactionBeginStmt();
- :}
- | KW_BEGIN KW_WITH KW_LABEL transaction_label:label
- {:
- RESULT = new TransactionBeginStmt(label);
- :}
- | KW_COMMIT opt_work opt_chain opt_release
- {:
- RESULT = new TransactionCommitStmt();
- :}
- | KW_ROLLBACK opt_work opt_chain opt_release
- {:
- RESULT = new TransactionRollbackStmt();
- :}
- ;
-
transaction_label ::=
/* empty */
{:
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/TransactionBeginStmt.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/TransactionBeginStmt.java
deleted file mode 100644
index 90f5fbb5159..00000000000
---
a/fe/fe-core/src/main/java/org/apache/doris/analysis/TransactionBeginStmt.java
+++ /dev/null
@@ -1,48 +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.doris.analysis;
-
-import org.apache.doris.common.AnalysisException;
-import org.apache.doris.common.UserException;
-import org.apache.doris.common.util.DebugUtil;
-import org.apache.doris.transaction.TransactionEntry;
-
-public class TransactionBeginStmt extends TransactionStmt implements
NotFallbackInParser {
- private String label = null;
-
- public TransactionBeginStmt() {
- this.label = "";
- }
-
- public TransactionBeginStmt(final String label) {
- this.label = label;
- }
-
- @Override
- public void analyze(Analyzer analyzer) throws AnalysisException,
UserException {
- if (label == null || label.isEmpty()) {
- label = "txn_insert_" +
DebugUtil.printId(analyzer.getContext().queryId());
- }
- if (analyzer.getContext().getTxnEntry() == null) {
- analyzer.getContext().setTxnEntry(new TransactionEntry());
- }
- analyzer.getContext().getTxnEntry().setLabel(label);
- super.analyze(analyzer);
- }
-
-}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/TransactionCommitStmt.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/TransactionCommitStmt.java
deleted file mode 100644
index b17e767b683..00000000000
---
a/fe/fe-core/src/main/java/org/apache/doris/analysis/TransactionCommitStmt.java
+++ /dev/null
@@ -1,22 +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.doris.analysis;
-
-public class TransactionCommitStmt extends TransactionStmt implements
NotFallbackInParser {
-
-}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/TransactionRollbackStmt.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/TransactionRollbackStmt.java
deleted file mode 100644
index 081cd84592b..00000000000
---
a/fe/fe-core/src/main/java/org/apache/doris/analysis/TransactionRollbackStmt.java
+++ /dev/null
@@ -1,22 +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.doris.analysis;
-
-public class TransactionRollbackStmt extends TransactionStmt implements
NotFallbackInParser {
-
-}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/TransactionStmt.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/TransactionStmt.java
deleted file mode 100644
index a1ad0ed2ed7..00000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/TransactionStmt.java
+++ /dev/null
@@ -1,39 +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.doris.analysis;
-
-import org.apache.doris.common.AnalysisException;
-import org.apache.doris.common.UserException;
-
-public class TransactionStmt extends StatementBase implements
NotFallbackInParser {
-
- @Override
- public RedirectStatus getRedirectStatus() {
- return RedirectStatus.NO_FORWARD;
- }
-
- @Override
- public void analyze(Analyzer analyzer) throws AnalysisException,
UserException {
- super.analyze(analyzer);
- }
-
- @Override
- public StmtType stmtType() {
- return StmtType.TRANSACTION;
- }
-}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
index dc687467686..b81fc1a6848 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
@@ -66,10 +66,6 @@ import org.apache.doris.analysis.StorageBackend.StorageType;
import org.apache.doris.analysis.StringLiteral;
import org.apache.doris.analysis.SwitchStmt;
import org.apache.doris.analysis.TableName;
-import org.apache.doris.analysis.TransactionBeginStmt;
-import org.apache.doris.analysis.TransactionCommitStmt;
-import org.apache.doris.analysis.TransactionRollbackStmt;
-import org.apache.doris.analysis.TransactionStmt;
import org.apache.doris.analysis.UnifiedLoadStmt;
import org.apache.doris.analysis.UnlockTablesStmt;
import org.apache.doris.analysis.UnsetVariableStmt;
@@ -1021,8 +1017,7 @@ public class StmtExecutor {
// parsedStmt maybe null here, we parse it. Or the predicate will
not work.
parseByLegacy();
checkSqlBlocked(parsedStmt.getClass());
- if (context.isTxnModel() && !(parsedStmt instanceof InsertStmt)
- && !(parsedStmt instanceof TransactionStmt)) {
+ if (context.isTxnModel() && !(parsedStmt instanceof InsertStmt)) {
throw new TException("This is in a transaction, only insert,
update, delete, "
+ "commit, rollback is acceptable.");
}
@@ -1090,8 +1085,6 @@ public class StmtExecutor {
} else if (parsedStmt instanceof UseCloudClusterStmt) {
// jdbc client use
handleUseCloudClusterStmt();
- } else if (parsedStmt instanceof TransactionStmt) {
- handleTransactionStmt();
} else if (parsedStmt instanceof CreateTableAsSelectStmt) {
handleCtasStmt();
} else if (parsedStmt instanceof InsertOverwriteTableStmt) {
@@ -2100,77 +2093,6 @@ public class StmtExecutor {
}
}
- private void handleTransactionStmt() throws Exception {
- if (context.getConnectType() == ConnectType.MYSQL) {
- // Every time set no send flag and clean all data in buffer
- context.getMysqlChannel().reset();
- }
- context.getState().setOk(0, 0, "");
- // create plan
- if (context.getTxnEntry() != null &&
context.getTxnEntry().getRowsInTransaction() == 0
- && !context.getTxnEntry().isTransactionBegan()
- && (parsedStmt instanceof TransactionCommitStmt || parsedStmt
instanceof TransactionRollbackStmt)) {
- context.setTxnEntry(null);
- } else if (parsedStmt instanceof TransactionBeginStmt) {
- if (context.isTxnModel()) {
- LOG.info("A transaction has already begin");
- return;
- }
- if (context.getTxnEntry() == null) {
- context.setTxnEntry(new TransactionEntry());
- }
- context.getTxnEntry()
- .setTxnConf(new
TTxnParams().setNeedTxn(true).setThriftRpcTimeoutMs(5000).setTxnId(-1).setDb("")
-
.setTbl("").setMaxFilterRatio(context.getSessionVariable().getEnableInsertStrict()
? 0
- :
context.getSessionVariable().getInsertMaxFilterRatio()));
- context.getTxnEntry().setFirstTxnInsert(true);
- StringBuilder sb = new StringBuilder();
-
sb.append("{'label':'").append(context.getTxnEntry().getLabel()).append("',
'status':'")
- .append(TransactionStatus.PREPARE.name());
- sb.append("', 'txnId':'").append("'").append("}");
- context.getState().setOk(0, 0, sb.toString());
- } else if (parsedStmt instanceof TransactionCommitStmt) {
- if (!context.isTxnModel()) {
- LOG.info("No transaction to commit");
- return;
- }
- try {
- TransactionEntry txnEntry = context.getTxnEntry();
- TransactionStatus txnStatus = txnEntry.commitTransaction();
- StringBuilder sb = new StringBuilder();
- sb.append("{'label':'").append(txnEntry.getLabel()).append("',
'status':'")
- .append(txnStatus.name()).append("', 'txnId':'")
-
.append(txnEntry.getTransactionId()).append("'").append("}");
- context.getState().setOk(0, 0, sb.toString());
- } catch (Exception e) {
- LOG.warn("Txn commit failed", e);
- throw new AnalysisException(e.getMessage());
- } finally {
- context.setTxnEntry(null);
- }
- } else if (parsedStmt instanceof TransactionRollbackStmt) {
- if (!context.isTxnModel()) {
- LOG.info("No transaction to rollback");
- return;
- }
- try {
- TransactionEntry txnEntry = context.getTxnEntry();
- long txnId = txnEntry.abortTransaction();
- StringBuilder sb = new StringBuilder();
- sb.append("{'label':'").append(txnEntry.getLabel()).append("',
'status':'")
- .append(TransactionStatus.ABORTED.name()).append("',
'txnId':'")
- .append(txnId).append("'").append("}");
- context.getState().setOk(0, 0, sb.toString());
- } catch (Exception e) {
- throw new AnalysisException(e.getMessage());
- } finally {
- context.setTxnEntry(null);
- }
- } else {
- throw new TException("parsedStmt type is not TransactionStmt");
- }
- }
-
private int executeForTxn(InsertStmt insertStmt)
throws UserException, TException, InterruptedException,
ExecutionException, TimeoutException {
if (context.isInsertValuesTxnIniting()) { // first time, begin txn
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/analysis/InsertArrayStmtTest.java
b/fe/fe-core/src/test/java/org/apache/doris/analysis/InsertArrayStmtTest.java
index 0d6e09c5051..63864237e41 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/analysis/InsertArrayStmtTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/analysis/InsertArrayStmtTest.java
@@ -23,14 +23,7 @@ import org.apache.doris.catalog.PrimitiveType;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.ExceptionChecker;
import org.apache.doris.common.util.SqlParserUtils;
-import org.apache.doris.nereids.StatementContext;
-import org.apache.doris.nereids.glue.LogicalPlanAdapter;
-import org.apache.doris.nereids.trees.plans.commands.UnsupportedCommand;
import org.apache.doris.qe.ConnectContext;
-import org.apache.doris.qe.OriginStatement;
-import org.apache.doris.qe.QueryState;
-import org.apache.doris.qe.QueryState.MysqlStateType;
-import org.apache.doris.qe.StmtExecutor;
import org.apache.doris.thrift.TUniqueId;
import org.apache.doris.utframe.UtFrameUtils;
@@ -114,41 +107,4 @@ public class InsertArrayStmtTest {
ExceptionChecker.expectThrowsWithMsg(AnalysisException.class, "can not
cast from origin type",
() -> parseAndAnalyze("insert into test.table1 values (1, [[1,
2], [3, 4]]);"));
}
-
- @Test
- public void testTransactionalInsert() throws Exception {
- ExceptionChecker.expectThrowsNoException(
- () -> createTable("CREATE TABLE test.`txn_insert_tbl` (\n"
- + " `k1` int(11) NULL,\n"
- + " `k2` double NULL,\n"
- + " `k3` varchar(100) NULL,\n"
- + " `k4` array<int(11)> NULL,\n"
- + " `k5` array<boolean> NULL\n"
- + ") ENGINE=OLAP\n"
- + "DUPLICATE KEY(`k1`)\n"
- + "COMMENT 'OLAP'\n"
- + "DISTRIBUTED BY HASH(`k1`) BUCKETS 1\n"
- + "PROPERTIES (\n"
- + "\"replication_allocation\" =
\"tag.location.default: 1\",\n"
- + "\"in_memory\" = \"false\",\n"
- + "\"storage_format\" = \"V2\",\n"
- + "\"disable_auto_compaction\" = \"false\"\n"
- + ");"));
-
- OriginStatement originStatement = new OriginStatement("begin", 0);
- StatementBase begin = new LogicalPlanAdapter(new UnsupportedCommand(),
- new StatementContext(connectContext, originStatement));
- begin.setOrigStmt(originStatement);
- StmtExecutor stmtExecutor = new StmtExecutor(connectContext, begin);
- stmtExecutor.execute();
-
- originStatement = new OriginStatement("insert into test.txn_insert_tbl
values(2, 3.3, \"xyz\", [1], [1, 0]);", 0);
- StatementBase insert = new LogicalPlanAdapter(new UnsupportedCommand(),
- new StatementContext(connectContext, originStatement));
- insert.setOrigStmt(originStatement);
- stmtExecutor = new StmtExecutor(connectContext, insert);
- stmtExecutor.execute();
- QueryState state = connectContext.getState();
- Assert.assertEquals(state.getErrorMessage(), MysqlStateType.OK,
state.getStateType());
- }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]