diff options
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r-- | src/backend/commands/tablecmds.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index a9e2a1a1ad2..4dc029f91f1 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -19174,17 +19174,24 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) if (tuples == RelationGetPartitionDesc(partedTbl, true)->nparts) { Relation idxRel; - HeapTuple newtup; + HeapTuple indTup; + Form_pg_index indexForm; idxRel = table_open(IndexRelationId, RowExclusiveLock); + indTup = SearchSysCacheCopy1(INDEXRELID, + ObjectIdGetDatum(RelationGetRelid(partedIdx))); + if (!HeapTupleIsValid(indTup)) + elog(ERROR, "cache lookup failed for index %u", + RelationGetRelid(partedIdx)); + indexForm = (Form_pg_index) GETSTRUCT(indTup); - newtup = heap_copytuple(partedIdx->rd_indextuple); - ((Form_pg_index) GETSTRUCT(newtup))->indisvalid = true; + indexForm->indisvalid = true; updated = true; - CatalogTupleUpdate(idxRel, &partedIdx->rd_indextuple->t_self, newtup); + CatalogTupleUpdate(idxRel, &indTup->t_self, indTup); table_close(idxRel, RowExclusiveLock); + heap_freetuple(indTup); } /* |