Re: not null constraints, again

From: Tender Wang <tndrwang(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: jian he <jian(dot)universality(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: not null constraints, again
Date: 2024-09-23 06:40:00
Message-ID: CAHewXNkNKJKBic7WXYP-k9zb5d25Q1dSo+BCjGbpBXPvYgYNJQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> 于2024年9月21日周六 05:15写道:

> On 2024-Sep-20, Alvaro Herrera wrote:
>
> > Yeah, there's a bunch of conflicts in current master. I rebased
> > yesterday but I'm still composing the email for v4. Coming soon.
>
> Okay, so here is v4 with these problems fixed, including correct
> propagation of constraint names to children tables, which I had
> inadvertently broken earlier. This one does pass the pg_upgrade tests
> and as far as I can see pg_dump does all the correct things also. I
> cleaned up the tests to remove everything that's unneeded, redundant, or
> testing behavior that no longer exists.
>
> I changed the behavior of ALTER TABLE ONLY <parent> ADD PRIMARY KEY, so
> that it throws error in case a child does not have a NOT NULL constraint
> on one of the columns, rather than silently creating such a constraint.
> (This is how `master` currently behaves). I think this is better
> behavior, because it lets the user decide whether they want to scan the
> table to create that constraint or not. It's a bit crude at present,
> because (1) a child could have a NO INHERIT constraint and have further
> children, which would foil the check (I think changing
> find_inheritance_children to find_all_inheritors would be sufficient to
> fix this, but that's only needed in legacy inheritance not
> partitioning); (2) the error message doesn't have an errcode, and the
> wording might need work.
>

The indexing test case in regress failed with v4 patch.
alter table only idxpart add primary key (a); -- fail, no not-null
constraint
-ERROR: column a of table idxpart0 is not marked not null
+ERROR: column "a" of table "idxpart0" is not marked NOT NULL

It seemed the error message forgot to change.

--
Thanks,
Tender Wang
https://www.openpie.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jakub Wartak 2024-09-23 07:04:02 Re: Configurable FP_LOCK_SLOTS_PER_BACKEND
Previous Message Tatsuo Ishii 2024-09-23 06:28:32 Re: Add memory/disk usage for WindowAgg nodes in EXPLAIN