Re: cataloguing NOT NULL constraints

Поиск
Список
Период
Сортировка
От Marcos Pegoraro
Тема Re: cataloguing NOT NULL constraints
Дата
Msg-id CAB-JLwYu3+M+CK3HTbBHMip2PDEPGP4NF52Yf_tiHH5d1KKOcg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: cataloguing NOT NULL constraints  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Список pgsql-hackers
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
 

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: static libpq (and other libraries) overwritten on aix
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Making Vars outer-join aware