@@ -289,9 +289,11 @@ static List *MergeAttributes(List *schema, List *supers, char relpersistence,
289289static bool MergeCheckConstraint (List * constraints , char * name , Node * expr );
290290static void MergeAttributesIntoExisting (Relation child_rel , Relation parent_rel );
291291static void MergeConstraintsIntoExisting (Relation child_rel , Relation parent_rel );
292- static void StoreCatalogInheritance (Oid relationId , List * supers );
292+ static void StoreCatalogInheritance (Oid relationId , List * supers ,
293+ bool child_is_partition );
293294static void StoreCatalogInheritance1 (Oid relationId , Oid parentOid ,
294- int16 seqNumber , Relation inhRelation );
295+ int16 seqNumber , Relation inhRelation ,
296+ bool child_is_partition );
295297static int findAttrByName (const char * attributeName , List * schema );
296298static void AlterIndexNamespaces (Relation classRel , Relation rel ,
297299 Oid oldNspOid , Oid newNspOid , ObjectAddresses * objsMoved );
@@ -725,7 +727,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
725727 typaddress );
726728
727729 /* Store inheritance information for new rel. */
728- StoreCatalogInheritance (relationId , inheritOids );
730+ StoreCatalogInheritance (relationId , inheritOids , stmt -> partbound != NULL );
729731
730732 /*
731733 * We must bump the command counter to make the newly-created relation
@@ -2248,7 +2250,8 @@ MergeCheckConstraint(List *constraints, char *name, Node *expr)
22482250 * supers is a list of the OIDs of the new relation's direct ancestors.
22492251 */
22502252static void
2251- StoreCatalogInheritance (Oid relationId , List * supers )
2253+ StoreCatalogInheritance (Oid relationId , List * supers ,
2254+ bool child_is_partition )
22522255{
22532256 Relation relation ;
22542257 int16 seqNumber ;
@@ -2278,7 +2281,8 @@ StoreCatalogInheritance(Oid relationId, List *supers)
22782281 {
22792282 Oid parentOid = lfirst_oid (entry );
22802283
2281- StoreCatalogInheritance1 (relationId , parentOid , seqNumber , relation );
2284+ StoreCatalogInheritance1 (relationId , parentOid , seqNumber , relation ,
2285+ child_is_partition );
22822286 seqNumber ++ ;
22832287 }
22842288
@@ -2291,7 +2295,8 @@ StoreCatalogInheritance(Oid relationId, List *supers)
22912295 */
22922296static void
22932297StoreCatalogInheritance1 (Oid relationId , Oid parentOid ,
2294- int16 seqNumber , Relation inhRelation )
2298+ int16 seqNumber , Relation inhRelation ,
2299+ bool child_is_partition )
22952300{
22962301 TupleDesc desc = RelationGetDescr (inhRelation );
22972302 Datum values [Natts_pg_inherits ];
@@ -2325,7 +2330,14 @@ StoreCatalogInheritance1(Oid relationId, Oid parentOid,
23252330 childobject .objectId = relationId ;
23262331 childobject .objectSubId = 0 ;
23272332
2328- recordDependencyOn (& childobject , & parentobject , DEPENDENCY_NORMAL );
2333+ /*
2334+ * Partition tables are expected to be dropped when the parent partitioned
2335+ * table gets dropped.
2336+ */
2337+ if (child_is_partition )
2338+ recordDependencyOn (& childobject , & parentobject , DEPENDENCY_AUTO );
2339+ else
2340+ recordDependencyOn (& childobject , & parentobject , DEPENDENCY_NORMAL );
23292341
23302342 /*
23312343 * Post creation hook of this inheritance. Since object_access_hook
@@ -10753,7 +10765,9 @@ CreateInheritance(Relation child_rel, Relation parent_rel)
1075310765 StoreCatalogInheritance1 (RelationGetRelid (child_rel ),
1075410766 RelationGetRelid (parent_rel ),
1075510767 inhseqno + 1 ,
10756- catalogRelation );
10768+ catalogRelation ,
10769+ parent_rel -> rd_rel -> relkind ==
10770+ RELKIND_PARTITIONED_TABLE );
1075710771
1075810772 /* Now we're done with pg_inherits */
1075910773 heap_close (catalogRelation , RowExclusiveLock );
0 commit comments