From 428d997b9f0172d1cdea02a8946843dcf474c759 Mon Sep 17 00:00:00 2001 From: Ashutosh Bapat Date: Thu, 7 Dec 2023 11:38:07 +0530 Subject: [PATCH 02/27] Assert that partition inherits from only one parent in MergeAttributes() A partition inherits only from one partitioned table and thus inherits column definition only once. Assert the same in MergeAttributes() and simplify a condition accordingly. Similar definition exists about line 3068 in the same function. Ashutosh Bapat --- src/backend/commands/tablecmds.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 6b0a20010e..18046a0d69 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -2712,6 +2712,12 @@ MergeAttributes(List *columns, const List *supers, char relpersistence, int32 deftypmod; Oid defCollId; + /* + * Partitions have only one parent and have no column + * definitions of their own, so conflict should never occur. + */ + Assert(!is_partition); + /* * Yes, try to merge the two column definitions. */ @@ -2783,12 +2789,9 @@ MergeAttributes(List *columns, const List *supers, char relpersistence, /* * In regular inheritance, columns in the parent's primary key - * get an extra not-null constraint. Partitioning doesn't - * need this, because the PK itself is going to be cloned to - * the partition. + * get an extra not-null constraint. */ - if (!is_partition && - bms_is_member(parent_attno - FirstLowInvalidHeapAttributeNumber, + if (bms_is_member(parent_attno - FirstLowInvalidHeapAttributeNumber, pkattrs)) { CookedConstraint *nn; -- 2.25.1