From 94ed51b61567514b81e150da24602d008c2ce85a Mon Sep 17 00:00:00 2001 From: cc_db_dev Date: Wed, 26 Apr 2023 16:43:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DfreePartList=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E7=9A=84=E5=86=85=E5=AD=98=E6=B3=84=E6=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit freePartList函数中没有释放cell的内存,参考list_free_private修正之 删除无用的函数freeSubPartList --- src/common/backend/catalog/pg_partition.cpp | 22 +++++++-------------- src/include/catalog/pg_partition_fn.h | 1 - 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/common/backend/catalog/pg_partition.cpp b/src/common/backend/catalog/pg_partition.cpp index a6a8490bf2..ed1dc256d4 100644 --- a/src/common/backend/catalog/pg_partition.cpp +++ b/src/common/backend/catalog/pg_partition.cpp @@ -1048,26 +1048,18 @@ void freePartList(List* plist) ListCell* tuplecell = NULL; HeapTuple tuple = NULL; - foreach (tuplecell, plist) { + tuplecell = list_head(plist); + while (tuplecell != NULL) { + ListCell* tmp = tuplecell; tuple = (HeapTuple)lfirst(tuplecell); + tuplecell = lnext(tuplecell); + if (HeapTupleIsValid(tuple)) { heap_freetuple_ext(tuple); } - } - - if (PointerIsValid(plist)) { - pfree_ext(plist); - } -} - -void freeSubPartList(List* plist) -{ - ListCell* cell = NULL; - - foreach (cell, plist) { - List *subParts = (List *)lfirst(cell); - freePartList(subParts); + + pfree(tmp); } if (PointerIsValid(plist)) { diff --git a/src/include/catalog/pg_partition_fn.h b/src/include/catalog/pg_partition_fn.h index ecec5ec584..db2fb91ad5 100644 --- a/src/include/catalog/pg_partition_fn.h +++ b/src/include/catalog/pg_partition_fn.h @@ -248,7 +248,6 @@ extern List *searchPgPartitionByParentId(char parttype, Oid parentId, ScanDirect extern List *searchPgSubPartitionByParentId(char parttype, List *parentOids, ScanDirection direction = ForwardScanDirection); extern void freePartList(List *l); -extern void freeSubPartList(List* plist); extern HeapTuple searchPgPartitionByParentIdCopy(char parttype, Oid parentId); extern Oid GetBaseRelOidOfParition(Relation relation); -- Gitee