Re: not null constraints, again

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

On 2024-Sep-25, jian he wrote:

> in ATExecSetNotNull
> /*
> * If we find an appropriate constraint, we're almost done, but just
> * need to change some properties on it: if we're recursing, increment
> * coninhcount; if not, set conislocal if not already set.
> */
> if (recursing)
> {
> conForm->coninhcount++;
> changed = true;
> }
> else if (!conForm->conislocal)
> {
> conForm->conislocal = true;
> changed = true;
> elog(INFO, "constraint islocal attribute changed");
> }
> if (recursing && !conForm->conislocal)
> elog(INFO, "should not happenX");
>
>
> "should not happenX" appeared in regression.diff, but not
> "constraint islocal attribute changed"
> Does that mean the IF, ELSE IF logic is not right?

I don't see a problem here. It means recursing is true, therefore we're
down one level already and don't need to set conislocal. Modifying
coninhcount is enough.

I attach v6 of this patch, including the requisite removal of the
ATExecDropNotNull ereport(ERROR) that I mentioned in the other
thread[1]. I think I have made fixes for all your comments, though I
would like to go back and verify all of them once again, as well as read
it in full.

[1] https://postgr.es/m/202409261752.nbvlawkxsttf@alvherre.pgsql

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"Digital and video cameras have this adjustment and film cameras don't for the
same reason dogs and cats lick themselves: because they can." (Ken Rockwell)

Attachment Content-Type Size
v6-0001-Don-t-disallow-DROP-of-constraints-ONLY-on-partit.patch text/x-diff 6.6 KB
v6-0002-Catalog-not-null-constraints.patch text/x-diff 307.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Junwang Zhao 2024-09-27 13:15:45 general purpose array_sort
Previous Message Christoph Berg 2024-09-27 12:17:15 Better error reporting from extension scripts (Was: Extend ALTER OPERATOR)