Subject: [PATCH 1/2] Fixes to index_get_partition()

From: Justin Pryzby <[email-masked]>
Date: Thu, 5 Nov 2020 12:06:49 -0600

which was added at: a6da0047158b8a227f883aeed19eb7fcfbef11fb

free list in cases where there's no parent
use lsyscache: get_rel_relispartition()
---
 src/backend/catalog/partition.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/backend/catalog/partition.c b/src/backend/catalog/partition.c
index 239ac017fa..4dfac39adf 100644
--- a/src/backend/catalog/partition.c
+++ b/src/backend/catalog/partition.c
@@ -170,13 +170,14 @@ index_get_partition(Relation partition, Oid indexId)
 		ReleaseSysCache(tup);
 		if (!ispartition)
 			continue;
-		if (get_partition_parent(lfirst_oid(l)) == indexId)
+		if (get_partition_parent(partIdx) == indexId)
 		{
 			list_free(idxlist);
 			return partIdx;
 		}
 	}
 
+	list_free(idxlist);
 	return InvalidOid;
 }
 
-- 
2.17.0

--6K2R/cS9K4qvcBNq
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="0002-index_get_partition-use-lsyscache.patch"