Re: Does psql use nested transactions?

From: Honza Pazdziora <adelton(at)informatics(dot)muni(dot)cz>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Does psql use nested transactions?
Date: 2004-08-18 06:39:19
Message-ID: 20040818063919.GB14034@anxur.fi.muni.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Aug 17, 2004 at 02:56:19PM -0400, Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > Doing it only for interactive mode seems too error-prone to me (it works
> > in psql, but not from my script).
>
> You're missing the point: a script cannot safely work this way. A human
> typing at the terminal can notice that his command failed and react to
> that, but a psql script cannot.

It is not just a typo that you make in the SQL command. You often need
to do

insert into table which has primary key
if the insert failed, do update of the existing record

It should be upto the application to decide if the failed insert
should lead to abortion of the transaction, or if it should be
silently ignored and based on the return value of the insert proceed
with update.

--
------------------------------------------------------------------------
Honza Pazdziora | adelton(at)fi(dot)muni(dot)cz | http://www.fi.muni.cz/~adelton/
.project: Perl, mod_perl, DBI, Oracle, large Web systems, XML/XSL, ...
Only self-confident people can be simple.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marius Andreiana 2004-08-18 06:44:39 Re: [HACKERS] [ADMIN] SRPM for 8.0.0 beta?
Previous Message Oliver Jowett 2004-08-18 06:28:23 Re: 7.4.3 & 8.0.0beta1 + Solaris 9: default pg_hba.conf