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

RE: foreign key check makes a big LOCK

From: "Mikheev, Vadim" <vmikheev(at)SECTORBASE(dot)COM>
To: "'sygma(at)marr(dot)irisz(dot)hu'" <sygma(at)marr(dot)irisz(dot)hu>, "'pgsql-bugs(at)postgresql(dot)org'" <pgsql-bugs(at)postgresql(dot)org>
Cc: "'janwieck(at)Yahoo(dot)com'" <janwieck(at)Yahoo(dot)com>, "'pgsql-hackers(at)postgresql(dot)org'" <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: foreign key check makes a big LOCK
Date: 2000-12-05 20:59:50
Message-ID: 8F4C99C66D04D4118F580090272A7A234D31CC@sectorbase1.sectorbase.com (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-hackers
> Short Description
> foreign key check makes a big LOCK
> 
> Long Description
> in: src/backend/utils/adt/ri_triggers.c
> 
> RI_FKey_check(), RI_FKey_noaction_upd(), RI_FKey_noaction_del(), etc..
> checking the referential with SELECT FOR UPDATE.
> 
> After BEGIN TRANSACTION: the INSERT/DELETE/UPDATE calling 
> foreign-key checks, and the SELECT FOR UPDATE locking ALL 
> matched rows in referential table.
> 
> I modify ri_triggers.c (remove "FOR UPDATE"). This working.. 
> but is correct?

It's not. If one transaction inserts FK 1 and another one deletes
PK 1 at the same time both will succeed.

RI triggers should perform dirty reads (and test if returned tuples
alive/dead/being updated by concurrent transaction) instead of
SELECT FOR UPDATE but dirty reads are not implemented, yet.

Vadim

pgsql-hackers by date

Next:From: The Hermit HackerDate: 2000-12-05 21:03:38
Subject: Re: beta testing version
Previous:From: Camm MaguireDate: 2000-12-05 20:53:42
Subject: Foreign key references to non-primary key columns

pgsql-bugs by date

Next:From: pgsql-bugsDate: 2000-12-05 23:29:17
Subject: FreeBSD 4.2 readlib issue
Previous:From: Tom LaneDate: 2000-12-05 20:42:54
Subject: Re: Rules with Conditions: Still Doesn't Work (Bug Rpt)

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