fix an exec_param and a expr copy_on_replace bugs

This commit is contained in:
jingtaoye35
2024-02-09 12:25:58 +00:00
committed by ob-robot
parent 49c4063930
commit a291a8ffaf
7 changed files with 196 additions and 24 deletions

View File

@ -65,6 +65,7 @@ public:
const ObIArray<ObRawExpr *> &to_exprs);
int add_replace_exprs(const ObIArray<std::pair<ObRawExpr *, ObRawExpr *>> &to_replace_exprs);
int append_replace_exprs(const ObRawExprReplacer &other);
int check_need_replace(const ObRawExpr *old_expr, ObRawExpr *&new_expr, bool &need_replace);
private:
// types and constants
@ -76,9 +77,6 @@ private:
const bool overwrite,
bool &is_existed);
int check_skip_expr(const ObRawExpr &expr, bool &skip_expr);
int check_need_replace(const ObRawExpr *old_expr,
ObRawExpr *&new_expr,
bool &need_replace);
// disallow copy
DISALLOW_COPY_AND_ASSIGN(ObRawExprReplacer);
// function members

View File

@ -4576,29 +4576,52 @@ int ObRawExprUtils::get_exec_param_expr(ObRawExprFactory &expr_factory,
// we create a new one here
if (OB_SUCC(ret) && NULL == param_expr) {
ObExecParamRawExpr *exec_param = NULL;
if (OB_FAIL(expr_factory.create_raw_expr(T_QUESTIONMARK, exec_param))) {
LOG_WARN("failed to create raw expr", K(ret));
} else if (OB_ISNULL(exec_param)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("exec param is null", K(ret), K(exec_param));
if (OB_FAIL(ObRawExprUtils::create_new_exec_param(expr_factory,
outer_val_expr,
exec_param,
false))) {
LOG_WARN("failed to create new exec param", K(ret));
} else if (OB_FAIL(query_ref->add_exec_param_expr(exec_param))) {
LOG_WARN("failed to add exec param expr", K(ret));
} else if (OB_FAIL(exec_param->set_enum_set_values(outer_val_expr->get_enum_set_values()))) {
LOG_WARN("failed to set enum set values", K(ret));
} else if (OB_FAIL(exec_param->add_flag(IS_CONST))) {
LOG_WARN("failed to add flag", K(ret));
} else if (OB_FAIL(exec_param->add_flag(IS_DYNAMIC_PARAM))) {
LOG_WARN("failed to add flag", K(ret));
} else {
exec_param->set_ref_expr(outer_val_expr);
exec_param->set_param_index(-1);
exec_param->set_result_type(outer_val_expr->get_result_type());
param_expr = exec_param;
}
}
return ret;
}
int ObRawExprUtils::create_new_exec_param(ObRawExprFactory &expr_factory,
ObRawExpr *ref_expr,
ObExecParamRawExpr *&exec_param,
bool is_onetime /*=false*/)
{
int ret = OB_SUCCESS;
exec_param = NULL;
if (OB_ISNULL(ref_expr)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("expr is null", K(ret), K(ref_expr));
} else if (OB_FAIL(expr_factory.create_raw_expr(T_QUESTIONMARK, exec_param))) {
LOG_WARN("failed to create exec param expr", K(ret));
} else if (OB_ISNULL(exec_param)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("exec param is null", K(ret), K(exec_param));
} else if (OB_FAIL(exec_param->set_enum_set_values(ref_expr->get_enum_set_values()))) {
LOG_WARN("failed to set enum set values", K(ret));
} else if (OB_FAIL(exec_param->add_flag(IS_CONST))) {
LOG_WARN("failed to add flag", K(ret));
} else if (OB_FAIL(exec_param->add_flag(IS_DYNAMIC_PARAM))) {
LOG_WARN("failed to add flag", K(ret));
} else {
exec_param->set_ref_expr(ref_expr, is_onetime);
exec_param->set_param_index(-1);
exec_param->set_result_type(ref_expr->get_result_type());
if (is_onetime) {
exec_param->add_flag(IS_ONETIME);
}
}
return ret;
}
int ObRawExprUtils::create_new_exec_param(ObQueryCtx *query_ctx,
ObRawExprFactory &expr_factory,
ObRawExpr *&expr,

View File

@ -557,11 +557,10 @@ public:
ObRawExprFactory &expr_factory,
ObRawExpr *&expr,
bool is_onetime = false);
static int create_exec_param_expr(ObQueryCtx *query_ctx,
ObRawExprFactory &expr_factory,
ObRawExpr *&src_expr,
std::pair<int64_t, ObRawExpr*> &init_expr);
static int create_new_exec_param(ObRawExprFactory &expr_factory,
ObRawExpr *ref_expr,
ObExecParamRawExpr *&exec_param,
bool is_onetime = false);
static int create_param_expr(ObRawExprFactory &expr_factory, int64_t param_idx, ObRawExpr *&expr);
static int build_trim_expr(const share::schema::ObColumnSchemaV2 *column_schema,
ObRawExprFactory &expr_factory,