Re: unreferenced primary keys: garbage collection

From: Forest Wilkinson <fspam(at)home(dot)com>
To: Michael Fork <mfork(at)toledolink(dot)com>
Cc: Jan Wieck <janwieck(at)yahoo(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: unreferenced primary keys: garbage collection
Date: 2001-01-24 21:09:08
Message-ID: 3rgu6ts8hvj5bonhuvusqdajogv4uc4f17@4ax.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, 24 Jan 2001 00:26:58 -0500 (EST), Michael Fork wrote:

>One other method is to setup up the foreign keys as ON DELETE RESTRICT,
>then outside of your transaction block issue a DELETE FROM address WHERE
>add_id = 1; If there are still records in the other tables referencing
>this record, it will error out and nothing will happen, however if no
>related records are left, the delete will succeed (you have to do it
>outside of transaction, otherwise I belive it will rollback on the
>error if other rows are found to be referencing the primary key)....

Yes, that's the approach I originally posted. The rollback issue is the
thing I'm complaining about. The code in question gets called from within
a parent function, which uses a single transaction block for all of its
operations. This means that executing a query outside a transaction block
(or within a separate one) is not an option.

I want to be able to tell postgres not to rollback the whole transaction
just because my delete attempt fails. I can think of 3 ways to do this:
1. Allow the delete to fail without throwing a fatal error. (Perhaps a
warning would suffice.)
2. Allow the client to tell postgres not to roll back if a specified query
produces an error.
3. Implement nested transactions.

Forest

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Roberto Bertolusso 2001-01-24 21:29:34 Cannot CREATE INDEX that contains a function
Previous Message Mike Castle 2001-01-24 20:55:52 Re: Problem with Dates