From: | Amit Langote <amitlangote09(at)gmail(dot)com> |
---|---|
To: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
Cc: | Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com> |
Subject: | Re: doc fail about ALTER TABLE ATTACH re. NO INHERIT |
Date: | 2024-11-13 12:52:10 |
Message-ID: | CA+HiwqGk2Y54FAE7fTKCmJNusT49RgFUOMu2yPzEWqRMG99=6g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Nov 12, 2024 at 5:46 PM Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)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
Attachment | Content-Type | Size |
---|---|---|
v2-0001-Allow-inherited-constraints-to-be-marked-NO-INHER.patch | application/octet-stream | 18.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | jian he | 2024-11-13 12:56:59 | Re: altering a column's collation leaves an invalid foreign key |
Previous Message | torikoshia | 2024-11-13 12:48:10 | Re: Add reject_limit option to file_fdw |