fix some bug

This commit is contained in:
zzg19950727
2023-06-02 05:42:03 +00:00
committed by ob-robot
parent 6caa107dd9
commit 157ecc38a3
5 changed files with 24 additions and 3 deletions

View File

@ -122,6 +122,7 @@ int ObSqlPlan::store_sql_plan_for_explain(ObExecContext *ctx,
PlanText out_plan_text;
plan_text.type_ = type;
ObSEArray<ObSqlPlanItem*, 16> sql_plan_infos;
bool allocate_mem_failed = false;
if (OB_FAIL(init_buffer(plan_text))) {
LOG_WARN("failed to init buffer", K(ret));
} else if (OB_FAIL(get_sql_plan_infos(plan_text,
@ -129,12 +130,14 @@ int ObSqlPlan::store_sql_plan_for_explain(ObExecContext *ctx,
sql_plan_infos))) {
LOG_WARN("failed to get sql plan infos", K(ret));
}
allocate_mem_failed |= OB_ALLOCATE_MEMORY_FAILED == ret;
if (OB_FAIL(format_sql_plan(sql_plan_infos,
type,
option,
out_plan_text))) {
LOG_WARN("failed to format sql plan", K(ret));
}
allocate_mem_failed |= OB_ALLOCATE_MEMORY_FAILED == ret;
if (OB_FAIL(plan_text_to_strings(out_plan_text, plan_strs))) {
LOG_WARN("failed to convert plan text to strings", K(ret));
} else if (OB_FAIL(inner_store_sql_plan_for_explain(ctx,
@ -147,6 +150,16 @@ int ObSqlPlan::store_sql_plan_for_explain(ObExecContext *ctx,
ret = OB_SUCCESS;
}
}
if (OB_SUCC(ret)) {
if (allocate_mem_failed) {
if (OB_FAIL(plan_strs.push_back("Plan truncated due to insufficient memory!"))) {
LOG_WARN("failed to push back string", K(ret));
}
} else if (plan_strs.empty()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("failed to generate plan", K(ret));
}
}
destroy_buffer(plan_text);
return ret;
}