Re: doc fail about ALTER TABLE ATTACH re. NO INHERIT
Amit Langote <amitlangote09@gmail.com>
From: Amit Langote <amitlangote09@gmail.com>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Pg Hackers <pgsql-hackers@lists.postgresql.org>,
Robert Haas <robertmhaas@gmail.com>
Date: 2024-11-13T12:52:10Z
Lists: pgsql-hackers
Attachments
- v2-0001-Allow-inherited-constraints-to-be-marked-NO-INHER.patch (application/octet-stream) patch v2-0001
On Tue, Nov 12, 2024 at 5:46 PM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote: > On 2024-Nov-11, Amit Langote wrote: > > > The restriction also exists in the CREATE TABLE PARTITION OF path: > > > > [...] > > > > I think we can remove the restriction at least for the leaf partition > > case just like in the ATTACH PARTITION path. > > Sure, WFM. I rebased my patch over 14e87ffa5c54 and noticed that NOT NULL constraints can also (or not) be marked NO INHERIT. I think we should allow NO INHERIT NOT NULL constraints on leaf partitions just like CHECK constraints, so changed AddRelationNotNullConstraints() that way and added some tests. However, I noticed that there is no clean way to do that for the following case: ALTER TABLE leaf_partition ADD CONSTRAINT col_nn_ni NOT NULL col NO INHERIT; If I change the new function AdjustNotNullInheritance() added by your commit to not throw an error for leaf partitions, the above constraint (col_nn_ni) is not stored at all, because the function returns true in that case, which means the caller does nothing with the constraint. I am not sure what the right thing to do would be. If we return false, the caller will store the constraint the first time around, but repeating the command will again do nothing, not even prevent the addition of a duplicate constraint. -- Thanks, Amit Langote
Commits
-
doc: Reword ALTER TABLE ATTACH restriction on NO INHERIT constraints
- f56a01ebdbd5 18.0 landed
- f534e38914eb 13.17 landed
- e2b5693c6cf2 17.1 landed
- d291e819be0c 15.9 landed
- 6f4524729ca2 16.5 landed
- 477830c1cb94 12.21 landed
- 344ac149cfdf 14.14 landed
-
Implement table partitioning.
- f0e44751d717 10.0 cited
-
Disallow merging ONLY constraints in children tables
- 3b11247aadf8 9.2.0 cited