Re: Continue transactions after errors in psql

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Greg Sabino Mullane <greg(at)turnstep(dot)com>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: Continue transactions after errors in psql
Date: 2005-04-25 16:34:00
Message-ID: 200504251634.j3PGY0Z11527@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Greg Sabino Mullane wrote:
[ There is text before PGP section. ]
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
> Finally had a chance to sit down at look at this afresh, and I'm
> pretty sure I've got all the kinks worked out this time. Apologies
> for not attaching, but my mail system is not working well enough
> at the moment. So, please try to break this patch:
>
> http://www.gtsm.com/pg/psql_error_recovery.diff

I have modified Greg's patch to fit in better with the existing psql
code. I changed the command to \set ON_ERROR_ROLLBACK, which seems to
fit better. Here is an illustration of its use (patch attached):

test=> BEGIN;
BEGIN
test=> lkjasdf;
ERROR: syntax error at or near "lkjasdf" at character 1
LINE 1: lkjasdf;
^
test=> SELECT 1;
ERROR: current transaction is aborted, commands ignored until end of
transaction block
test=> COMMIT;
ROLLBACK
test=> \set ON_ERROR_ROLLBACK on
test=> BEGIN;
BEGIN
test=> lkjasdf;
ERROR: syntax error at or near "lkjasdf" at character 1
LINE 1: lkjasdf;
^
test=> SELECT 1;
?column?
----------
1
(1 row)

test=> COMMIT;
COMMIT

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 4.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2005-04-25 16:39:37 Re: Continue transactions after errors in psql
Previous Message Dave Held 2005-04-25 16:15:22 Re: [PERFORM] Bad n_distinct estimation; hacks suggested?

Browse pgsql-patches by date

  From Date Subject
Next Message Alvaro Herrera 2005-04-25 16:39:37 Re: Continue transactions after errors in psql
Previous Message Bruce Momjian 2005-04-25 04:40:10 Re: Cleaning up unreferenced table files