Re: Continue transactions after errors in psql
Bruce Momjian <pgman@candle.pha.pa.us>
From: Bruce Momjian <pgman@candle.pha.pa.us>
To: Greg Sabino Mullane <greg@turnstep.com>
Cc: pgsql-patches@postgresql.org
Date: 2005-04-25T16:34:00Z
Lists: pgsql-hackers
Attachments
- (unnamed) (text/plain)
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@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073