From: Csaba Nagy <nagy@ecircle-ag.com>
To: j.random.programmer <javadesigner@yahoo.com>
Cc: pg@fastcrypt.com
Cc: Postgres JDBC <pgsql-jdbc@postgresql.org>
Subject: Re: Weird behavior in transaction handling (Possible bug ?)
Date: Fri, 14 Jan 2005 17:57:22 +0100
Message-ID: <1105721842.14493.52.camel@localhost.localdomain> (raw)
In-Reply-To: <20050114162956.91766.qmail@web14227.mail.yahoo.com>
References: <20050114162956.91766.qmail@web14227.mail.yahoo.com>
Dear random programmer,
I understand your grief perfectly, and agree completely, I've been
there. But I think the spec is at least ambiguous about this matter, if
not leaning towards the postgres behavior of rolling back everything on
an error. And I don't believe commit fails silently, it should give you
an error.
The demand for the convenience of deciding after a failed query to
continue or not comes from other DB engines readily implementing it
(notably Oracle). So I would expect you're coming from an oracle DB
experience...
In any case, if you want similar behavior in postgres > 8.0, you could
use a savepoint before the auxialiary query and roll back to it on an
error. Then the result of the queries before the savepoint can be
committed.
Please note that setting a savepoint in postgres is not nearly free, so
be careful how often you do it.
HTH,
Csaba.
Fri, 2005-01-14 at 17:29, j.random.programmer wrote:
> > With postgres once an error occurs in a transaction
> block you need
> > to rollback. None of the transaction will commit.
> >
> > This behaviour makes sense as it assumes that the
> transaction block
> > is atomic and it should all succeed or all fail.
>
>
> This is VERY counter-intuitive. I can have really
> important data
> for say 5 tables which has committed properly but at
> the 6th
> insert into a non-important auxillary table, I may
> encounter a
> transient exception. I still want to be able to commit
> my data.
>
> There are many similar scenarios such as the above,
> right ?
>
> As a programmer, shouldn't it be upto me to decide
> when to
> commit and when to rollback ? Is this even within
> spec ? And
> at the very least, commit() should then not fail
> SILENTLY ! (and
> this should be documented).
>
> :-]
>
> Best regards,
>
> --j
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - Helps protect you from nasty viruses.
> http://promotions.yahoo.com/new_mail
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: nagy@ecircle-ag.com, javadesigner@yahoo.com, pg@fastcrypt.com
Subject: Re: Weird behavior in transaction handling (Possible bug ?)
In-Reply-To: <1105721842.14493.52.camel@localhost.localdomain>
References: <20050114162956.91766.qmail@web14227.mail.yahoo.com> <1105721842.14493.52.camel@localhost.localdomain>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox