Asthenia0412 opened a new pull request, #67982: URL: https://github.com/apache/doris/pull/67982
### What problem does this PR solve? Issue Number: close #65848 Problem Summary: A prepared write statement executed on a non-master FE and forwarded to the master FE fails with `NoSuchElementException` (errCode 1105) on cached `COM_STMT_EXECUTE`. **Reproduction:** 1. Connect to a non-master FE with a MySQL client supporting prepared statements. 2. `PREPARE` / `EXECUTE` an `INSERT ... VALUES (?, ...)` statement (the first execute sends `new_params_bind_flag = 1` with the parameter types). 3. Run the same prepared statement again without re-prepare. The client sends a cached execute with `new_params_bind_flag = 0`, so the parameter types are omitted from the packet. 4. Because the statement is a write statement, the follower forwards `COM_STMT_EXECUTE` to the master FE. The master re-prepares the statement and never sees the parameter types, so it cannot decode the parameter values and fails. **Root cause:** In `MysqlConnectProcessor.handleExecute`, the forwarded `COM_STMT_EXECUTE` buffer is set before the parameter types are parsed. On a cached repeat execute the client omits the types (`new_params_bind_flag == 0`), and the forwarded buffer contains only the null bitmap and the parameter values, so the master cannot decode them. **Fix:** When a cached execute omits the parameter types, embed the types known from the first execute into the forwarded buffer and set `new_params_bind_flag = 1`. The buffer keeps the standard MySQL `COM_STMT_EXECUTE` layout (null bitmap | flag | parameter types | parameter values), so older masters accept it unchanged. Zero-parameter executes keep forwarding the raw (empty) buffer. ### Release note None ### Check List (For Author) - Test: Unit test `MysqlConnectProcessorPreparedStmtForwardTest` covering cached execute, first execute and zero-parameter cases. - Behavior changed: No - Does this need documentation: No -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
