Re: [PATCHES] Continue transactions after errors in psql

From: "Michael Paesold" <mpaesold(at)gmx(dot)at>
To: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
Cc: "PostgreSQL-development" <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: [PATCHES] Continue transactions after errors in psql
Date: 2005-04-25 17:51:31
Message-ID: 01ad01c549bf$6aa3ad60$0f01a8c0@zaphod
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Bruce Momjian wrote:

> Greg Sabino Mullane wrote:
>> > The SQL-Standard itself says that errors inside transactions should
>> only
>> > rollback the last statement, if possible. So why is that not
>> > implemented in
>> > PostgreSQL? What I read from past discussions here, is because it's
>> > just
>> > unsave and will lead to data-garbage if you aren't very careful.
>>
>> That's a good point: if that is indeed what the standard says, we should
>> probably see about following it. Rolling back to the last savepoint seems
>> a reasonable behavior to me.
>
> OK, so we need to make a decision. Right now I have Greg's patch that
> is enabled by "\set ON_ERROR_ROLLBACK on":
>
> 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
>
> The question is what to make the default:
>
> disable it by default for all sessions (current patch)
> enable it by default only for interactive sessions, like AUTOCOMMIT
> enable it by default for all sessions (breaks too many apps)
> add a third mode called 'ttyonly' and figure out a default

My vote:
1) disable it by default for all sessions

2) enable it with \set (can be set in .psqlrc), but provide a way so it only
works with interactive commands, either always, or something like
\set ON_ERROR_ROLLBACK interactive

Best Regards,
Michael Paesold

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2005-04-25 18:49:01 Re: [HACKERS] Bad n_distinct estimation; hacks suggested?
Previous Message Brent Verner 2005-04-25 17:32:30 [proposal] protocol extension to support loadable stream filters

Browse pgsql-patches by date

  From Date Subject
Next Message Hans-Jürgen Schönig 2005-04-25 19:22:21 Re: Constant WAL replay
Previous Message Michael Paesold 2005-04-25 17:30:24 Re: Continue transactions after errors in psql