diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/PrepareCommand.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/PrepareCommand.java index ebddcd68845185..a844dcb9500796 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/PrepareCommand.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/PrepareCommand.java @@ -109,7 +109,7 @@ public void run(ConnectContext ctx, StmtExecutor executor) throws Exception { } ctx.addPreparedStatementContext(name, new PreparedStatementContext(this, ctx, ctx.getStatementContext(), name)); - if (ctx.getCommand() == MysqlCommand.COM_STMT_PREPARE && !ctx.isProxy()) { + if (ctx.getCommand() == MysqlCommand.COM_STMT_PREPARE) { executor.sendStmtPrepareOK(Integer.parseInt(name), labels); } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java index c677edf5d6eee8..a82d5e0929931b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java @@ -69,8 +69,6 @@ import com.google.common.collect.Maps; import com.google.common.collect.Sets; import io.netty.util.concurrent.FastThreadLocal; -import lombok.Getter; -import lombok.Setter; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -78,7 +76,6 @@ import org.xnio.StreamConnection; import java.io.IOException; -import java.nio.ByteBuffer; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -242,10 +239,6 @@ public enum ConnectType { // it's default thread-safe private boolean isProxy = false; - @Getter - @Setter - private ByteBuffer prepareExecuteBuffer; - private MysqlHandshakePacket mysqlHandshakePacket; public void setUserQueryTimeout(int queryTimeout) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java index 85104262014e3b..cc75c72ec6f365 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java @@ -61,7 +61,6 @@ import org.apache.doris.nereids.parser.NereidsParser; import org.apache.doris.nereids.stats.StatsErrorEstimator; import org.apache.doris.nereids.trees.plans.commands.ExplainCommand; -import org.apache.doris.nereids.trees.plans.commands.PrepareCommand; import org.apache.doris.nereids.trees.plans.logical.LogicalPlan; import org.apache.doris.nereids.trees.plans.logical.LogicalSqlCache; import org.apache.doris.plugin.DialectConverterPlugin; @@ -88,7 +87,6 @@ import java.io.IOException; import java.io.StringReader; import java.nio.ByteBuffer; -import java.nio.ByteOrder; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -695,6 +693,7 @@ public TMasterOpResult proxyExecute(TMasterOpRequest request) throws TException ctx.setResourceTags(Env.getCurrentEnv().getAuth().getResourceTags(ctx.qualifiedUser)); ctx.setThreadLocalInfo(); + StmtExecutor executor = null; try { // 0 for compatibility. int idx = request.isSetStmtIdx() ? request.getStmtIdx() : 0; @@ -723,25 +722,7 @@ public TMasterOpResult proxyExecute(TMasterOpRequest request) throws TException queryId = new TUniqueId(uuid.getMostSignificantBits(), uuid.getLeastSignificantBits()); } - if (request.isSetPrepareExecuteBuffer()) { - ctx.setCommand(MysqlCommand.COM_STMT_PREPARE); - executor.execute(); - ctx.setCommand(MysqlCommand.COM_STMT_EXECUTE); - String preparedStmtId = executor.getPrepareStmtName(); - PreparedStatementContext preparedStatementContext = ctx.getPreparedStementContext(preparedStmtId); - if (preparedStatementContext == null) { - if (LOG.isDebugEnabled()) { - LOG.debug("Something error, just support nereids preparedStmtId:{}", preparedStmtId); - } - throw new RuntimeException("Prepare failed when proxy execute"); - } - handleExecute(preparedStatementContext.command, Long.parseLong(preparedStmtId), - preparedStatementContext, - ByteBuffer.wrap(request.getPrepareExecuteBuffer()).order(ByteOrder.LITTLE_ENDIAN), queryId); - } else { - executor.execute(queryId); - } - + executor.execute(queryId); } catch (IOException e) { // Client failed. LOG.warn("Process one query failed because IOException: ", e); @@ -791,11 +772,6 @@ public void processOnce() throws IOException, NotImplementedException { throw new NotImplementedException("Not Impl processOnce"); } - protected void handleExecute(PrepareCommand prepareCommand, long stmtId, PreparedStatementContext prepCtx, - ByteBuffer packetBuf, TUniqueId queryId) { - throw new NotSupportedException("Just MysqlConnectProcessor support execute"); - } - private Map userVariableFromThrift(Map thriftMap) throws TException { try { Map userVariables = Maps.newHashMap(); diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java index 3cf5f2edc4bf91..23f11f41173140 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java @@ -23,7 +23,6 @@ import org.apache.doris.common.ClientPool; import org.apache.doris.common.DdlException; import org.apache.doris.common.ErrorCode; -import org.apache.doris.mysql.MysqlCommand; import org.apache.doris.thrift.FrontendService; import org.apache.doris.thrift.TExpr; import org.apache.doris.thrift.TExprNode; @@ -184,12 +183,6 @@ private TMasterOpRequest buildStmtForwardParams() { if (null != ctx.queryId()) { params.setQueryId(ctx.queryId()); } - if (ctx.getCommand() == MysqlCommand.COM_STMT_EXECUTE) { - if (null != ctx.getPrepareExecuteBuffer()) { - params.setPrepareExecuteBuffer(ctx.getPrepareExecuteBuffer()); - } - } - return params; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/MysqlConnectProcessor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/MysqlConnectProcessor.java index d6304b8c844196..f40bae578a4933 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/MysqlConnectProcessor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/MysqlConnectProcessor.java @@ -46,7 +46,6 @@ import org.apache.doris.nereids.trees.plans.PlaceholderId; import org.apache.doris.nereids.trees.plans.commands.ExecuteCommand; import org.apache.doris.nereids.trees.plans.commands.PrepareCommand; -import org.apache.doris.thrift.TUniqueId; import com.google.common.base.Preconditions; import com.google.common.base.Strings; @@ -171,18 +170,7 @@ private void handleExecute(PrepareStmt prepareStmt, long stmtId) { } } - private String getHexStr(ByteBuffer packetBuf) { - byte[] bytes = packetBuf.array(); - StringBuilder hex = new StringBuilder(); - for (int i = packetBuf.position(); i < packetBuf.limit(); ++i) { - hex.append(String.format("%02X ", bytes[i])); - } - return hex.toString(); - } - - @Override - protected void handleExecute(PrepareCommand prepareCommand, long stmtId, PreparedStatementContext prepCtx, - ByteBuffer packetBuf, TUniqueId queryId) { + private void handleExecute(PrepareCommand prepareCommand, long stmtId, PreparedStatementContext prepCtx) { int paramCount = prepareCommand.placeholderCount(); LOG.debug("execute prepared statement {}, paramCount {}", stmtId, paramCount); // null bitmap @@ -190,13 +178,6 @@ protected void handleExecute(PrepareCommand prepareCommand, long stmtId, Prepare try { StatementContext statementContext = prepCtx.statementContext; if (paramCount > 0) { - if (LOG.isDebugEnabled()) { - LOG.debug("execute param buf: {}, array: {}", packetBuf, getHexStr(packetBuf)); - } - if (!ctx.isProxy()) { - ctx.setPrepareExecuteBuffer(packetBuf.duplicate()); - } - byte[] nullbitmapData = new byte[(paramCount + 7) / 8]; packetBuf.get(nullbitmapData); // new_params_bind_flag @@ -237,12 +218,7 @@ protected void handleExecute(PrepareCommand prepareCommand, long stmtId, Prepare stmt.setOrigStmt(prepareCommand.getOriginalStmt()); executor = new StmtExecutor(ctx, stmt); ctx.setExecutor(executor); - if (null != queryId) { - executor.execute(queryId); - } else { - executor.execute(); - } - + executor.execute(); if (ctx.getSessionVariable().isEnablePreparedStmtAuditLog()) { stmtStr = executeStmt.toSql(); stmtStr = stmtStr + " /*originalSql = " + prepareCommand.getOriginalStmt().originStmt + "*/"; @@ -257,7 +233,6 @@ protected void handleExecute(PrepareCommand prepareCommand, long stmtId, Prepare if (ctx.getSessionVariable().isEnablePreparedStmtAuditLog()) { auditAfterExec(stmtStr, executor.getParsedStmt(), executor.getQueryStatisticsForAuditLog(), true); } - ctx.setPrepareExecuteBuffer(null); } // process COM_EXECUTE, parse binary row data @@ -291,7 +266,7 @@ private void handleExecute() { "msg: Not supported such prepared statement"); return; } - handleExecute(preparedStatementContext.command, stmtId, preparedStatementContext, packetBuf, null); + handleExecute(preparedStatementContext.command, stmtId, preparedStatementContext); } } 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 55dc0dfaba339a..5f3bf4c1b1e7ae 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 @@ -143,7 +143,6 @@ import org.apache.doris.nereids.minidump.MinidumpUtils; import org.apache.doris.nereids.parser.NereidsParser; import org.apache.doris.nereids.rules.exploration.mv.InitMaterializationContextHook; -import org.apache.doris.nereids.trees.expressions.Placeholder; import org.apache.doris.nereids.trees.plans.commands.Command; import org.apache.doris.nereids.trees.plans.commands.CreateTableCommand; import org.apache.doris.nereids.trees.plans.commands.DeleteFromCommand; @@ -268,7 +267,6 @@ public class StmtExecutor { private Data.PQueryStatistics.Builder statisticsForAuditLog; private boolean isCached; private String stmtName; - private String prepareStmtName; // for proxy private StatementBase prepareStmt = null; private String mysqlLoadId; // Distinguish from prepare and execute command @@ -683,10 +681,8 @@ private void executeByNereids(TUniqueId queryId) throws Exception { } long stmtId = Config.prepared_stmt_start_id > 0 ? Config.prepared_stmt_start_id : context.getPreparedStmtId(); - this.prepareStmtName = String.valueOf(stmtId); - List placeholders = context == null - ? statementContext.getPlaceholders() : context.getStatementContext().getPlaceholders(); - logicalPlan = new PrepareCommand(prepareStmtName, logicalPlan, placeholders, originStmt); + logicalPlan = new PrepareCommand(String.valueOf(stmtId), + logicalPlan, statementContext.getPlaceholders(), originStmt); } // when we in transaction mode, we only support insert into command and transaction command if (context.isTxnModel()) { @@ -3481,8 +3477,4 @@ public void sendProxyQueryResult() throws IOException { context.getMysqlChannel().sendOnePacket(byteBuffer); } } - - public String getPrepareStmtName() { - return this.prepareStmtName; - } } diff --git a/gensrc/thrift/FrontendService.thrift b/gensrc/thrift/FrontendService.thrift index 64f6578f68f708..746d5d7e5d8607 100644 --- a/gensrc/thrift/FrontendService.thrift +++ b/gensrc/thrift/FrontendService.thrift @@ -571,7 +571,6 @@ struct TMasterOpRequest { // transaction load 29: optional TTxnLoadInfo txnLoadInfo 30: optional TGroupCommitInfo groupCommitInfo - 31: optional binary prepareExecuteBuffer } struct TColumnDefinition {