diff --git a/src/logical_plan/logical_planner.cpp b/src/logical_plan/logical_planner.cpp index fab9bf76..ed776853 100644 --- a/src/logical_plan/logical_planner.cpp +++ b/src/logical_plan/logical_planner.cpp @@ -2927,7 +2927,7 @@ int LogicalPlanner::create_scan_nodes() { } void LogicalPlanner::set_dml_txn_state(int64_t table_id) { - if (_ctx->is_explain || table_id == -1) { + if (_ctx->is_explain) { return; } auto client = _ctx->client_conn; diff --git a/src/logical_plan/prepare_planner.cpp b/src/logical_plan/prepare_planner.cpp index 76e01b52..1141c013 100644 --- a/src/logical_plan/prepare_planner.cpp +++ b/src/logical_plan/prepare_planner.cpp @@ -173,6 +173,7 @@ int PreparePlanner::stmt_prepare(const std::string& stmt_name, const std::string prepare_ctx->client_conn = client; prepare_ctx->get_runtime_state()->set_client_conn(client); prepare_ctx->sql = stmt_sql; + prepare_ctx->is_full_export = false; std::unique_ptr planner; switch (prepare_ctx->stmt_type) { @@ -248,7 +249,7 @@ int PreparePlanner::stmt_execute(const std::string& stmt_name, std::vectorstat_info.table = prepare_ctx->stat_info.table; _ctx->stat_info.sample_sql << prepare_ctx->stat_info.sample_sql.str(); _ctx->stat_info.sign = prepare_ctx->stat_info.sign; - _ctx->is_full_export = prepare_ctx->is_full_export; + _ctx->is_full_export = false; _ctx->debug_region_id = prepare_ctx->debug_region_id; _ctx->execute_global_flow = prepare_ctx->execute_global_flow; if (params.size() != prepare_ctx->placeholders.size()) { @@ -268,7 +269,9 @@ int PreparePlanner::stmt_execute(const std::string& stmt_name, std::vectoris_select || prepare_ctx->sub_query_plans.size() > 0 || (prepare_ctx->root != nullptr && prepare_ctx->root->has_optimized())) { // enable_2pc=true or table has global index need generate txn_id - set_dml_txn_state(prepare_ctx->prepared_table_id); + if (!prepare_ctx->is_select && prepare_ctx->prepared_table_id != -1) { + set_dml_txn_state(prepare_ctx->prepared_table_id); + } _ctx->plan.CopyFrom(prepare_ctx->plan); int ret = set_dml_local_index_binlog(prepare_ctx->prepared_table_id); if (ret < 0) { diff --git a/src/logical_plan/select_planner.cpp b/src/logical_plan/select_planner.cpp index ddbec8f7..ce192437 100644 --- a/src/logical_plan/select_planner.cpp +++ b/src/logical_plan/select_planner.cpp @@ -154,6 +154,9 @@ bool SelectPlanner::is_full_export() { if (_ctx->explain_type != EXPLAIN_NULL) { return false; } + if (_ctx->is_prepared) { + return false; + } if (_ctx->debug_region_id != -1) { return false; }