Add query hint: enable_rich_vector_format

This commit is contained in:
Zach41
2024-01-18 14:12:30 +00:00
committed by ob-robot
parent 5753203c06
commit 718c71384c
9 changed files with 116 additions and 6 deletions

View File

@ -179,7 +179,8 @@ ObPlanCacheValue::ObPlanCacheValue()
is_batch_execute_(false),
has_dynamic_values_table_(false),
stored_schema_objs_(pc_alloc_),
stmt_type_(stmt::T_MAX)
stmt_type_(stmt::T_MAX),
enable_rich_vector_format_(false)
{
MEMSET(sql_id_, 0, sizeof(sql_id_));
not_param_index_.set_attr(ObMemAttr(MTL_ID(), "NotParamIdex"));
@ -262,6 +263,7 @@ int ObPlanCacheValue::init(ObPCVSet *pcv_set, const ObILibCacheObject *cache_obj
sys_schema_version_ = plan->get_sys_schema_version();
tenant_schema_version_ = plan->get_tenant_schema_version();
sql_traits_ = pc_ctx.sql_traits_;
enable_rich_vector_format_ = static_cast<const ObPhysicalPlan *>(plan)->get_use_rich_format();
#ifdef OB_BUILD_SPM
is_spm_closed_ = pcv_set->get_spm_closed();
#endif
@ -476,6 +478,8 @@ int ObPlanCacheValue::choose_plan(ObPlanCacheCtx &pc_ctx,
if (schema_array.count() == 0 && stored_schema_objs_.count() == 0) {
need_check_schema = true;
}
ObBasicSessionInfo::ForceRichFormatStatus orig_rich_format_status = ObBasicSessionInfo::ForceRichFormatStatus::Disable;
bool orig_phy_ctx_rich_format = false;
if (stmt::T_NONE == pc_ctx.sql_ctx_.stmt_type_) {
//sql_ctx_.stmt_type_ != stmt::T_NONE means this calling in nested sql,
//can't cover the first stmt type in sql context
@ -484,6 +488,7 @@ int ObPlanCacheValue::choose_plan(ObPlanCacheCtx &pc_ctx,
if (OB_ISNULL(session = pc_ctx.exec_ctx_.get_my_session())) {
ret = OB_ERR_UNEXPECTED;
SQL_PC_LOG(ERROR, "got session is NULL", K(ret));
} else if (FALSE_IT(orig_rich_format_status = session->get_force_rich_format_status())) {
} else if (FALSE_IT(session->set_stmt_type(stmt_type_))) {
} else if (OB_FAIL(session->get_use_plan_baseline(enable_baseline))) {
LOG_WARN("fail to get use plan baseline", K(ret));
@ -552,7 +557,12 @@ int ObPlanCacheValue::choose_plan(ObPlanCacheCtx &pc_ctx,
if (OB_SUCC(ret)) {
ObPhysicalPlanCtx *phy_ctx = pc_ctx.exec_ctx_.get_physical_plan_ctx();
if (NULL != phy_ctx) {
orig_phy_ctx_rich_format = phy_ctx->is_rich_format();
phy_ctx->set_original_param_cnt(phy_ctx->get_param_store().count());
phy_ctx->set_rich_format(enable_rich_vector_format_);
session->set_force_rich_format(enable_rich_vector_format_ ?
ObBasicSessionInfo::ForceRichFormatStatus::FORCE_ON :
ObBasicSessionInfo::ForceRichFormatStatus::FORCE_OFF);
if (OB_FAIL(phy_ctx->init_datum_param_store())) {
LOG_WARN("fail to init datum param store", K(ret));
}
@ -673,6 +683,15 @@ int ObPlanCacheValue::choose_plan(ObPlanCacheCtx &pc_ctx,
plan_out = plan;
pc_ctx.sql_traits_ = sql_traits_; //used for check read only
}
// reset force rich format status
if (NULL == plan) {
if (session != nullptr) {
session->set_force_rich_format(orig_rich_format_status);
}
if (pc_ctx.exec_ctx_.get_physical_plan_ctx() != nullptr) {
pc_ctx.exec_ctx_.get_physical_plan_ctx()->set_rich_format(orig_phy_ctx_rich_format);
}
}
return ret;
}
@ -1418,6 +1437,7 @@ void ObPlanCacheValue::reset()
}
}
stored_schema_objs_.reset();
enable_rich_vector_format_ = false;
pcv_set_ = NULL; //放最后,前面可能存在需要pcv_set
}