提交 8064e195 编写于 作者: B br0 提交者: wangzelin.wzl

Fix casting error for year to bit

上级 df707d35
...@@ -3400,10 +3400,10 @@ static int year_bit( ...@@ -3400,10 +3400,10 @@ static int year_bit(
if (OB_UNLIKELY(ObYearTC != in.get_type_class() || ObBitTC != ob_obj_type_class(expect_type))) { if (OB_UNLIKELY(ObYearTC != in.get_type_class() || ObBitTC != ob_obj_type_class(expect_type))) {
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
LOG_ERROR("invalid input type", K(ret), K(in), K(expect_type)); LOG_ERROR("invalid input type", K(ret), K(in), K(expect_type));
} else if (OB_FAIL(year_string(ObVarcharType, params, in, tmp_val, cast_mode))) { } else if (OB_FAIL(year_int(ObIntType, params, in, tmp_val, cast_mode))) {
LOG_WARN("fail to cast datetime to string", K(ret), K(expect_type), K(in), K(tmp_val)); LOG_WARN("fail to cast datetime to int", K(ret), K(expect_type), K(in), K(tmp_val));
} else if (OB_FAIL(string_bit(expect_type, params, tmp_val, out, cast_mode))) { } else if (OB_FAIL(int_bit(expect_type, params, tmp_val, out, cast_mode))) {
LOG_WARN("fail to cast string to bit", K(ret), K(expect_type), K(in), K(tmp_val)); LOG_WARN("fail to cast int to bit", K(ret), K(expect_type), K(in), K(tmp_val));
} }
return ret; return ret;
} }
......
...@@ -3273,16 +3273,12 @@ CAST_FUNC_NAME(year, bit) ...@@ -3273,16 +3273,12 @@ CAST_FUNC_NAME(year, bit)
{ {
EVAL_ARG() EVAL_ARG()
{ {
char buf[OB_CAST_TO_VARCHAR_MAX_LENGTH] = {0}; int64_t year_int = 0;
int64_t len = 0;
uint8_t in_val = child_res->get_uint8(); uint8_t in_val = child_res->get_uint8();
if (OB_FAIL(ObTimeConverter::year_to_str(in_val, buf, sizeof(buf), len))) { if (OB_FAIL(ObTimeConverter::year_to_int(in_val, year_int))) {
LOG_WARN("year_to_str failed", K(ret)); LOG_WARN("year_to_int failed", K(ret), K(in_val));
} else { } else if (OB_FAIL(common_uint_bit(expr, year_int, ctx, res_datum))) {
ObString in_str(len, buf); LOG_WARN("common_uint_bit failed", K(ret), K(year_int));
if (OB_FAIL(common_string_bit(expr, in_str, ctx, res_datum))) {
LOG_WARN("common_string_bit failed", K(ret), K(in_str));
}
} }
} }
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册