From 20c83158e00638695def4deb9a48730449a19c69 Mon Sep 17 00:00:00 2001 From: obdev Date: Tue, 6 Feb 2024 22:42:13 +0000 Subject: [PATCH] [CP] skip modify view status for unnecessary alter table stmt --- src/rootserver/ob_ddl_service.cpp | 17 ++++++++++++++--- src/rootserver/ob_ddl_service.h | 2 ++ src/share/schema/ob_dependency_info.cpp | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/rootserver/ob_ddl_service.cpp b/src/rootserver/ob_ddl_service.cpp index 49f06427d5..bd138bf2dd 100755 --- a/src/rootserver/ob_ddl_service.cpp +++ b/src/rootserver/ob_ddl_service.cpp @@ -10865,8 +10865,10 @@ int ObDDLService::alter_table_in_trans(obrpc::ObAlterTableArg &alter_table_arg, } else if (OB_FAIL(trans.start(sql_proxy_, tenant_id, refreshed_schema_version))) { LOG_WARN("start transaction failed", KR(ret), K(tenant_id), K(refreshed_schema_version)); // All alter table behaviors will cause the status to change, which is not as fine as oracle - } else if (OB_FAIL(ObDependencyInfo::modify_dep_obj_status(trans, tenant_id, orig_table_schema->get_table_id(), - ddl_operator, *schema_service_))) { + } else if (need_modify_dep_obj_status(alter_table_arg) + && OB_FAIL(ObDependencyInfo::modify_dep_obj_status(trans, tenant_id, + orig_table_schema->get_table_id(), + ddl_operator, *schema_service_))) { LOG_WARN("failed to modify obj status", K(ret)); } else { ObArray global_idx_schema_array; @@ -11774,7 +11776,8 @@ int ObDDLService::do_offline_ddl_in_trans(obrpc::ObAlterTableArg &alter_table_ar } // TODO yiren, refactor it, create user hidden table after alter index/column/part/cst... if (OB_FAIL(ret)) { - } else if (OB_FAIL(ObDependencyInfo::modify_dep_obj_status(trans, tenant_id, orig_table_schema->get_table_id(), + } else if (need_modify_dep_obj_status(alter_table_arg) + && OB_FAIL(ObDependencyInfo::modify_dep_obj_status(trans, tenant_id, orig_table_schema->get_table_id(), ddl_operator, *schema_service_))) { LOG_WARN("failed to modify obj status", K(ret)); } else if (OB_FAIL(check_ddl_with_primary_key_operation(alter_table_arg, @@ -36085,5 +36088,13 @@ int ObDDLService::check_same_subpartition_(const bool is_oracle_mode, const ObSu return ret; } +bool ObDDLService::need_modify_dep_obj_status(const obrpc::ObAlterTableArg &alter_table_arg) const +{ + const AlterTableSchema &alter_table_schema = alter_table_arg.alter_table_schema_; + return (alter_table_arg.is_alter_columns_ + || (alter_table_arg.is_alter_options_ + && alter_table_schema.alter_option_bitset_.has_member(ObAlterTableArg::TABLE_NAME))); +} + } // end namespace rootserver } // end namespace oceanbase diff --git a/src/rootserver/ob_ddl_service.h b/src/rootserver/ob_ddl_service.h index 26c188b21b..7374f345ac 100644 --- a/src/rootserver/ob_ddl_service.h +++ b/src/rootserver/ob_ddl_service.h @@ -2595,6 +2595,8 @@ private: return !(orig_key == (new_key)); } + bool need_modify_dep_obj_status(const obrpc::ObAlterTableArg &alter_table_arg) const; + private: bool inited_; volatile bool stopped_; diff --git a/src/share/schema/ob_dependency_info.cpp b/src/share/schema/ob_dependency_info.cpp index 40ae56e535..6502da8e69 100644 --- a/src/share/schema/ob_dependency_info.cpp +++ b/src/share/schema/ob_dependency_info.cpp @@ -541,6 +541,7 @@ int ObDependencyInfo::modify_all_obj_status(const ObIArray