From: | Nandakumar M <m(dot)nanda92(at)gmail(dot)com> |
---|---|
To: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
Cc: | "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Rows violating Foreign key constraint exists |
Date: | 2019-11-29 08:15:37 |
Message-ID: | CANcFUu7gHMxK=px+zwt+mnX63-2ELU0nmLbYvP=GmL0+dERKXg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Nandakumar M | 2019-11-29 09:02:35 | Re: Rows violating Foreign key constraint exists |
Previous Message | Nandakumar M | 2019-11-29 07:40:07 | Re: Rows violating Foreign key constraint exists |