From b44dd8ad833bdf8dd47a570eeaf089dac08c4869 Mon Sep 17 00:00:00 2001 From: zhang_xubo <2578876417@qq.com> Date: Mon, 14 Aug 2023 21:52:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8D=87=E7=BA=A7=E4=B8=AD?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=20select=20nextval=E5=AF=BC=E8=87=B4core?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/utils/cache/knl_localpartdefcache.cpp | 3 +++ .../backend/utils/cache/knl_localsystupcache.cpp | 9 ++++++--- .../backend/utils/cache/knl_localtabdefcache.cpp | 3 +++ .../optimizer/commands/sequence/sequence.cpp | 10 +++++++++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/common/backend/utils/cache/knl_localpartdefcache.cpp b/src/common/backend/utils/cache/knl_localpartdefcache.cpp index fe56b8db80..1915020412 100644 --- a/src/common/backend/utils/cache/knl_localpartdefcache.cpp +++ b/src/common/backend/utils/cache/knl_localpartdefcache.cpp @@ -77,6 +77,9 @@ Partition LocalPartDefCache::SearchPartitionFromGlobalCopy(Oid part_oid) if (unlikely(!IsPrimaryRecoveryFinished())) { return NULL; } + if (unlikely(u_sess->attr.attr_common.IsInplaceUpgrade)) { + return NULL; + } uint32 hash_value = oid_hash((void *)&(part_oid), sizeof(Oid)); ResourceOwnerEnlargeGlobalBaseEntry(LOCAL_SYSDB_RESOWNER); GlobalPartitionEntry *global = (GlobalPartitionEntry *)m_global_partdefcache->SearchReadOnly(part_oid, hash_value); diff --git a/src/common/backend/utils/cache/knl_localsystupcache.cpp b/src/common/backend/utils/cache/knl_localsystupcache.cpp index 3755cbe8da..9309b5233d 100644 --- a/src/common/backend/utils/cache/knl_localsystupcache.cpp +++ b/src/common/backend/utils/cache/knl_localsystupcache.cpp @@ -434,7 +434,8 @@ LocalCatCTup *LocalSysTupCache::SearchTupleFromGlobal(Datum *arguments, uint32 h bool bypass_gsc = HistoricSnapshotActive() || m_global_systupcache->enable_rls || !g_instance.global_sysdbcache.hot_standby || - unlikely(!IsPrimaryRecoveryFinished()); + unlikely(!IsPrimaryRecoveryFinished()) || + (unlikely(u_sess->attr.attr_common.IsInplaceUpgrade)); if (invalid_entries.ExistTuple(hash_value) || bypass_gsc) { global_ct = m_global_systupcache->SearchTupleFromFile(hash_value, arguments, true); } else { @@ -586,7 +587,8 @@ LocalCatCList *LocalSysTupCache::SearchListFromGlobal(int nkeys, Datum *argument bool bypass_gsc = HistoricSnapshotActive() || m_global_systupcache->enable_rls || !g_instance.global_sysdbcache.hot_standby || - unlikely(!IsPrimaryRecoveryFinished()); + unlikely(!IsPrimaryRecoveryFinished()) || + unlikely(u_sess->attr.attr_common.IsInplaceUpgrade); GlobalCatCList *global_cl; if (invalid_entries.ExistList() || bypass_gsc) { global_cl = m_global_systupcache->SearchListFromFile(hash_value, nkeys, arguments, true); @@ -704,7 +706,8 @@ LocalCatCTup *LocalSysTupCache::SearchTupleFromGlobalForProcAllArgs( bool bypass_gsc = HistoricSnapshotActive() || m_global_systupcache->enable_rls || !g_instance.global_sysdbcache.hot_standby || - unlikely(!IsPrimaryRecoveryFinished()); + unlikely(!IsPrimaryRecoveryFinished()) || + unlikely(u_sess->attr.attr_common.IsInplaceUpgrade); if (invalid_entries.ExistTuple(hash_value) || bypass_gsc) { global_ct = m_global_systupcache->SearchTupleFromFileWithArgModes(hash_value, arguments, argModes, true); } else { diff --git a/src/common/backend/utils/cache/knl_localtabdefcache.cpp b/src/common/backend/utils/cache/knl_localtabdefcache.cpp index 63f696492b..6748917ab5 100644 --- a/src/common/backend/utils/cache/knl_localtabdefcache.cpp +++ b/src/common/backend/utils/cache/knl_localtabdefcache.cpp @@ -119,6 +119,9 @@ Relation LocalTabDefCache::SearchRelationFromGlobalCopy(Oid rel_oid) if (unlikely(!IsPrimaryRecoveryFinished())) { return NULL; } + if (unlikely(u_sess->attr.attr_common.IsInplaceUpgrade)) { + return NULL; + } uint32 hash_value = oid_hash((void *)&(rel_oid), sizeof(Oid)); Index hash_index = HASH_INDEX(hash_value, (uint32)m_nbuckets); ResourceOwner owner = LOCAL_SYSDB_RESOWNER; diff --git a/src/gausskernel/optimizer/commands/sequence/sequence.cpp b/src/gausskernel/optimizer/commands/sequence/sequence.cpp index aa2a7ea679..3255a854cc 100644 --- a/src/gausskernel/optimizer/commands/sequence/sequence.cpp +++ b/src/gausskernel/optimizer/commands/sequence/sequence.cpp @@ -1389,7 +1389,15 @@ bool shouldReturnNumeric() break; } - return get_nextval_rettype() == NUMERICOID; + HeapTuple ftup = SearchSysCache1(PROCOID, ObjectIdGetDatum(NEXTVALFUNCOID)); + if (!HeapTupleIsValid(ftup)) { + ereport(ERROR, (errmsg("cache lookup failed for function %u", NEXTVALFUNCOID))); + } + Form_pg_proc pform = (Form_pg_proc)GETSTRUCT(ftup); + bool ret = pform->prorettype == NUMERICOID; + ReleaseSysCache(ftup); + + return ret; } Datum nextval_oid(PG_FUNCTION_ARGS) -- Gitee