[CP] fix nullif replace var expr report 4016 bug
This commit is contained in:
6
deps/oblib/src/lib/charset/ob_charset.cpp
vendored
6
deps/oblib/src/lib/charset/ob_charset.cpp
vendored
@ -1136,7 +1136,7 @@ int ObCharset::mb_wc(ObCollationType collation_type, const ObString& mb, int32_t
|
|||||||
reinterpret_cast<const unsigned char*>(mb.ptr() + mb.length()),
|
reinterpret_cast<const unsigned char*>(mb.ptr() + mb.length()),
|
||||||
&res_wc);
|
&res_wc);
|
||||||
if (tmp <= 0) {
|
if (tmp <= 0) {
|
||||||
ret = OB_ERROR;
|
ret = OB_ERR_INCORRECT_STRING_VALUE;
|
||||||
} else {
|
} else {
|
||||||
ret = OB_SUCCESS;
|
ret = OB_SUCCESS;
|
||||||
wc = static_cast<int32_t>(res_wc);
|
wc = static_cast<int32_t>(res_wc);
|
||||||
@ -1164,7 +1164,7 @@ int ObCharset::mb_wc(
|
|||||||
int tmp = cs->cset->mb_wc(
|
int tmp = cs->cset->mb_wc(
|
||||||
reinterpret_cast<const unsigned char*>(mb), reinterpret_cast<const unsigned char*>(mb + mb_size), &res_wc);
|
reinterpret_cast<const unsigned char*>(mb), reinterpret_cast<const unsigned char*>(mb + mb_size), &res_wc);
|
||||||
if (tmp <= 0) {
|
if (tmp <= 0) {
|
||||||
ret = OB_ERROR;
|
ret = OB_ERR_INCORRECT_STRING_VALUE;
|
||||||
} else {
|
} else {
|
||||||
ret = OB_SUCCESS;
|
ret = OB_SUCCESS;
|
||||||
wc = static_cast<int32_t>(res_wc);
|
wc = static_cast<int32_t>(res_wc);
|
||||||
@ -1283,7 +1283,7 @@ int ObCharset::wc_mb(ObCollationType collation_type, int32_t wc, char* buff, int
|
|||||||
int tmp = cs->cset->wc_mb(
|
int tmp = cs->cset->wc_mb(
|
||||||
wc, reinterpret_cast<unsigned char*>(buff), reinterpret_cast<unsigned char*>(buff + buff_len));
|
wc, reinterpret_cast<unsigned char*>(buff), reinterpret_cast<unsigned char*>(buff + buff_len));
|
||||||
if (tmp <= 0) {
|
if (tmp <= 0) {
|
||||||
ret = OB_ERROR;
|
ret = OB_ERR_INCORRECT_STRING_VALUE;
|
||||||
} else {
|
} else {
|
||||||
ret = OB_SUCCESS;
|
ret = OB_SUCCESS;
|
||||||
length = tmp;
|
length = tmp;
|
||||||
|
|||||||
@ -986,10 +986,6 @@ int ObStaticEngineExprCG::replace_var_rt_expr(ObExpr* origin_expr,
|
|||||||
if (OB_ISNULL(parent_expr) || OB_UNLIKELY(parent_expr->arg_cnt_ < var_idx + 1)) {
|
if (OB_ISNULL(parent_expr) || OB_UNLIKELY(parent_expr->arg_cnt_ < var_idx + 1)) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_WARN("invalid param", KPC(parent_expr));
|
LOG_WARN("invalid param", KPC(parent_expr));
|
||||||
} else if (OB_UNLIKELY(var_expr->datum_meta_.type_ != origin_expr->datum_meta_.type_
|
|
||||||
|| var_expr->datum_meta_.cs_type_ != origin_expr->datum_meta_.cs_type_)) {
|
|
||||||
ret = OB_ERR_UNEXPECTED;
|
|
||||||
LOG_WARN("exec var meta diff from origin expr meta", K(ret), KPC(origin_expr), KPC(var_expr));
|
|
||||||
} else {
|
} else {
|
||||||
parent_expr->args_[var_idx] = origin_expr;
|
parent_expr->args_[var_idx] = origin_expr;
|
||||||
}
|
}
|
||||||
@ -1015,19 +1011,26 @@ int ObStaticEngineExprCG::replace_var_rt_expr(ObExpr* origin_expr,
|
|||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_WARN("expr is null", K(ret), KPC(parent_expr));
|
LOG_WARN("expr is null", K(ret), KPC(parent_expr));
|
||||||
} else if (T_EXEC_VAR == var_expr->type_) {
|
} else if (T_EXEC_VAR == var_expr->type_) {
|
||||||
if (OB_UNLIKELY(var_expr->datum_meta_.type_ != origin_expr->datum_meta_.type_
|
|
||||||
|| var_expr->datum_meta_.cs_type_ != origin_expr->datum_meta_.cs_type_)) {
|
|
||||||
ret = OB_ERR_UNEXPECTED;
|
|
||||||
LOG_WARN("exec var meta diff from origin expr meta", K(ret), KPC(origin_expr), KPC(var_expr));
|
|
||||||
} else {
|
|
||||||
parent_expr->args_[var_idx] = origin_expr;
|
parent_expr->args_[var_idx] = origin_expr;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
parent_expr = var_expr;
|
parent_expr = var_expr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (OB_SUCC(ret) && T_EXEC_VAR == var_expr->type_) {
|
||||||
|
if (OB_UNLIKELY(
|
||||||
|
ObNullType != var_expr->datum_meta_.type_ && ObNullType != origin_expr->datum_meta_.type_ &&
|
||||||
|
ob_obj_type_class(var_expr->datum_meta_.type_) != ob_obj_type_class(origin_expr->datum_meta_.type_))) {
|
||||||
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
LOG_WARN("exec var meta diff from origin expr meta", K(ret), KPC(origin_expr), KPC(var_expr));
|
||||||
|
} else if (OB_UNLIKELY(ob_is_string_or_lob_type(var_expr->datum_meta_.type_) &&
|
||||||
|
ob_is_string_or_lob_type(origin_expr->datum_meta_.type_) &&
|
||||||
|
var_expr->datum_meta_.cs_type_ != origin_expr->datum_meta_.cs_type_)) {
|
||||||
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
LOG_WARN("exec var collation diff from origin expr collation", K(ret), KPC(origin_expr), KPC(var_expr));
|
||||||
|
}
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -230,10 +230,10 @@ int ObExprNullif::cg_expr(ObExprCGCtx& expr_cg_ctx, const ObRawExpr& raw_expr, O
|
|||||||
for (int64_t i = 0; OB_SUCC(ret) && i < real_param_num; i++) {
|
for (int64_t i = 0; OB_SUCC(ret) && i < real_param_num; i++) {
|
||||||
if (OB_FAIL(ObStaticEngineExprCG::replace_var_rt_expr(
|
if (OB_FAIL(ObStaticEngineExprCG::replace_var_rt_expr(
|
||||||
rt_expr.args_[i], rt_expr.args_[i + real_param_num], &rt_expr, i + real_param_num))) {
|
rt_expr.args_[i], rt_expr.args_[i + real_param_num], &rt_expr, i + real_param_num))) {
|
||||||
LOG_WARN("replace var rt expr failed", K(ret));
|
LOG_WARN("replace var rt expr failed", K(ret), K(i), K(raw_expr));
|
||||||
} else if (OB_FAIL(ObStaticEngineExprCG::replace_var_rt_expr(
|
} else if (OB_FAIL(ObStaticEngineExprCG::replace_var_rt_expr(
|
||||||
rt_expr.args_[i], rt_expr.args_[i + 2 * real_param_num], &rt_expr, i + 2 * real_param_num))) {
|
rt_expr.args_[i], rt_expr.args_[i + 2 * real_param_num], &rt_expr, i + 2 * real_param_num))) {
|
||||||
LOG_WARN("replace var rt expr failed", K(ret));
|
LOG_WARN("replace var rt_expr failed", K(ret), K(i), K(raw_expr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (OB_FAIL(ret)) {
|
if (OB_FAIL(ret)) {
|
||||||
|
|||||||
@ -78,7 +78,13 @@ int ObExprQuote::calc_result1(ObObj& result, const ObObj& obj, ObExprCtx& expr_c
|
|||||||
ObString str = obj.get_string();
|
ObString str = obj.get_string();
|
||||||
ObString res_str;
|
ObString res_str;
|
||||||
if (OB_FAIL(calc(res_str, str, obj.get_collation_type(), expr_ctx.calc_buf_))) {
|
if (OB_FAIL(calc(res_str, str, obj.get_collation_type(), expr_ctx.calc_buf_))) {
|
||||||
|
result.set_null();
|
||||||
|
// ret = OB_ERR_INCORRECT_STRING_VALUE means input string is not invalid, then output NULL.
|
||||||
|
if (OB_ERR_INCORRECT_STRING_VALUE == ret) {
|
||||||
|
ret = OB_SUCCESS;
|
||||||
|
} else {
|
||||||
LOG_WARN("calc quote expr failed", K(ret), K(str));
|
LOG_WARN("calc quote expr failed", K(ret), K(str));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
result.set_varchar(res_str);
|
result.set_varchar(res_str);
|
||||||
result.set_collation(result_type_);
|
result.set_collation(result_type_);
|
||||||
@ -180,7 +186,13 @@ int ObExprQuote::calc_quote_expr(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& re
|
|||||||
ObString res_str;
|
ObString res_str;
|
||||||
ObExprStrResAlloc res_alloc(expr, ctx);
|
ObExprStrResAlloc res_alloc(expr, ctx);
|
||||||
if (OB_FAIL(calc(res_str, str, expr.datum_meta_.cs_type_, &res_alloc))) {
|
if (OB_FAIL(calc(res_str, str, expr.datum_meta_.cs_type_, &res_alloc))) {
|
||||||
|
res_datum.set_null();
|
||||||
|
// ret = OB_ERR_INCORRECT_STRING_VALUE means input string is not invalid, then output NULL.
|
||||||
|
if (OB_ERR_INCORRECT_STRING_VALUE == ret) {
|
||||||
|
ret = OB_SUCCESS;
|
||||||
|
} else {
|
||||||
LOG_WARN("calc quote expr failed", K(ret), K(str));
|
LOG_WARN("calc quote expr failed", K(ret), K(str));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
res_datum.set_string(res_str);
|
res_datum.set_string(res_str);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user