Skip to content

Commit

Permalink
[Fix](Prepared Statment) use fixed charset to init StringLiteral (apa…
Browse files Browse the repository at this point in the history
  • Loading branch information
eldenmoon authored and weixingyu12 committed Jul 17, 2024
1 parent 980cfc9 commit 54cb9b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.Objects;

public class StringLiteral extends LiteralExpr {
Expand Down Expand Up @@ -310,7 +311,9 @@ public void setupParamFromBinary(ByteBuffer data, boolean isUnsigned) {
}
byte[] bytes = new byte[strLen];
data.get(bytes);
value = new String(bytes);
// ATTN: use fixed StandardCharsets.UTF_8 to avoid unexpected charset in
// different environment
value = new String(bytes, StandardCharsets.UTF_8);
if (LOG.isDebugEnabled()) {
LOG.debug("parsed value '{}'", value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,9 @@ private static boolean isNull(byte[] bitmap, int position) {
// process COM_EXECUTE, parse binary row data
// https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_com_stmt_execute.html
private void handleExecute() {
// debugPacket();
if (LOG.isDebugEnabled()) {
debugPacket();
}
packetBuf = packetBuf.order(ByteOrder.LITTLE_ENDIAN);
// parse stmt_id, flags, params
int stmtId = packetBuf.getInt();
Expand Down

0 comments on commit 54cb9b4

Please sign in to comment.