From: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
---|---|
To: | Michael Paquier <michael(at)paquier(dot)xyz> |
Cc: | Alexander Lakhin <exclusion(at)gmail(dot)com>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: cataloguing NOT NULL constraints |
Date: | 2024-02-05 18:11:18 |
Message-ID: | 202402051811.kqefo2toa3yg@alvherre.pgsql |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2024-Feb-05, Alvaro Herrera wrote:
> While playing with it I noticed this other behavior change from 16,
>
> create table pa (a int primary key) partition by list (a);
> create table pe (a int unique);
> alter table pa attach partition pe for values in (1, null);
>
> In 16, we get the error:
> ERROR: column "a" in child table must be marked NOT NULL
> which is correct (because the PK requires not-null). In master we just
> let that through, but that seems to be a separate bug.
Hmm, so my initial reaction was to make the constraint-matching code
ignore the constraint in the partition-to-be if it's not the same type
(this is what patch 0002 here does) ... but what ends up happening is
that we create a separate, identical constraint+index for the primary
key. I don't like that behavior too much myself, as it seems too
magical and surprising, since it could cause the ALTER TABLE ATTACH
operation of a large partition become costly and slower, since it needs
to create an index instead of merely scanning the whole data.
I'll look again at the idea of raising an error if the not-null
constraint is not already present. That seems safer (and also, it's
what we've been doing all along).
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
Attachment | Content-Type | Size |
---|---|---|
v2-0001-Fix-failure-to-merge-NOT-NULL-constraints-in-inhe.patch | text/x-diff | 3.5 KB |
v2-0002-ATTACH-PARTITION-Don-t-let-a-UNIQUE-constraint-ma.patch | text/x-diff | 2.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2024-02-05 18:21:18 | Re: Make COPY format extendable: Extract COPY TO format implementations |
Previous Message | John Morris | 2024-02-05 17:29:08 | Re: Where can I find the doxyfile? |