public inbox for [email protected]
help / color / mirror / Atom feedFrom: Zsolt Parragi <[email protected]>
To: [email protected]
Subject: Re: Fix bug of CHECK constraint enforceability recursion
Date: Tue, 2 Jun 2026 15:56:40 -0500
Message-ID: <CAN4CZFMgVDOosK_aM15+VV=WC_wgT52d4xgnaOBzvh4LtRq=1A@mail.gmail.com> (raw)
In-Reply-To: <CACJufxHbVuY683j3DHEU4LSswo8DTzLJbTvhv2Uj6gqN8pJs7Q@mail.gmail.com>
References: <[email protected]>
<CACJufxGRkCSqqRwd+3MMVFbosKXHv=Jc+KyGK+NM3YAHN7eu+g@mail.gmail.com>
<[email protected]>
<[email protected]>
<[email protected]>
<CACJufxGxY=1mxcNz8-bjp6R+ZoCRE3O7DYt2ZqObv-Le+aMOqw@mail.gmail.com>
<[email protected]>
<CACJufxFwJH5K1jgL1ryckYX8gxp1sfqz_2ypey1sYtWZ5u45oQ@mail.gmail.com>
<[email protected]>
<[email protected]>
<CACJufxHbVuY683j3DHEU4LSswo8DTzLJbTvhv2Uj6gqN8pJs7Q@mail.gmail.com>
Hello
+ * During recursion, another parent outside this ALTER may still enforce
+ * the same constraint. In that case, keep the child constraint ENFORCED
+ * so that its merged enforceability still reflects the remaining enforced
+ * parent.
+ */
+ if (!cmdcon->is_enforced)
+ {
This means once is_enforced is set to true, it will never be
rechecked. See the following example which showcases an issue with
this:
create table g(a int constraint k check(a > 0) enforced);
create table o(a int constraint k check(a > 0) enforced);
create table s1() inherits(g);
create table s2() inherits(g, o);
create table s3() inherits(g);
alter table g alter constraint k not enforced;
select conrelid::regclass as tbl, conenforced
from pg_constraint
where conname = 'k' and contype = 'c'
order by conrelid::regclass::text collate "C";
insert into s1 values (-1);
insert into s3 values (-1); -- bug: ERRORs out, but shouldn't
view thread (32+ messages) latest in thread
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]
Subject: Re: Fix bug of CHECK constraint enforceability recursion
In-Reply-To: <CAN4CZFMgVDOosK_aM15+VV=WC_wgT52d4xgnaOBzvh4LtRq=1A@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