Re: INSERT/SELECT and excessive foreign key checks - Mailing list pgsql-hackers

From Gregory Stark
Subject Re: INSERT/SELECT and excessive foreign key checks
Date
Msg-id 87ejhzsuan.fsf@oxford.xeocode.com
Whole thread Raw
In response to INSERT/SELECT and excessive foreign key checks  (Lodewijk Voege <lvoege@gmail.com>)
Responses Re: INSERT/SELECT and excessive foreign key checks
List pgsql-hackers
"Lodewijk Voege" <lvoege@gmail.com> writes:

> I hacked up a patch that handles these two cases:
>   - for such an INSERT/SELECT, check constant FKs only once.

This sounds like a clever idea. It seems the abstraction violation is worth it
to me.

>   - for an INSERT/SELECT from/to the same table, don't check FKs that are
>     carried over as is at all. (it'd be nice to extend this to fields that
>     have the same FK constraint, rather than the current patch' strict
>     same-table, same-field condition)

I'm not sure this is safe. It means you're not locking the target row. If
someone else comes along and deletes both the original source record and the
target record before you've gotten around to inserting the new record...

--  Gregory Stark EnterpriseDB          http://www.enterprisedb.com


pgsql-hackers by date:

Previous
From: Lodewijk Voege
Date:
Subject: INSERT/SELECT and excessive foreign key checks
Next
From: Andrew Dunstan
Date:
Subject: Re: INSERT/SELECT and excessive foreign key checks