Skip site navigation (1) Skip section navigation (2)

Re: bad data with Foreign Key constraint

From: "Lee Wu" <Lwu(at)mxlogic(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-admin(at)postgresql(dot)org>
Subject: Re: bad data with Foreign Key constraint
Date: 2004-06-21 18:55:28
Message-ID: (view raw or whole thread)
Lists: pgsql-admin
Hi Tom,

We do not have rules on the tables. 

I find manipulating PG dictionary can allow violating RI data to enter


-----Original Message-----
From: pgsql-admin-owner(at)postgresql(dot)org
[mailto:pgsql-admin-owner(at)postgresql(dot)org] On Behalf Of Tom Lane
Sent: Friday, June 18, 2004 4:36 PM
To: Lee Wu
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: [ADMIN] bad data with Foreign Key constraint 

"Lee Wu" <Lwu(at)mxlogic(dot)com> writes:
> I have found that there are some foreign keys in our detail tables
> there are not primary keys in master tables.
> Yes, we have FK constraints on detail tables.
> I could not think how it can happen. PG (7.3.2) does not have "disable
> constraint" like Oracle, does it?

Hm, you don't have any weird rules on these tables do you?  I see
the following in the 7.3.5 commit logs:

2003-10-30 22:57  wieck

	* src/: backend/utils/adt/ri_triggers.c,
	test/regress/sql/foreign_key.sql (REL7_3_STABLE): Fix for
	referential integrity violation when a qualified ON INSERT rule
	split the query into one INSERT and one UPDATE where the UPDATE
	then hit's the just created row without modifying the key fields
	again.	In this special case, the new key slipped in totally

Also, I find the following in 7.3.3:

2003-03-27 09:33  tgl

	* src/: backend/commands/trigger.c, backend/executor/execMain.c,
	include/commands/trigger.h (REL7_3_STABLE): GetTupleForTrigger
	use outer transaction's command counter for time qual checking,
	GetCurrentCommandId.  Per test case from Steve Wolfe.

I don't recall the implications of this one in detail anymore, but I
think it was triggered by updates inside functions.  You might want to
check the archives from back then to see if what Steve was doing looks
anything like stuff your own apps do.

			regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org

pgsql-admin by date

Next:From: Thomas F. O'ConnellDate: 2004-06-21 21:57:17
Subject: pg_restore usage
Previous:From: lise chhayDate: 2004-06-21 16:14:43

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group