Search Postgresql Archives

Re: Rows violating Foreign key constraint exists

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,


> Have you verified that the FK is not in the parent table and is just not
> some index error/corruption?

Yes.

> >
> > Also, is there any way to make sure the FK checking trigger can never
> > be disabled (so that such a case will never arise)?
>
> Not sure that can happen as it is baked into existing code. For instance:
>
> https://www.postgresql.org/docs/11/app-pgdump.html
>
> "
> --disable-triggers
>
>      This option is relevant only when creating a data-only dump. It
> instructs pg_dump to include commands to temporarily disable triggers on
> the target tables while the data is reloaded. Use this if you have
> referential integrity checks or other triggers on the tables that you do
> not want to invoke during data reload.

Found this thread which discusses the same topic as here.
https://www.postgresql.org/message-id/20190715160926.GA17140%40alvherre.pgsql

PG already allows a new FK to be created with ADD CONSTRAINT ... NOT
VALID clause which can be validated later using ALTER TABLE ...
VALIDATE CONSTRAINT.
I guess what we are looking for here is the same but for existing FKs.

i.e Something like

`ALTER TABLE distributors ALTER CONSTRAINT distfk NOT VALID;`
`ALTER TABLE distributors VALIDATE CONSTRAINT distfk;`


Regards,
Nanda





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux