pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Forest Wilkinson <fspam@home.com>
To: Michael Fork <mfork@toledolink.com>
Cc: Jan Wieck <janwieck@yahoo.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: unreferenced primary keys: garbage collection
Date: Wed, 24 Jan 2001 13:09:08 -0800
Message-ID: <3rgu6ts8hvj5bonhuvusqdajogv4uc4f17@4ax.com> (raw)
In-Reply-To: <Pine.BSI.4.21.0101240021140.29537-100000@glass.toledolink.com>
References: <d1ms6tgl0kupjbomqgff971e3mljkfoara@4ax.com>
	<Pine.BSI.4.21.0101240021140.29537-100000@glass.toledolink.com>

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




view thread (7+ messages)

Message-ID: <3rgu6ts8hvj5bonhuvusqdajogv4uc4f17@4ax.com>
Permalink:  ../3rgu6ts8hvj5bonhuvusqdajogv4uc4f17@4ax.com/
Also on:    postgresql.org/message-id/3rgu6ts8hvj5bonhuvusqdajogv4uc4f17@4ax.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: fspam@home.com, mfork@toledolink.com, janwieck@yahoo.com
  Subject: Re: unreferenced primary keys: garbage collection
  In-Reply-To: <3rgu6ts8hvj5bonhuvusqdajogv4uc4f17@4ax.com>
  References: <d1ms6tgl0kupjbomqgff971e3mljkfoara@4ax.com> <Pine.BSI.4.21.0101240021140.29537-100000@glass.toledolink.com> <3rgu6ts8hvj5bonhuvusqdajogv4uc4f17@4ax.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox