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 <alvhe...@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 <alvhe...@alvh.no-ip.org> Date: Wed Mar 21 12:03:35 2018 -0300 Fix relcache handling of the 'default' partition Regards, -- Rushabh Lathia