[CP]Fixbug:observer core at oceanbase::sql::ObRelationalExprOperator::deduce_cmp_type(3_2_x_release->master)

This commit is contained in:
obdev 2022-11-30 02:07:28 +00:00 committed by ob-robot
parent f09ac680ce
commit f320ab99da
2 changed files with 9 additions and 4 deletions

View File

@ -2125,13 +2125,16 @@ int ObRelationalExprOperator::deduce_cmp_type(const ObExprOperator &expr,
// to be compatiable with mysql:
// if c1 is date or datetime, convert 'c1 = c2+1'to cast (c1 as double) = cast (c2+1 as double)
const ObRawExpr* cmp_expr = type_ctx.get_raw_expr();
const ObRawExpr* date_expr = cmp_expr->get_param_expr(0);
const ObRawExpr* other_expr = cmp_expr->get_param_expr(1);
const ObRawExpr* date_expr = NULL;
const ObRawExpr* other_expr = NULL;
ObObjType other_expr_type = ObMaxType;
bool is_date_op_other = false;
if (OB_ISNULL(cmp_expr) || OB_ISNULL(date_expr) || OB_ISNULL(other_expr) ) {
if (OB_ISNULL(cmp_expr)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected null", K(ret), K(cmp_expr), K(date_expr), K(other_expr));
LOG_WARN("unexpected null", K(ret), K(cmp_expr));
} else if (OB_ISNULL(date_expr = cmp_expr->get_param_expr(0)) || OB_ISNULL(other_expr = cmp_expr->get_param_expr(1))) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected null", K(ret), K(date_expr), K(other_expr));
} else {
if (T_REF_QUERY == other_expr->get_expr_type()) {
const ObQueryRefRawExpr *ref_expr = static_cast<const ObQueryRefRawExpr*>(other_expr);

View File

@ -313,6 +313,8 @@ int ObOptEstUtils::if_expr_value_equal(ObOptimizerContext &opt_ctx,
ObExprResType result_type;
ObExprResType first_type = first_expr.get_result_type();
ObExprResType second_type = second_expr.get_result_type();
ObOpRawExpr equal_expr(const_cast<ObRawExpr *>(&first_expr), const_cast<ObRawExpr *>(&second_expr), T_OP_EQ);
type_ctx.set_raw_expr(&equal_expr);
if (OB_FAIL(ObSQLUtils::wrap_expr_ctx(stmt->get_stmt_type(), *exec_ctx, allocator, expr_ctx))) {
LOG_WARN("Failed to wrap expr ctx", K(ret));
} else if (OB_FAIL(equal_op.calc_result_type2(result_type, first_type, second_type, type_ctx))) {