>
> I started this time around from the newest of my patches in those
> threads, but the implementation has changed considerably from what's
> there.
>

I don“t know exactly what will be the scope of this process you're working
on, but there is a gap on foreign key constraint too.
It is possible to have wrong values on a FK constraint if you disable
checking of it with session_replication_role or disable trigger all
I know you can create that constraint with "not valid" and it'll be checked
when turned on. But if I just forgot that ...
So would be good to have validate constraints which checks, even if it's
already valid

drop table if exists tb_pk cascade;create table tb_pk(key integer not null
primary key);
drop table if exists tb_fk cascade;create table tb_fk(fk_key integer);
alter table tb_fk add constraint fk_pk foreign key (fk_key) references
tb_pk (key);
insert into tb_pk values(1);
alter table tb_fk disable trigger all; --can be with
session_replication_role too.
insert into tb_fk values(5); --wrong values on that table

Then, you could check

alter table tb_fk validate constraint fk_pk
or
alter table tb_fk validate all constraints

Reply via email to