* StorePartitionBound
* Update pg_class tuple of rel to store the partition bound and set
* relispartition to true
+ *
+ * Also, invalidate the parent's relcache, so that the next rebuild will load
+ * the new partition's info into its partition descriptor.
*/
void
-StorePartitionBound(Relation rel, Node *bound)
+StorePartitionBound(Relation rel, Relation parent, Node *bound)
{
Relation classRel;
HeapTuple tuple,
CatalogUpdateIndexes(classRel, newtuple);
heap_freetuple(newtuple);
heap_close(classRel, RowExclusiveLock);
+
+ CacheInvalidateRelcache(parent);
}
* it does not return on error.
*/
check_new_partition_bound(relname, parent, bound);
- heap_close(parent, NoLock);
/* Update the pg_class entry. */
- StorePartitionBound(rel, bound);
+ StorePartitionBound(rel, parent, bound);
+
+ heap_close(parent, NoLock);
/*
* The code that follows may also update the pg_class tuple to update
cmd->bound);
/* Update the pg_class entry. */
- StorePartitionBound(attachRel, cmd->bound);
+ StorePartitionBound(attachRel, rel, cmd->bound);
/*
* Generate partition constraint from the partition bound specification.
}
}
- /*
- * Invalidate the parent's relcache so that the new partition is now
- * included its partition descriptor.
- */
- CacheInvalidateRelcache(rel);
-
ObjectAddressSet(address, RelationRelationId, RelationGetRelid(attachRel));
/* keep our lock until commit */
Oid *partopclass,
Oid *partcollation);
extern void RemovePartitionKeyByRelId(Oid relid);
-extern void StorePartitionBound(Relation rel, Node *bound);
+extern void StorePartitionBound(Relation rel, Relation parent, Node *bound);
#endif /* HEAP_H */