From ed608ae7217dc18c4fcf60c81c170b2d4e1683b5 Mon Sep 17 00:00:00 2001 From: zhubin79 <18784715772@163.com> Date: Fri, 15 Nov 2024 15:37:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0GUC=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E6=8E=A7=E5=88=B6B=E5=BA=93=E4=B8=8B=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E5=88=86=E5=8C=BA=E8=A1=A8=E9=BB=98=E8=AE=A4=E8=A1=A8=E7=8E=B0?= =?UTF-8?q?=E4=B8=BALOCAL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bin/gs_guc/cluster_guc.conf | 1 + src/common/backend/utils/misc/guc.cpp | 11 +++++++++++ src/gausskernel/optimizer/commands/indexcmds.cpp | 9 +++++++-- src/include/knl/knl_guc/knl_session_attr_sql.h | 1 + 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/bin/gs_guc/cluster_guc.conf b/src/bin/gs_guc/cluster_guc.conf index c09af69fe..39ac3ba83 100755 --- a/src/bin/gs_guc/cluster_guc.conf +++ b/src/bin/gs_guc/cluster_guc.conf @@ -839,6 +839,7 @@ uwal_truncate_interval|int|0,7200|NULL|NULL| uwal_async_append_switch|bool|0,0|NULL|NULL| enable_gazelle_performance_mode|bool|0,0|NULL|NULL| enable_aggr_coerce_type|bool|0,0|NULL|NULL| +enable_default_local_index|bool|0,0|NULL|NULL| [cmserver] log_dir|string|0,0|NULL|NULL| log_file_size|int|0,2047|MB|NULL| diff --git a/src/common/backend/utils/misc/guc.cpp b/src/common/backend/utils/misc/guc.cpp index 7e05d6b9b..2993f4fa8 100755 --- a/src/common/backend/utils/misc/guc.cpp +++ b/src/common/backend/utils/misc/guc.cpp @@ -2155,6 +2155,17 @@ static void InitConfigureNamesBool() NULL, NULL, NULL}, + {{"enable_default_local_index", + PGC_USERSET, + NODE_ALL, + ERROR_HANDLING_OPTIONS, + gettext_noop("Enable create index default behavior is local index"), + NULL}, + &u_sess->attr.attr_sql.enable_default_local_index, + false, + NULL, + NULL, + NULL}, #ifdef ENABLE_HTAP {{"enable_parallel_populate", PGC_USERSET, diff --git a/src/gausskernel/optimizer/commands/indexcmds.cpp b/src/gausskernel/optimizer/commands/indexcmds.cpp index 4211158a4..285d5bd35 100644 --- a/src/gausskernel/optimizer/commands/indexcmds.cpp +++ b/src/gausskernel/optimizer/commands/indexcmds.cpp @@ -536,8 +536,13 @@ void SetPartionIndexType(IndexStmt* stmt, Relation rel, bool is_alter_table) stmt->isGlobal = !CheckIdxParamsOwnPartKey(rel, stmt->indexParams); } } else if (!stmt->isPartitioned) { - /* default partition index is set to Global index */ - stmt->isGlobal = (!DEFAULT_CREATE_LOCAL_INDEX ? true : stmt->isGlobal); + /* + * default partition index is set to Global index. + * if B compatibility and enable_default_local_index is true, set Local index. + */ + if (!DEFAULT_CREATE_LOCAL_INDEX + && !(DB_IS_CMPT(B_FORMAT) && u_sess->attr.attr_sql.enable_default_local_index)) + stmt->isGlobal = true; } stmt->isPartitioned = true; #ifndef ENABLE_MULTIPLE_NODES diff --git a/src/include/knl/knl_guc/knl_session_attr_sql.h b/src/include/knl/knl_guc/knl_session_attr_sql.h index 22a81ff36..ee06242da 100644 --- a/src/include/knl/knl_guc/knl_session_attr_sql.h +++ b/src/include/knl/knl_guc/knl_session_attr_sql.h @@ -268,6 +268,7 @@ typedef struct knl_session_attr_sql { bool dolphin; bool whale; bool enable_vector_targetlist; + bool enable_default_local_index; #endif } knl_session_attr_sql;