Skip to content

Commit d22d98c

Browse files
committed
Assert that partition inherits from only one parent in MergeAttributes()
A partition inherits only from one partitioned table and thus inherits a column definition only once. Assert the same in MergeAttributes() and simplify a condition accordingly. Similar definition exists about line 3068 in the same function. Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/CAExHW5uOykuTC+C6R1yDSp=o8Q83jr8xJdZxgPkxfZ1Ue5RRGg@mail.gmail.com
1 parent 58b20e6 commit d22d98c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/backend/commands/tablecmds.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2721,6 +2721,12 @@ MergeAttributes(List *columns, const List *supers, char relpersistence,
27212721
int32 deftypmod;
27222722
Oid defCollId;
27232723

2724+
/*
2725+
* Partitions have only one parent and have no column
2726+
* definitions of their own, so conflict should never occur.
2727+
*/
2728+
Assert(!is_partition);
2729+
27242730
/*
27252731
* Yes, try to merge the two column definitions.
27262732
*/
@@ -2792,12 +2798,9 @@ MergeAttributes(List *columns, const List *supers, char relpersistence,
27922798

27932799
/*
27942800
* In regular inheritance, columns in the parent's primary key
2795-
* get an extra not-null constraint. Partitioning doesn't
2796-
* need this, because the PK itself is going to be cloned to
2797-
* the partition.
2801+
* get an extra not-null constraint.
27982802
*/
2799-
if (!is_partition &&
2800-
bms_is_member(parent_attno - FirstLowInvalidHeapAttributeNumber,
2803+
if (bms_is_member(parent_attno - FirstLowInvalidHeapAttributeNumber,
28012804
pkattrs))
28022805
{
28032806
CookedConstraint *nn;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy