Skip to content

Commit

Permalink
[fix](group commit) Fix prepare stmt setNull return too many filtered…
Browse files Browse the repository at this point in the history
… rows error (#38262)

When use prepare statement and setNull to do group commit:
```
stmt.setString(3, "WAGERNO");
stmt.setNull(4, Types.INTEGER);
```
we may get `too many rows filtered` rows.
  • Loading branch information
mymeiyi authored Jul 24, 2024
1 parent 83276c9 commit 1e304bd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.apache.doris.analysis.NullLiteral;
import org.apache.doris.analysis.OutFileClause;
import org.apache.doris.analysis.PartitionNames;
import org.apache.doris.analysis.PlaceHolderExpr;
import org.apache.doris.analysis.PrepareStmt;
import org.apache.doris.analysis.PrepareStmt.PreparedType;
import org.apache.doris.analysis.Queriable;
Expand Down Expand Up @@ -351,6 +352,9 @@ public static InternalService.PDataRow getRowStringValue(List<Expr> cols,
}
InternalService.PDataRow.Builder row = InternalService.PDataRow.newBuilder();
for (Expr expr : cols) {
if (expr instanceof PlaceHolderExpr) {
expr = ((PlaceHolderExpr) expr).getLiteral();
}
if (!expr.isLiteralOrCastExpr()) {
throw new UserException(
"do not support non-literal expr in transactional insert operation: " + expr.toSql());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ suite("insert_group_commit_with_prepare_stmt") {
);
"""

sql """ set enable_insert_strict = false; """

// 1. insert into
def insert_stmt = prepareStatement """ INSERT INTO ${table} VALUES(?, ?, ?) """
assertEquals(com.mysql.cj.jdbc.ServerPreparedStatement, insert_stmt.class)
Expand Down Expand Up @@ -212,8 +210,6 @@ suite("insert_group_commit_with_prepare_stmt") {
);
"""

sql """ set enable_insert_strict = false; """

// 1. insert into
def insert_stmt = prepareStatement """ INSERT INTO ${table} VALUES(?, ?, ?) """
assertEquals(com.mysql.cj.jdbc.ServerPreparedStatement, insert_stmt.class)
Expand Down

0 comments on commit 1e304bd

Please sign in to comment.