fix unhex bug

This commit is contained in:
rh0 2022-03-03 10:22:54 +08:00 committed by LINxiansheng
parent 42bdc0f45d
commit 104dab5c02
3 changed files with 18 additions and 6 deletions

View File

@ -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));

View File

@ -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));

View File

@ -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));