> ------------------------------------------------------------------------ > 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';