From 42115c7db1bc104ffec0911d95f5e04e7e0313ca Mon Sep 17 00:00:00 2001 From: obdev Date: Mon, 29 Apr 2024 04:16:31 +0000 Subject: [PATCH] [CP] FIX: fix the core induced by foreign key handle overwrite the datum pointer of expr in DML op --- src/observer/ob_inner_sql_connection.h | 4 ---- src/sql/engine/dml/ob_dml_service.cpp | 15 ++++++++++++--- src/sql/engine/dml/ob_table_modify_op.cpp | 1 + src/sql/engine/dml/ob_table_modify_op.h | 6 ++---- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/observer/ob_inner_sql_connection.h b/src/observer/ob_inner_sql_connection.h index a5317b6d25..cb4bf1be96 100644 --- a/src/observer/ob_inner_sql_connection.h +++ b/src/observer/ob_inner_sql_connection.h @@ -263,10 +263,6 @@ public: SavedValue &saved_conn, bool skip_cur_stmt_tables); int end_nested_session(sql::ObSQLSessionInfo::StmtSavedValue &saved_session, SavedValue &saved_conn); - int set_foreign_key_cascade(bool is_cascade); - int get_foreign_key_cascade(bool &is_cascade) const; - int set_foreign_key_check_exist(bool is_check_exist); - int get_foreign_key_check_exist(bool &is_check_exist) const; bool is_extern_session() const { return NULL != extern_session_; } bool is_inner_session() const { return NULL == extern_session_; } bool is_spi_conn() const { return is_spi_conn_; } diff --git a/src/sql/engine/dml/ob_dml_service.cpp b/src/sql/engine/dml/ob_dml_service.cpp index e9280b4ded..821f221d03 100644 --- a/src/sql/engine/dml/ob_dml_service.cpp +++ b/src/sql/engine/dml/ob_dml_service.cpp @@ -2198,9 +2198,14 @@ int ObDMLService::handle_after_processing_multi_row(ObDMLModifyRowsList *dml_mod const ObDmlEventType t_insert = ObDmlEventType::DE_INSERTING; const ObDmlEventType t_update = ObDmlEventType::DE_UPDATING; const ObDmlEventType t_delete = ObDmlEventType::DE_DELETING; - if (OB_ISNULL(dml_modify_rows) || OB_ISNULL(dml_op)) { + if (OB_ISNULL(dml_modify_rows) || OB_ISNULL(dml_op) || OB_ISNULL(dml_op->get_child())) { ret = OB_ERR_UNEXPECTED; LOG_WARN("dml operator or modify rows list is null", K(dml_modify_rows), K(dml_op)); + } else if (OB_ISNULL(dml_op->last_store_row_.get_store_row()) && + OB_FAIL(dml_op->last_store_row_.init(dml_op->get_exec_ctx().get_allocator(), dml_op->get_child()->get_spec().output_.count()))) { + LOG_WARN("failed to init shadow stored row", K(ret)); + } else if (OB_FAIL(dml_op->last_store_row_.shadow_copy(dml_op->get_child()->get_spec().output_, dml_op->get_eval_ctx()))) { + LOG_WARN("failed to backup the datum ptr of child operator", K(ret)); } else { ObDMLModifyRowsList::iterator row_iter = dml_modify_rows->begin(); for (; OB_SUCC(ret) && row_iter != dml_modify_rows->end(); row_iter++) { @@ -2260,8 +2265,12 @@ int ObDMLService::handle_after_processing_multi_row(ObDMLModifyRowsList *dml_mod } // check the result of batch foreign key check results - if (OB_SUCC(ret) && dml_op->get_spec().check_fk_batch_ && OB_FAIL(dml_op->perform_batch_fk_check())) { - LOG_WARN("failed to perform batch foreign key check", K(ret)); + if (OB_SUCC(ret)) { + if (dml_op->get_spec().check_fk_batch_ && OB_FAIL(dml_op->perform_batch_fk_check())) { + LOG_WARN("failed to perform batch foreign key check", K(ret)); + } else if (OB_FAIL(dml_op->last_store_row_.restore(dml_op->get_child()->get_spec().output_, dml_op->get_eval_ctx()))) { + LOG_WARN("failed to restore the datum ptr", K(ret)); + } } } return ret; diff --git a/src/sql/engine/dml/ob_table_modify_op.cpp b/src/sql/engine/dml/ob_table_modify_op.cpp index a7aedc466d..13e7b7fb6b 100644 --- a/src/sql/engine/dml/ob_table_modify_op.cpp +++ b/src/sql/engine/dml/ob_table_modify_op.cpp @@ -675,6 +675,7 @@ ObTableModifyOp::ObTableModifyOp(ObExecContext &ctx, execute_single_row_(false), err_log_rt_def_(), dml_modify_rows_(ctx.get_allocator()), + last_store_row_(), saved_session_(NULL) { obj_print_params_ = CREATE_OBJ_PRINT_PARAM(ctx_.get_my_session()); diff --git a/src/sql/engine/dml/ob_table_modify_op.h b/src/sql/engine/dml/ob_table_modify_op.h index b84c3cc3a4..9ba725d6a9 100644 --- a/src/sql/engine/dml/ob_table_modify_op.h +++ b/src/sql/engine/dml/ob_table_modify_op.h @@ -206,6 +206,7 @@ public: dml_rtctx_.cleanup(); trigger_clear_exprs_.reset(); fk_checkers_.reset(); + last_store_row_.reset(); ObOperator::destroy(); } @@ -214,10 +215,6 @@ public: int close_inner_conn(); int begin_nested_session(bool skip_cur_stmt_tables); int end_nested_session(); - int set_foreign_key_cascade(bool is_cascade); - int get_foreign_key_cascade(bool &is_cascade) const; - int set_foreign_key_check_exist(bool is_check_exist); - int get_foreign_key_check_exist(bool &is_check_exist) const; int execute_write(const char *sql); int execute_read(const char *sql, common::ObMySQLProxy::MySQLResult &res); int check_stack(); @@ -292,6 +289,7 @@ public: ObSEArray trigger_clear_exprs_; ObDMLModifyRowsList dml_modify_rows_; ObSEArray fk_checkers_; + ObChunkDatumStore::ShadowStoredRow last_store_row_; private: ObSQLSessionInfo::StmtSavedValue *saved_session_; char saved_session_buf_[sizeof(ObSQLSessionInfo::StmtSavedValue)] __attribute__((aligned (16)));; -- GitLab