Question about RI checks - Mailing list pgsql-hackers

From Nick Barnes
Subject Question about RI checks
Date
Msg-id CAG+WGGnMCPzXhMxOCx9b887xbFMY-=n0NOSjoaHNknsnuSFKSg@mail.gmail.com
Whole thread
Responses Re: Question about RI checks
List pgsql-hackers
One of the queries in ri_triggers.c has be a little baffled.

For (relatively) obvious reasons, a FK insert triggers a SELECT 1 FROM pk_rel ... FOR KEY SHARE.
For not-so-obvious reasons, a PK delete triggers a SELECT 1 FROM fk_rel ... FOR KEY SHARE.

I can't see what the lock on fk_rel achieves. Both operations are already contending for the lock on the PK row, which seems like enough to cover every eventuality.

And even if the lock serves a purpose, KEY SHARE is an odd choice, since the referencing field is, in general, not a "key" in this sense.

Can anyone provide an explanation / counterexample?

pgsql-hackers by date:

Previous
From: Stephen Frost
Date:
Subject: Re: Review of GetUserId() Usage
Next
From: Robert Haas
Date:
Subject: Re: Hide 'Execution time' in EXPLAIN (COSTS OFF)