Re: referential integrity violations - Mailing list pgsql-general

From Tom Lane
Subject Re: referential integrity violations
Date
Msg-id 6176.1055285813@sss.pgh.pa.us
Whole thread Raw
In response to referential integrity violations  ("Shaun W. Kruger" <shaun@linuxhost.cc>)
List pgsql-general
"Shaun W. Kruger" <shaun@linuxhost.cc> writes:
> I'm getting some pretty strange results when doing a mass
> create of my database structure.  I get the following when
> it goes to create the foreign keys.  I just can't figure out
> why it is that half of them complain and the other half don't.

> ERROR:  groupidfk referential integrity violation - key
> referenced from users not found in groups

These are not syntax errors, they are complaints about your data --- ie,
there are rows in the tables that fail to meet the proposed foreign-key
constraint (there is no matching row in the referenced table).

I believe CVS tip has code in it to actually show the offending data
values, but right now you have to find the bad rows the hard way.
A SELECT ... WHERE NOT EXISTS ... kind of query should help.

            regards, tom lane

pgsql-general by date:

Previous
From: Ron Snyder
Date:
Subject: error restoring large objects during pg_restore
Next
From: Dmitry Tkach
Date:
Subject: Re: referential integrity violations