From 5ea8ac9c4aadb69a3d4dc26999e76bf6e614c19b Mon Sep 17 00:00:00 2001 From: pgsql-guo Date: Wed, 17 Aug 2022 04:16:46 +0000 Subject: [PATCH v1] fix partitioned index matching --- src/backend/commands/indexcmds.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 15a57ea9c3..f189ab0db7 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1286,6 +1286,7 @@ DefineIndex(Oid relationId, Oid cldidxid = lfirst_oid(cell); Relation cldidx; IndexInfo *cldIdxInfo; + Relation index; /* this index is already partition of another one */ if (has_superclass(cldidxid)) @@ -1293,6 +1294,9 @@ DefineIndex(Oid relationId, cldidx = index_open(cldidxid, lockmode); cldIdxInfo = BuildIndexInfo(cldidx); + + index = index_open(indexRelationId, lockmode); + indexInfo = BuildIndexInfo(index); if (CompareIndexInfo(cldIdxInfo, indexInfo, cldidx->rd_indcollation, collationObjectId, @@ -1336,10 +1340,12 @@ DefineIndex(Oid relationId, found = true; /* keep lock till commit */ index_close(cldidx, NoLock); + index_close(index, NoLock); break; } index_close(cldidx, lockmode); + index_close(index, lockmode); } list_free(childidxs); -- 2.25.1