提交 39c3a048 编写于 作者: L LINxiansheng 提交者: wangzelin.wzl

[CP] fixed not hit plan cache due to equal constraint

上级 b4bfa011
......@@ -376,12 +376,30 @@ struct ObPCConstParamInfo {
common::ObSEArray<int64_t, 4> const_idx_;
common::ObSEArray<common::ObObj, 4> const_params_;
TO_STRING_KV(K_(const_idx), K_(const_params));
bool operator==(const ObPCConstParamInfo &other) const
{
bool cmp_ret = true;
for (int i=0; cmp_ret && i < const_idx_.count(); i++) {
cmp_ret = const_idx_.at(i) == other.const_idx_.at(i);
}
for (int i=0; cmp_ret && i < const_params_.count(); i++) {
cmp_ret = const_params_.at(i) == other.const_params_.at(i);
}
return cmp_ret;
}
};
struct ObPCParamEqualInfo {
int64_t first_param_idx_;
int64_t second_param_idx_;
TO_STRING_KV(K_(first_param_idx), K_(second_param_idx));
inline bool operator==(const ObPCParamEqualInfo &other) const
{
bool cmp_ret = first_param_idx_ == other.first_param_idx_ &&
second_param_idx_ == other.second_param_idx_;
return cmp_ret;
}
};
struct ObFastParserResult {
......
......@@ -386,6 +386,7 @@ int ObPlanSet::match_params_info(
if (OB_SUCC(ret)) {
const ParamStore& params = pc_ctx.exec_ctx_.get_physical_plan_ctx()->get_param_store();
OC((match_constraint)(params, is_same));
OC( (match_cons)(pc_ctx, is_same));
}
}
}
......@@ -624,6 +625,41 @@ int ObPlanSet::set_equal_param_constraint(common::ObIArray<ObPCParamEqualInfo>&
return ret;
}
// match actually constraint
int ObPlanSet::match_cons(const ObPlanCacheCtx &pc_ctx, bool &is_matched)
{
int ret = OB_SUCCESS;
ObIArray<ObPCConstParamInfo> *param_cons = pc_ctx.sql_ctx_.all_plan_const_param_constraints_;
ObIArray<ObPCConstParamInfo> *possible_param_cons =
pc_ctx.sql_ctx_.all_possible_const_param_constraints_;
ObIArray<ObPCParamEqualInfo> *equal_cons = pc_ctx.sql_ctx_.all_equal_param_constraints_;
is_matched = true;
if (OB_ISNULL(param_cons) ||
OB_ISNULL(possible_param_cons) ||
OB_ISNULL(equal_cons)) {
is_matched = false;
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid arugment", K(param_cons), K(possible_param_cons), K(equal_cons));
} else if (param_cons->count() != all_plan_const_param_constraints_.count() ||
possible_param_cons->count() != all_possible_const_param_constraints_.count() ||
equal_cons->count() != all_equal_param_constraints_.count()) {
is_matched = false;
} else {
for (int64_t i=0; is_matched && i < all_plan_const_param_constraints_.count(); i++) {
is_matched = (all_plan_const_param_constraints_.at(i)==param_cons->at(i));
}
for (int64_t i=0; is_matched && i < all_possible_const_param_constraints_.count(); i++) {
is_matched = (all_possible_const_param_constraints_.at(i)==possible_param_cons->at(i));
}
for (int64_t i=0; is_matched && i < all_equal_param_constraints_.count(); i++) {
is_matched = (all_equal_param_constraints_.at(i)==equal_cons->at(i));
}
}
return ret;
}
int ObPlanSet::match_constraint(const ParamStore& params, bool& is_matched)
{
int ret = OB_SUCCESS;
......
......@@ -174,7 +174,8 @@ private:
common::ObIArray<ObPCConstParamInfo>& const_param_constraint, const bool is_all_constraint);
int set_equal_param_constraint(common::ObIArray<ObPCParamEqualInfo>& equal_param_constraint);
int match_cons(const ObPlanCacheCtx &pc_ctx, bool &is_matched);
/**
* @brief Match const param constraint.
* If all_plan_const_param_constraints_ is not empty, check wether the constraints is mached and return the result.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册