Re: not null constraints, again
Alvaro Herrera <alvherre@alvh.no-ip.org>
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: jian he <jian.universality@gmail.com>
Cc: Tender Wang <tndrwang@gmail.com>, Pg Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-09-27T13:07:09Z
Lists: pgsql-hackers
Attachments
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)
Commits
-
Suppress "may be used uninitialized" warnings from older compilers.
- fc5e966f73f0 18.0 landed
-
Elide not-null constraint checks on child tables during PK creation
- 11ff192b5bb7 18.0 landed
-
Remove unnecessary code to handle CONSTR_NOTNULL
- 5b291d1c9c09 18.0 landed
-
Silence compilers about extractNotNullColumn()
- ff239c3bf4e8 18.0 landed
-
Add pg_constraint rows for not-null constraints
- 14e87ffa5c54 18.0 landed