diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/StringLiteral.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/StringLiteral.java index e26cbffe6420bf..619b757c5fcac0 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/StringLiteral.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/StringLiteral.java @@ -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 { @@ -344,7 +345,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); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/Literal.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/Literal.java index 4619e35d5e06b0..fe53cbf0e2ab46 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/Literal.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/Literal.java @@ -45,6 +45,7 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; import java.util.Locale; import java.util.Objects; import java.util.Optional; @@ -582,7 +583,9 @@ private static Literal handleStringLiteral(ByteBuffer data) { strLen = Math.min(strLen, data.remaining()); byte[] bytes = new byte[strLen]; data.get(bytes); - return new StringLiteral(new String(bytes)); + // ATTN: use fixed StandardCharsets.UTF_8 to avoid unexpected charset in + // different environment + return new StringLiteral(new String(bytes, StandardCharsets.UTF_8)); } private static Literal handleVarcharLiteral(ByteBuffer data) { @@ -590,6 +593,8 @@ private static Literal handleVarcharLiteral(ByteBuffer data) { strLen = Math.min(strLen, data.remaining()); byte[] bytes = new byte[strLen]; data.get(bytes); - return new VarcharLiteral(new String(bytes)); + // ATTN: use fixed StandardCharsets.UTF_8 to avoid unexpected charset in + // different environment + return new VarcharLiteral(new String(bytes, StandardCharsets.UTF_8)); } } 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 4e383120f195cd..b772da388db249 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 @@ -213,7 +213,9 @@ private void handleExecute(PrepareCommand prepareCommand, long stmtId, PreparedS // 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();