public inbox for [email protected]
help / color / mirror / Atom feedFrom: Himanshu Upadhyaya <[email protected]>
To: Dilip Kumar <[email protected]>
Cc: David G. Johnston <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: CHECK Constraint Deferrable
Date: Mon, 11 Sep 2023 17:45:14 +0530
Message-ID: <CAPF61jCSd85jkVMz_P7kirjyEVGcAJjPpfjgOYDNh2QgSBQMew@mail.gmail.com> (raw)
In-Reply-To: <CAFiTN-u2D2Zs5BRO23i4yknx7gy72P8adQKhEYJ_qsJMbcy6jw@mail.gmail.com>
References: <CAPF61jBFT6iGv-Af=NrZx3vhqLYqx8WDvfjqVuRVYv2DFbbY4A@mail.gmail.com>
<CAFiTN-tRjms-23L7FyxACJHcxcYr8yo=KP8JN4XC2gtukaXT3A@mail.gmail.com>
<CAPF61jCRXxCo9wX=RW2mqc+bnB=DPijU1ruGDki55TYYiSu7yw@mail.gmail.com>
<CAKFQuwZf0We7p-7Df-Fyxrfv+cS=meF0DorEtuBWx5nhLZ+j9A@mail.gmail.com>
<CAPF61jAH7NhgoQkzuv+eBE8UyLorB8uQB0_hgmAYWj783GnxRQ@mail.gmail.com>
<CAFiTN-u2D2Zs5BRO23i4yknx7gy72P8adQKhEYJ_qsJMbcy6jw@mail.gmail.com>
On Fri, Sep 8, 2023 at 1:23 PM Dilip Kumar <[email protected]> wrote:
> 2.
> - if ((failed = ExecRelCheck(resultRelInfo, slot, estate)) != NULL)
> + if ((failed = ExecRelCheck(resultRelInfo, slot, estate,
> checkConstraint, &recheckConstraints)) != NULL && !recheckConstraints)
>
>
> Why recheckConstraints need to get as output from ExecRelCheck? I
> mean whether it will be rechecked or nor is already known by the
> caller and
>
Yes it will be known to the caller but ExecRelCheck will set this new
parameter only if any one of the constraint is defined as Deferrable (in
create table statement) and there is a potential constraint violation.
> Whether the constraint failed or passed is known based on the return
> value so why do you need to extra parameter here?
>
> Because if normal CHECK constraint(non Deferrable) is violated, no need to
proceed with the insertion and in that case recheckConstraints will hold
"false" but if Deferrable check constraint is violated, we need to
revalidate the constraint at commit time and recheckConstraints will hold
"true".
>
> 5.
> +typedef enum checkConstraintRecheck
> +{
> + CHECK_RECHECK_DISABLED, /* Recheck of CHECK constraint is disabled, so
> + * DEFERRED CHECK constraint will be
> + * considered as non-deferrable check
> + * constraint. */
> + CHECK_RECHECK_ENABLED, /* Recheck of CHECK constraint is enabled, so
> + * CHECK constraint will be validated but
> + * error will not be reported for deferred
> + * CHECK constraint. */
> + CHECK_RECHECK_EXISTING /* Recheck of existing violated CHECK
> + * constraint, indicates that this is a
> + * deferred recheck of a row that was reported
> + * as a potential violation of CHECK
> + * CONSTRAINT */
> +} checkConstraintRecheck;
>
> I do not like the naming convention here, especially the words
> RECHECK, DISABLE, and ENABLE. And also the name of the enum is a bit
> off. We can name it more like a unique constraint
> YES, PARTIAL, EXISTING
>
> I can think of alternative ENUM name as "EnforceDeferredCheck" and member
as “CHECK_DEFERRED_YES”, “CHECK_DEFRRED_NO” and “CHECK_DEFERRED_EXISTING”.
Thoughts?
--
Regards,
Himanshu Upadhyaya
EnterpriseDB: http://www.enterprisedb.com
view thread (2+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Subject: Re: CHECK Constraint Deferrable
In-Reply-To: <CAPF61jCSd85jkVMz_P7kirjyEVGcAJjPpfjgOYDNh2QgSBQMew@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox