fix core caused by missing const flag

This commit is contained in:
yinyj17
2024-02-20 09:46:17 +00:00
committed by ob-robot
parent 661031247f
commit 86b8b822b9
8 changed files with 155 additions and 27 deletions

View File

@ -263,3 +263,59 @@ int ObStmtExecParamFormatter::do_formalize_exec_param(ObRawExpr *&expr, bool &is
}
return ret;
}
int ObStmtExprChecker::do_visit(ObRawExpr *&expr)
{
int ret = OB_SUCCESS;
if (OB_FAIL(check_expr(expr))) {
LOG_WARN("failed to check expr", K(ret), KPC(expr));
}
return ret;
}
int ObStmtExprChecker::check_expr(const ObRawExpr *expr) const
{
int ret = OB_SUCCESS;
if (OB_ISNULL(expr)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("expr is null", K(ret));
} else if (OB_FAIL(check_const_flag(expr))) {
LOG_WARN("failed to check const flag", K(ret));
}
for (int64_t i = 0; OB_SUCC(ret) && i < expr->get_param_count(); ++i) {
if (OB_FAIL(SMART_CALL(check_expr(expr->get_param_expr(i))))) {
LOG_WARN("failed to check param expr", K(ret));
}
}
return ret;
}
int ObStmtExprChecker::check_const_flag(const ObRawExpr *expr) const
{
int ret = OB_SUCCESS;
bool expect_is_const = true;
if (OB_ISNULL(expr)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("expr is null", K(ret), K(expr));
}
for (int64_t i = 0; OB_SUCC(ret) && expect_is_const && i < expr->get_param_count(); ++i) {
const ObRawExpr *param_expr = expr->get_param_expr(i);
if (OB_ISNULL(param_expr)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("param expr is null", K(ret), K(param_expr));
} else {
expect_is_const = param_expr->is_const_expr();
}
}
if (OB_SUCC(ret) && expect_is_const) {
if (OB_FAIL(expr->is_const_inherit_expr(expect_is_const))) {
LOG_WARN("failed to check expr is const inherit", K(ret));
}
}
if (OB_FAIL(ret)) {
} else if (OB_UNLIKELY(expr->is_const_expr() != expect_is_const)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("expr const flag is not match", K(ret), K(expect_is_const), KPC(expr));
}
return ret;
}

View File

@ -236,6 +236,15 @@ public:
};
class ObStmtExprChecker : public ObStmtExprVisitor
{
public:
ObStmtExprChecker() {}
virtual int do_visit(ObRawExpr *&expr) override;
int check_expr(const ObRawExpr *expr) const;
int check_const_flag(const ObRawExpr *expr) const;
};
}
}

View File

@ -789,6 +789,17 @@ int ObRawExpr::is_const_inherit_expr(bool &is_const_inherit,
|| T_FUN_NORMAL_UDF == type_
|| T_FUN_SYS_REMOVE_CONST == type_
|| T_FUN_SYS_WRAPPER_INNER == type_
|| T_FUN_SYS_VALUES == type_
|| T_OP_GET_PACKAGE_VAR == type_
|| T_OP_GET_SUBPROGRAM_VAR == type_
|| T_FUN_SYS_JSON_VALUE == type_
|| T_FUN_SYS_JSON_QUERY == type_
|| (T_FUN_SYS_JSON_EXISTS == type_ && lib::is_oracle_mode())
|| T_FUN_SYS_JSON_EQUAL == type_
|| T_FUN_SYS_IS_JSON == type_
|| (T_FUN_SYS_JSON_MERGE_PATCH == type_ && lib::is_oracle_mode())
|| T_FUN_SYS_JSON_OBJECT == type_
|| IS_LABEL_SE_POLICY_FUNC(type_)
|| (T_FUN_SYS_LAST_INSERT_ID == type_ && get_param_count() > 0)
|| T_FUN_SYS_TO_BLOB == type_
|| (T_FUN_SYS_SYSDATE == type_ && lib::is_mysql_mode())

View File

@ -567,32 +567,6 @@ int ObRawExprInfoExtractor::visit(ObSysFunRawExpr &expr)
}
} else {}
}
if (OB_SUCC(ret)
&& (T_FUN_SYS_JSON_VALUE == expr.get_expr_type()
|| T_FUN_SYS_JSON_QUERY == expr.get_expr_type()
|| (T_FUN_SYS_JSON_EXISTS == expr.get_expr_type() && lib::is_oracle_mode())
|| T_FUN_SYS_JSON_EQUAL == expr.get_expr_type()
|| T_FUN_SYS_IS_JSON == expr.get_expr_type()
|| (T_FUN_SYS_JSON_MERGE_PATCH == expr.get_expr_type() && lib::is_oracle_mode())
|| T_FUN_SYS_JSON_OBJECT == expr.get_expr_type()
|| IS_LABEL_SE_POLICY_FUNC(expr.get_expr_type()))
&& OB_FAIL(expr.clear_flag(IS_CONST_EXPR))) {
LOG_WARN("failed to clear flag", K(ret));
}
if (OB_SUCC(ret) && T_FUN_SYS_JSON_VALUE == expr.get_expr_type()) {
if (expr.get_param_count() >= 12) {
ObRawExpr * sub_expr = expr.get_param_expr(7);
if (OB_NOT_NULL(sub_expr)
&& OB_FAIL(sub_expr->clear_flag(IS_CONST_EXPR))) {
LOG_WARN("failed to clear flag", K(ret));
} else if (OB_NOT_NULL(sub_expr = expr.get_param_expr(4))
&& OB_FAIL(sub_expr->clear_flag(IS_CONST_EXPR))) {
LOG_WARN("failed to clear flag", K(ret));
}
}
}
}
return ret;
}