ATExecAttachPartition-create-inheritance-after-checking-bound.patch

text/plain

Filename: ATExecAttachPartition-create-inheritance-after-checking-bound.patch
Type: text/plain
Part: 0
Message: Re: pg_upgrade failed with ERROR: null relpartbound for relation 18159 error.

Patch

Format: unified
File+
src/backend/commands/tablecmds.c 3 3
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index c145385f84..2d0043d1db 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -14247,9 +14247,6 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
 						trigger_name, RelationGetRelationName(attachrel)),
 				 errdetail("ROW triggers with transition tables are not supported on partitions")));
 
-	/* OK to create inheritance.  Rest of the checks performed there */
-	CreateInheritance(attachrel, rel);
-
 	/*
 	 * Check that the new partition's bound is valid and does not overlap any
 	 * of existing partitions of the parent - note that it does not return on
@@ -14258,6 +14255,9 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
 	check_new_partition_bound(RelationGetRelationName(attachrel), rel,
 							  cmd->bound);
 
+	/* OK to create inheritance.  Rest of the checks performed there */
+	CreateInheritance(attachrel, rel);
+
 	/* Update the pg_class entry. */
 	StorePartitionBound(attachrel, rel, cmd->bound);