diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index a1c91b5fb8..cb92b1975e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1095,6 +1095,8 @@ DefineIndex(Oid relationId, /* Attach index to parent and we're done. */ IndexSetParentIndex(cldidx, indexRelationId); + /* Also, set child index as the partition. */ + update_relispartition(NULL, cldidxid, true); if (createdConstraintId != InvalidOid) ConstraintSetParentConstraint(cldConstrOid, createdConstraintId, diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index aa7328ea40..a50a865d4c 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -525,8 +525,6 @@ static ObjectAddress ATExecAttachPartitionIdx(List **wqueue, Relation rel, static void validatePartitionedIndex(Relation partedIdx, Relation partedTbl); static void refuseDupeIndexAttach(Relation parentIdx, Relation partIdx, Relation partitionTbl); -static void update_relispartition(Relation classRel, Oid relationId, - bool newval); static List *GetParentedForeignKeyRefs(Relation partition); static void ATDetachCheckNoForeignKeyRefs(Relation partition); @@ -16407,7 +16405,7 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) * classRel is the pg_class relation, already open and suitably locked. * It can be passed as NULL, in which case it's opened and closed locally. */ -static void +void update_relispartition(Relation classRel, Oid relationId, bool newval) { HeapTuple tup; diff --git a/src/include/commands/tablecmds.h b/src/include/commands/tablecmds.h index 96927b900d..6898fa864c 100644 --- a/src/include/commands/tablecmds.h +++ b/src/include/commands/tablecmds.h @@ -57,6 +57,8 @@ extern void ExecuteTruncateGuts(List *explicit_rels, List *relids, List *relids_ DropBehavior behavior, bool restart_seqs); extern void SetRelationHasSubclass(Oid relationId, bool relhassubclass); +extern void update_relispartition(Relation classRel, Oid relationId, + bool newval); extern ObjectAddress renameatt(RenameStmt *stmt);