From: | Amul Sul <sulamul(at)gmail(dot)com> |
---|---|
To: | jian he <jian(dot)universality(at)gmail(dot)com> |
Cc: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Peter Eisentraut <peter(at)eisentraut(dot)org>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Joel Jacobson <joel(at)compiler(dot)org> |
Subject: | Re: NOT ENFORCED constraint feature |
Date: | 2024-12-11 12:58:13 |
Message-ID: | CAAJ_b94XS7=TmC0hTu_DWq_uB4soRX42XwGgBST-53_n+Jx8tA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Dec 11, 2024 at 6:12 PM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
> On Tue, Dec 10, 2024 at 7:48 PM Amul Sul <sulamul(at)gmail(dot)com> wrote:
> >
> > >
> > > static bool
> > > MergeWithExistingConstraint(Relation rel, const char *ccname, Node *expr,
> > > bool allow_merge, bool is_local,
> > > + bool is_enforced,
> > > bool is_initially_valid,
> > > bool is_no_inherit)
> > > {
> > > @@ -2729,12 +2738,24 @@ MergeWithExistingConstraint(Relation rel,
> > > const char *ccname, Node *expr,
> > > * If the child constraint is "not valid" then cannot merge with a
> > > * valid parent constraint.
> > > */
> > > - if (is_initially_valid && !con->convalidated)
> > > + if (is_initially_valid && con->conenforced && !con->convalidated)
> > > ereport(ERROR,
> > > (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
> > > errmsg("constraint \"%s\" conflicts with NOT VALID constraint on
> > > relation \"%s\"",
> > > ccname, RelationGetRelationName(rel))));
> > >
> > > There are no tests for this change. I think this change is not necessary.
> > >
> >
> > It is necessary; otherwise, it would raise an error for a NOT ENFORCED
> > constraint, which is NOT VALID by default.
> >
> got it.
> overall v8-0001 looks good to me!
>
Thank you.
> do you have a patch for
> alter check constraint set [not] enforced?
> If not, I will probably try to work on it.
>
Not yet; I believe I need to first look into allowing NOT VALID
foreign key constraints on partitioned tables.
>
> I am playing around with the remaining patch.
>
> ATExecAlterConstrRecurse
> ATExecAlterConstrEnforceability
> ATExecAlterChildConstr
> AlterConstrTriggerDeferrability
> These four functions take a lot of arguments.
> more comments about these arguments would be helpful.
> we only need to mention it at ATExecAlterConstrRecurse.
>
> for example:
> ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel,
> const Oid fkrelid, const Oid pkrelid,
> HeapTuple contuple, List **otherrelids,
> LOCKMODE lockmode, Oid ReferencedParentDelTrigger,
> Oid ReferencedParentUpdTrigger,
> Oid ReferencingParentInsTrigger,
> Oid ReferencingParentUpdTrigger)
> the comments only explained otherrelids.
>
> LOCKMODE lockmode,
> Oid ReferencedParentDelTrigger,
> Oid ReferencedParentUpdTrigger,
> Oid ReferencingParentInsTrigger,
> Oid ReferencingParentUpdTrigger
>
> The above arguments are pretty intuitive.
>
> Constraint *cmdcon
> Relation conrel
> Relation tgrel
> HeapTuple contuple
>
> but these arguments are not that very intuitive,
> especially these arguments passing to another function.
Those are the existing ones; let me think what can be done with them.
Regards,
Amul
From | Date | Subject | |
---|---|---|---|
Next Message | jian he | 2024-12-11 14:00:16 | Re: Proposals for EXPLAIN: rename ANALYZE to EXECUTE and extend VERBOSE |
Previous Message | jian he | 2024-12-11 12:42:26 | Re: NOT ENFORCED constraint feature |