Re: Continue transactions after errors in psql - Mailing list pgsql-patches

From Robert Treat
Subject Re: Continue transactions after errors in psql
Date
Msg-id 200501280148.44060.xzilla@users.sourceforge.net
Whole thread Raw
In response to Continue transactions after errors in psql  (Greg Sabino Mullane <greg@turnstep.com>)
Responses Re: Continue transactions after errors in psql  (Christopher Kings-Lynne <chriskl@familyhealth.com.au>)
Re: Continue transactions after errors in psql  ("Greg Sabino Mullane" <greg@turnstep.com>)
List pgsql-patches
On Tuesday 25 January 2005 22:07, Greg Sabino Mullane wrote:
> Attached is a patch that takes advantage of savepoints to enable
> transactions to continue even after errors in psql. The name of it
> is \reseterror, and it is off by default. It's backwards compatible,
> and allows things like this to work on 8.0 and up servers:
>
> \reseterror
> BEGIN;
> DELETE FROM foobar;
> INSERT INTO foobar(a) VALUES(1);
> ISNER INTO foobar(a) VALUES(2);
> INSERT INTO foobar(a) VALUES(3);
> COMMIT;
>
> Doing a SELECT(a) FROM foobar will show two values, 1 and 3. This
> is a great help for those of us that tend to type typos into our
> psql session, and end up cursing as we have to restart our current
> transaction. :)

I've been testing this patch and found the following bug:
test=# \reseterror
Reset error is on.
test=# begin;
BEGIN
test=# select * from t;
 c
---
 1
(1 row)
test=# delete from t;
DELETE 1
test=# select * from tt;
ERROR:  relation "tt" does not exist
ERROR:  relation "tt" does not exist
test=# select * from t;
 c
---
(0 rows)
test=# commit;
COMMIT
ERROR:  RELEASE SAVEPOINT may only be used in transaction blocks
ERROR:  RELEASE SAVEPOINT may only be used in transaction blocks


I've attached a revised patch which fixes the problem, however I'm sure there
is a better way.  Thanks to Neil for putting up with me on irc :-)

--
Robert Treat
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL

Attachment

pgsql-patches by date:

Previous
From: "Ed L."
Date:
Subject: Re: dbsize patch
Next
From: Christopher Kings-Lynne
Date:
Subject: Re: Continue transactions after errors in psql