Re: Support NOT VALID / VALIDATE constraint options for named NOT NULL constraints - Mailing list pgsql-hackers

From Rushabh Lathia
Subject Re: Support NOT VALID / VALIDATE constraint options for named NOT NULL constraints
Date
Msg-id CAGPqQf3FJV26wx9qwtyY01hqgXvJ_Z-ZFB5bDW=O2+mBYATOBQ@mail.gmail.com
Whole thread Raw
In response to Re: Support NOT VALID / VALIDATE constraint options for named NOT NULL constraints  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
List pgsql-hackers


> ------------------------------------------------------------------------
> i think your patch messed up with pg_constraint.conislocal.
> for example:
>
> CREATE TABLE parted (id bigint default 1,id_abc bigint) PARTITION BY LIST (id);
> alter TABLE parted add CONSTRAINT dummy_constr not null id not valid;
> CREATE TABLE parted_1 (id bigint default 1,id_abc bigint);
> alter TABLE parted_1 add CONSTRAINT dummy_constr not null id;
> ALTER TABLE parted ATTACH PARTITION parted_1 FOR VALUES IN ('1');

It's still not clear to me what to do to fix this problem.  But while
trying to understand it, I had the chance to rework the pg_dump code
somewhat, so here it is.  Feel free to propose fixes on top of this.
(BTW, I think the business of assigning to tbinfo->checkexprs both the
block for check constraints and the one for not-null constraints is
bogus.  I didn't find what this breaks, but it looks wrong.  We probably
need another struct _constraintInfo pointer in TableInfo.)

I fail to understand the issue here. I tested the scenario both with and without the patch,
and the behavior remained the same in both cases. While testing without the patch,
I ensured that I created valid constraints.

I ran the script below with and without the patch, and the output was the same in both cases.

------------------------------------------------------------------

CREATE TABLE parted (id bigint default 1,id_abc bigint) PARTITION BY LIST (id);
alter TABLE parted add CONSTRAINT dummy_constr not null id;
select conrelid::regclass, conname, conislocal
from pg_constraint where conname = 'dummy_constr';

CREATE TABLE parted_1 (id bigint default 1,id_abc bigint);
alter TABLE parted_1 add CONSTRAINT dummy_constr not null id;

select conrelid::regclass, conname, conislocal
from pg_constraint where conname = 'dummy_constr';

ALTER TABLE parted ATTACH PARTITION parted_1 FOR VALUES IN ('1');

select conrelid::regclass, conname, conislocal
from pg_constraint where conname = 'dummy_constr';

------------------------------------------------------------------

Are we expecting conislocal status to be different when it's NOT NULL NOT VALID?

Thanks & Regards
Rushabh Lathia

pgsql-hackers by date:

Previous
From: John Naylor
Date:
Subject: Re: Improve CRC32C performance on SSE4.2
Next
From: "Hayato Kuroda (Fujitsu)"
Date:
Subject: RE: Fix 035_standby_logical_decoding.pl race conditions