From c5deec223668f0a4d0eb70bedc3f4d029c12d83e Mon Sep 17 00:00:00 2001 From: SevenJ-swj Date: Fri, 21 Jul 2023 03:12:47 +0000 Subject: [PATCH] [CP] fix tmp table core --- src/rootserver/ob_ddl_service.cpp | 8 +++++--- src/share/ob_rpc_struct.cpp | 25 +++++++++++++++++++++++++ src/share/ob_rpc_struct.h | 3 +++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/rootserver/ob_ddl_service.cpp b/src/rootserver/ob_ddl_service.cpp index e1b4efd22..e441d6580 100755 --- a/src/rootserver/ob_ddl_service.cpp +++ b/src/rootserver/ob_ddl_service.cpp @@ -19774,7 +19774,6 @@ int ObDDLService::collect_temporary_tables_in_session(const ObDropTableArg &cons } else if (need_collect) { found = true; // session_id should not across tenant database_schema = NULL; - table_item.table_name_ = table_schema->get_table_name_str(); table_item.mode_ = table_schema->get_name_case_mode(); if (OB_FAIL(schema_guard.get_database_schema(*tenant_id, table_schema->get_database_id(), database_schema))) { LOG_WARN("failed to get database schema", K(ret), "tenant_id", tenant_id); @@ -19783,8 +19782,11 @@ int ObDDLService::collect_temporary_tables_in_session(const ObDropTableArg &cons LOG_WARN("database schema is null", K(ret)); } else if (database_schema->is_in_recyclebin() || table_schema->is_in_recyclebin()) { LOG_INFO("skip table schema in recyclebin", K(*table_schema)); - } else if (FALSE_IT(table_item.database_name_ = database_schema->get_database_name_str())) { - //impossible + } else if (OB_FAIL(ob_write_string(drop_table_arg.allocator_, database_schema->get_database_name_str(), + table_item.database_name_)) + || OB_FAIL(ob_write_string(drop_table_arg.allocator_, table_schema->get_table_name_str(), + table_item.table_name_))) { + LOG_WARN("Can not malloc space for table/db name", K(ret)); } else if (OB_FAIL(drop_table_arg.tables_.push_back(table_item))) { LOG_WARN("failed to add table item!", K(table_item), K(ret)); } else { diff --git a/src/share/ob_rpc_struct.cpp b/src/share/ob_rpc_struct.cpp index 360619487..da6f215a0 100755 --- a/src/share/ob_rpc_struct.cpp +++ b/src/share/ob_rpc_struct.cpp @@ -2336,6 +2336,31 @@ bool ObDropTableArg::is_valid() const return ret; } +int ObDropTableArg::assign(const ObDropTableArg &other) +{ + int ret = OB_SUCCESS; + if (this == &other) { + //do nothing + } else if (OB_FAIL(ObDDLArg::assign(other))) { + LOG_WARN("assign failed", K(ret)); + } else { + tenant_id_ = other.tenant_id_; + session_id_ = other.session_id_; + sess_create_time_ = other.sess_create_time_; + table_type_ = other.table_type_; + if_exist_ = other.if_exist_; + to_recyclebin_ = other.to_recyclebin_; + for (int64_t i = 0; OB_SUCC(ret) && i < other.tables_.count(); i++) { + ObTableItem table_item; + table_item.mode_ = other.tables_.at(i).mode_; + OZ (ob_write_string(allocator_, other.tables_.at(i).table_name_, table_item.table_name_)); + OZ (ob_write_string(allocator_, other.tables_.at(i).database_name_, table_item.database_name_)); + OZ (tables_.push_back(table_item)); + } + } + return ret; +} + DEF_TO_STRING(ObDropTableArg) { int64_t pos = 0; diff --git a/src/share/ob_rpc_struct.h b/src/share/ob_rpc_struct.h index 233f7566c..e03c157e1 100755 --- a/src/share/ob_rpc_struct.h +++ b/src/share/ob_rpc_struct.h @@ -2119,6 +2119,8 @@ public: ObDropTableArg(const ObDropTableArg &other) = delete; virtual ~ObDropTableArg() { tables_.reset(); } virtual bool is_allow_when_upgrade() const { return true; } + + int assign(const ObDropTableArg& other); DECLARE_TO_STRING; uint64_t tenant_id_; @@ -2132,6 +2134,7 @@ public: bool is_add_to_scheduler_; bool force_drop_; lib::Worker::CompatMode compat_mode_; + common::ObArenaAllocator allocator_; }; struct ObOptimizeTableArg : public ObDDLArg