提交 104dab5c 编写于 作者: R rh0 提交者: LINGuanRen

fix unhex bug

上级 42bdc0f4
......@@ -55,8 +55,12 @@ int ObHexUtilsBase::unhex(const ObString& text, ObIAllocator& alloc, ObObj& resu
while (OB_SUCC(ret) && all_valid_char && i < text.length()) {
if (isxdigit(c1) && isxdigit(c2)) {
buf[i / 2] = (char)((get_xdigit(c1) << 4) | get_xdigit(c2));
c1 = text[++i];
c2 = text[++i];
if (i + 2 < text.length()) {
c1 = text[++i];
c2 = text[++i];
} else {
break;
}
} else if (lib::is_oracle_mode()) {
ret = OB_ERR_INVALID_HEX_NUMBER;
LOG_WARN("invalid hex number", K(ret), K(c1), K(c2), K(text));
......
......@@ -538,8 +538,12 @@ int ObHexUtils::unhex(const ObString& text, ObCastCtx& cast_ctx, ObObj& result)
while (OB_SUCC(ret) && i < text.length()) {
if (isxdigit(c1) && isxdigit(c2)) {
buf[i / 2] = (char)((get_xdigit(c1) << 4) | get_xdigit(c2));
c1 = text[++i];
c2 = text[++i];
if (i + 2 < text.length()) {
c1 = text[++i];
c2 = text[++i];
} else {
break;
}
} else {
ret = OB_ERR_INVALID_HEX_NUMBER;
LOG_WARN("invalid hex number", K(ret), K(c1), K(c2), K(text));
......
......@@ -512,8 +512,12 @@ int ObDatumHexUtils::unhex(const ObExpr& expr, const ObString& in_str, ObEvalCtx
while (OB_SUCC(ret) && i < in_str.length()) {
if (isxdigit(c1) && isxdigit(c2)) {
buf[i / 2] = (char)((get_xdigit(c1) << 4) | get_xdigit(c2));
c1 = in_str[++i];
c2 = in_str[++i];
if (i + 2 < in_str.length()) {
c1 = in_str[++i];
c2 = in_str[++i];
} else {
break;
}
} else {
ret = OB_ERR_INVALID_HEX_NUMBER;
LOG_WARN("invalid hex number", K(ret), K(c1), K(c2), K(in_str));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册