Fix compare routine for questionamrk expr

This commit is contained in:
obdev 2024-02-07 20:52:15 +00:00 committed by ob-robot
parent 7c915acc34
commit a97235802c
3 changed files with 27 additions and 4 deletions

View File

@ -781,6 +781,7 @@ class EventTable
EN_CHEN = 2101,
EN_ENABLE_TABLE_LOCK = 2102,
EN_ENABLE_ROWKEY_CONFLICT_CHECK = 2103,
EN_ENABLE_ORA_DECINT_CONST = 2104,
// WR && ASH
EN_CLOSE_ASH = 2201,

View File

@ -1057,9 +1057,29 @@ bool ObConstRawExpr::inner_same_as(
ObExprEqualCheckContext *check_context) const
{
bool bool_ret = false;
if ((T_QUESTIONMARK == get_expr_type() && is_dynamic_eval_questionmark())
|| (T_QUESTIONMARK == expr.get_expr_type() && expr.is_static_const_expr()
&& static_cast<const ObConstRawExpr &>(expr).is_dynamic_eval_questionmark())) {
bool left_dyn_const = (T_QUESTIONMARK == get_expr_type() && is_dynamic_eval_questionmark());
bool right_dyn_const = (T_QUESTIONMARK == expr.get_expr_type() && expr.is_static_const_expr()
&& static_cast<const ObConstRawExpr &>(expr).is_dynamic_eval_questionmark());
if (left_dyn_const && right_dyn_const) {
// if following conditions are matched, two dynamic evaluated question_marks are same:
// 1. param_idxes are same
// 2. result_types are same
// 3. cast modes are same
const ObConstRawExpr &r_expr = static_cast<const ObConstRawExpr &>(expr);
if (check_context != NULL) {
int64_t l_param_idx = -1, r_param_idx = -1;
int &ret = check_context->err_code_;
if (OB_FAIL(get_value().get_unknown(l_param_idx))) {
LOG_WARN("get param idx failed", K(ret));
} else if (OB_FAIL(r_expr.get_value().get_unknown(r_param_idx))) {
LOG_WARN("get param idx failed", K(ret));
} else if (l_param_idx == r_param_idx) {
bool_ret =
(get_result_type() == r_expr.get_result_type()
&& get_result_type().get_cast_mode() == r_expr.get_result_type().get_cast_mode());
}
}
} else if (left_dyn_const || right_dyn_const) {
// for simplicity's sake, if question is evaluated during runtime, just return false
// do nothing
} else if (check_context != NULL && check_context->override_const_compare_) {

View File

@ -2547,7 +2547,9 @@ int ObResolverUtils::resolve_const(const ParseNode *node,
int16_t len = 0;
ObString tmp_string(static_cast<int32_t>(node->str_len_), node->str_value_);
bool use_decimalint_as_result = false;
if (enable_decimal_int_type && !is_from_pl) {
int tmp_ret = OB_E(EventTable::EN_ENABLE_ORA_DECINT_CONST) OB_SUCCESS;
if (enable_decimal_int_type && !is_from_pl && OB_SUCC(tmp_ret)) {
// 如果开启decimal int类型,T_NUMBER解析成decimal int
int32_t val_len = 0;
ret = wide::from_string(node->str_value_, node->str_len_, allocator, scale, precision,