Re: NOT ENFORCED constraint feature

From: Amul Sul <sulamul(at)gmail(dot)com>
To: Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, jian he <jian(dot)universality(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Joel Jacobson <joel(at)compiler(dot)org>, Suraj Kharage <suraj(dot)kharage(at)enterprisedb(dot)com>
Subject: Re: NOT ENFORCED constraint feature
Date: 2025-02-17 10:11:20
Message-ID: CAAJ_b96gEVfK5MVe5YRVwBuobMFr_CKGvz683zFLNeF8gAN5_Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Feb 11, 2025 at 12:18 AM Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
>
[...]
>
> > • v13-0001-Add-AlterConstraintStmt-struct-for-ALTER-.-CONST.patch
>
> I think the new node name is wrong, because it makes the code looks as if we support ALTER CONSTRAINT as a statement for this, which is false. (This is a repeat of ReplicaIdentityStmt, which I think is a mistake). I would suggest a name like ATAlterConstraint instead. Perhaps we can use that in the patch for ALTER CONSTRAINT ... SET [NO] INHERIT as well, instead of (as I suggested Suraj) creating a separate subcommand number.

I have renamed AlterConstraintStmt to ATAlterConstraint as per your
suggestion in the attached version. Apart from this, there are no
other changes, as the final behavior is still unclear based on the
discussions so far.

If we don’t want to keep a constraint marked as valid when it is not
enforced, we should revert to the v12 version behavior, where the
constraint is marked invalid when changed to NOT ENFORCED and remains
so even after being changed to ENFORCED, until explicitly validated
using the existing ALTER ... VALIDATE CONSTRAINT command.

However, if we want to provide an option to validate the constraint
immediately when changing it to ENFORCED, we could introduce support
for a syntax like:

ALTER TABLE ... ALTER CONSTRAINT ... [ NOT ] ENFORCED [ (WITH |
WITHOUT) VALIDATION ]

Regards,
Amul

Attachment Content-Type Size
v14-0001-Add-ATAlterConstraint-struct-for-ALTER-.-CONSTRA.patch application/x-patch 6.4 KB
v14-0002-refactor-Split-tryAttachPartitionForeignKey.patch application/x-patch 13.5 KB
v14-0003-Move-the-RemoveInheritedConstraint-function-call.patch application/x-patch 2.7 KB
v14-0004-refactor-Pass-Relid-instead-of-Relation-to-creat.patch application/x-patch 3.3 KB
v14-0005-refactor-Change-ATExecAlterConstrRecurse-argumen.patch application/x-patch 5.3 KB
v14-0006-Remove-hastriggers-flag-check-before-fetching-FK.patch application/x-patch 10.8 KB
v14-0007-Ease-the-restriction-that-a-NOT-ENFORCED-constra.patch application/x-patch 20.7 KB
v14-0008-Add-support-for-NOT-ENFORCED-in-foreign-key-cons.patch application/x-patch 63.4 KB
v14-0009-Merge-the-parent-and-child-constraints-with-diff.patch application/x-patch 31.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2025-02-17 10:34:47 Re: Get rid of WALBufMappingLock
Previous Message Ilia Evdokimov 2025-02-17 09:50:00 Re: describe special values in GUC descriptions more consistently