From c4bf786100a08dafab9a3fa5eb33eb514297bb37 Mon Sep 17 00:00:00 2001 From: obdev Date: Thu, 6 Feb 2025 08:14:54 +0000 Subject: [PATCH] Fixed the issue of direct load initialization being skipped in merge into scene --- src/sql/engine/ob_exec_context.cpp | 5 +---- src/sql/ob_result_set.cpp | 21 +++++++++------------ 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/sql/engine/ob_exec_context.cpp b/src/sql/engine/ob_exec_context.cpp index cc4d721430..1fa191fdc0 100644 --- a/src/sql/engine/ob_exec_context.cpp +++ b/src/sql/engine/ob_exec_context.cpp @@ -784,10 +784,7 @@ int ObExecContext::init_physical_plan_ctx(const ObPhysicalPlan &plan) } else { consistency = STRONG; } - if (stmt::T_INSERT == plan.get_stmt_type()) { - bool is_direct_load = plan.get_enable_append(); - phy_plan_ctx_->set_is_direct_insert_plan(is_direct_load); - } + phy_plan_ctx_->set_is_direct_insert_plan(plan.get_enable_append()); phy_plan_ctx_->set_consistency_level(consistency); phy_plan_ctx_->set_timeout_timestamp(start_time + plan_timeout); phy_plan_ctx_->set_rich_format(my_session_->use_rich_format()); diff --git a/src/sql/ob_result_set.cpp b/src/sql/ob_result_set.cpp index b4d097ffd6..484681151f 100644 --- a/src/sql/ob_result_set.cpp +++ b/src/sql/ob_result_set.cpp @@ -183,7 +183,7 @@ int ObResultSet::open_result() } } else if (OB_FAIL(drive_dml_query())) { LOG_WARN("fail to drive dml query", K(ret)); - } else if (stmt::T_INSERT == get_stmt_type()) { + } else { ObPhysicalPlanCtx *plan_ctx = NULL; if (OB_ISNULL(plan_ctx = get_exec_context().get_physical_plan_ctx())) { ret = OB_ERR_UNEXPECTED; @@ -581,16 +581,13 @@ OB_INLINE int ObResultSet::do_open_plan(ObExecContext &ctx) ctx.get_physical_plan_ctx()->get_last_refresh_scns())))) { LOG_WARN("fail to set last_refresh_scns", K(ret), K(physical_plan_->get_mview_ids())); } else { - // for insert /*+ append */ into select clause - if (stmt::T_INSERT == get_stmt_type()) { - ObPhysicalPlanCtx *plan_ctx = NULL; - if (OB_ISNULL(plan_ctx = get_exec_context().get_physical_plan_ctx())) { - ret = OB_ERR_UNEXPECTED; - LOG_WARN("physical plan ctx is null"); - } else if (plan_ctx->get_is_direct_insert_plan()) { - if (OB_FAIL(ObTableDirectInsertService::start_direct_insert(ctx, *physical_plan_))) { - LOG_WARN("fail to start direct insert", KR(ret)); - } + ObPhysicalPlanCtx *plan_ctx = NULL; + if (OB_ISNULL(plan_ctx = get_exec_context().get_physical_plan_ctx())) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("physical plan ctx is null"); + } else if (plan_ctx->get_is_direct_insert_plan()) { + if (OB_FAIL(ObTableDirectInsertService::start_direct_insert(ctx, *physical_plan_))) { + LOG_WARN("fail to start direct insert", KR(ret)); } } /* 将exec_result_设置到executor的运行时环境中,用于返回数据 */ @@ -856,7 +853,7 @@ OB_INLINE int ObResultSet::do_close_plan(int errcode, ObExecContext &ctx) ObPxAdmission::exit_query_admission(my_session_, get_exec_context(), get_stmt_type(), *get_physical_plan()); // Finishing direct-insert must be executed after ObPxTargetMgr::release_target() - if (stmt::T_INSERT == get_stmt_type() && plan_ctx->get_is_direct_insert_plan()) { + if (plan_ctx->get_is_direct_insert_plan()) { // for insert /*+ append */ into select clause int tmp_ret = OB_SUCCESS; if (OB_TMP_FAIL(ObTableDirectInsertService::finish_direct_insert(