This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 0636fa884bd branch-2.1: [fix](prepare statement)Throw exception when
prepare placeholder more than 65536. (#54571)
0636fa884bd is described below
commit 0636fa884bdad4c524c44eaf578d19a8b1a9cbde
Author: James <[email protected]>
AuthorDate: Wed Aug 13 14:47:48 2025 +0800
branch-2.1: [fix](prepare statement)Throw exception when prepare
placeholder more than 65536. (#54571)
backport: https://github.com/apache/doris/pull/54568
---
.../src/main/java/org/apache/doris/qe/StmtExecutor.java | 4 ++++
regression-test/suites/prepared_stmt_p0/prepared_stmt.groovy | 12 +++++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
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 05bb067acca..5f1b739a5c5 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
@@ -251,6 +251,7 @@ public class StmtExecutor {
private static final AtomicLong STMT_ID_GENERATOR = new AtomicLong(0);
public static final int MAX_DATA_TO_SEND_FOR_TXN = 100;
public static final String NULL_VALUE_FOR_LOAD = "\\N";
+ private final int maxPlaceholderCount = 65536;
private ConnectContext context;
private final StatementContext statementContext;
private MysqlSerializer serializer;
@@ -2555,6 +2556,9 @@ public class StmtExecutor {
private void handlePrepareStmt() throws Exception {
List<String> labels = ((PrepareStmt)
prepareStmt).getColLabelsOfPlaceHolders();
+ if (labels.size() >= maxPlaceholderCount) {
+ ErrorReport.reportAnalysisException(ErrorCode.ERR_PS_MANY_PARAM);
+ }
// register prepareStmt
if (LOG.isDebugEnabled()) {
LOG.debug("add prepared statement {}, isBinaryProtocol {}",
diff --git a/regression-test/suites/prepared_stmt_p0/prepared_stmt.groovy
b/regression-test/suites/prepared_stmt_p0/prepared_stmt.groovy
index 1c6934c4009..f3b56fc1233 100644
--- a/regression-test/suites/prepared_stmt_p0/prepared_stmt.groovy
+++ b/regression-test/suites/prepared_stmt_p0/prepared_stmt.groovy
@@ -63,7 +63,17 @@ suite("test_prepared_stmt", "nonConcurrent") {
sql "set enable_fallback_to_original_planner = false"
sql """set global enable_server_side_prepared_statement = true"""
- def stmt_read = prepareStatement "select * from ${tableName} where k1
= ? order by k1"
+ int count = 65536;
+ StringBuilder sb = new StringBuilder();
+ sb.append("?");
+ for (int i = 1; i < count; i++) {
+ sb.append(", ?");
+ }
+ String sqlWithTooManyPlaceholder = sb.toString();
+ def stmt_read = prepareStatement "select * from ${tableName} where k1
in ${sqlWithTooManyPlaceholder}"
+ assertEquals(com.mysql.cj.jdbc.ClientPreparedStatement,
stmt_read.class)
+
+ stmt_read = prepareStatement "select * from ${tableName} where k1 = ?
order by k1"
assertEquals(stmt_read.class,
com.mysql.cj.jdbc.ServerPreparedStatement);
stmt_read.setInt(1, 1231)
qe_select0 stmt_read
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]