Commit 4dba331cb3 broke ATTACH PARTITION behaviour. - Mailing list pgsql-hackers

From Rushabh Lathia
Subject Commit 4dba331cb3 broke ATTACH PARTITION behaviour.
Date
Msg-id CAGPqQf0W+v-Ci_qNV_5R3A=Z9LsK4+jO7LzgddRncpp_rrnJqQ@mail.gmail.com
Whole thread Raw
Responses Re: Commit 4dba331cb3 broke ATTACH PARTITION behaviour.  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
List pgsql-hackers
Hi,

Consider the below test:

CREATE TABLE foo (a INT, b INT, c VARCHAR) PARTITION BY LIST(a);
CREATE TABLE foo_p1 PARTITION OF foo FOR VALUES IN (1,2);
CREATE TABLE foo_p2 PARTITION OF foo FOR VALUES IN (3,4);
INSERT INTO foo select i,i,i from generate_series(1,4)i;

CREATE TABLE foo_d (like foo);
INSERT INTO foo_d select i,i,i from generate_series(1,9)i;

ALTER TABLE foo ATTACH PARTITION foo_d DEFAULT;

Above ATTACH PARTITION should fail with "partition constraint is violated"
error, but instead it's working on a master branch.

Looking further I found that problem introduced with below commit:

commit 4dba331cb3dc1b5ffb0680ed8efae847de216796
Author: Alvaro Herrera <alvherre@alvh.no-ip.org>
Date:   Tue Mar 20 11:19:41 2018 -0300

    Fix CommandCounterIncrement in partition-related DDL
    
    It makes sense to do the CCIs in the places that do catalog updates,
    rather than before the places that error out because the former ones
    fail to do it.  In particular, it looks like StorePartitionBound() and
    IndexSetParentIndex() ought to make their own CCIs.
    
    Per review comments from Peter Eisentraut for row-level triggers on
    partitioned tables.

I noticed that further below commit tried to correct thing in similar
area, but still I am noticing the broken behavior in case of attaching
the partition as DEFAULT.

commit 56163004b8b2151db279744b77138d4d90e2d5cb
Author: Alvaro Herrera <alvherre@alvh.no-ip.org>
Date:   Wed Mar 21 12:03:35 2018 -0300

    Fix relcache handling of the 'default' partition
    
Regards,


--
Rushabh Lathia

pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: [HACKERS] MERGE SQL Statement for PG11
Next
From: Teodor Sigaev
Date:
Subject: Re: [HACKERS] GSoC 2017: weekly progress reports (week 6)