pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Quartz <quartz12h@yahoo.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: JDBC gripe list (the autocommit subthread)
Date: Wed, 6 Apr 2011 09:07:28 -0700 (PDT)
Message-ID: <678556.87919.qm@web33208.mail.mud.yahoo.com> (raw)
In-Reply-To: <AANLkTi=Bcs6ZoWfE9tbA0RpSVjD3j4G98rKXXPs1fUcE@mail.gmail.com>

I posted that the remaining question is not about how and why it is used.
It is about the fact that with autocommit=true, when a the first statement to fail is in the middle of a batch, all previous statement are supposed to be completed and NOT rolled back (regardless of the other statement at or after the failed statement).

> (a) it would be quite a lot of extra work to wrap each
> statement in a separate transaction (we'd have to send explicit BEGIN/END
> around each statement execution;

> (c) usually batch updates are there for performance
> reasons, which is at odds with creating a separate transaction for each
> batched statement;


It is not about performance. It is about behavior.


> (d) the current behavior *is* allowed by the
> specification.

Not it isn't. (see top of message.)





--- On Thu, 3/31/11, Oliver Jowett <oliver@opencloud.com> wrote:

> From: Oliver Jowett <oliver@opencloud.com>
> Subject: Re: [JDBC] JDBC gripe list (the autocommit subthread)
> To: "Quartz" <quartz12h@yahoo.com>
> Cc: "Kevin Grittner" <Kevin.Grittner@wicourts.gov>, pgsql-jdbc@postgresql.org
> Received: Thursday, March 31, 2011, 6:32 PM
> On 1 April 2011 10:34, Quartz <quartz12h@yahoo.com>
> wrote:
> 
> > You have been defending all that long that most use
> the autocommit=false when using batches. Then they won't
> break....!
> >
> > Besides that's what release notes are for. And I dare
> say, if they expected a transaction when using a batch with
> autocommit=true, it about time they learn their mistake.
> JDBC api is a contract. Can't make exception for postgres.
> 
> The JDBC spec says that the behavior of executeBatch()
> with
> autocommit=true is implementation defined, and specifically
> warns
> against using it with autocommit on.
> 
> I don't see any problems with the driver's current
> behavior:
> 
> (a) it would be quite a lot of extra work to wrap each
> statement in a
> separate transaction (we'd have to send explicit BEGIN/END
> around each
> statement execution;
> (b) the current behavior is consistent with how multiple
> statement
> execution works elsewhere in the driver, where if you
> execute "SELECT
> a; SELECT b" as a statement with autocommit=true then the
> two queries
> run in a single transaction;
> (c) usually batch updates are there for performance
> reasons, which is
> at odds with creating a separate transaction for each
> batched
> statement;
> (d) the current behavior *is* allowed by the
> specification.
> 
> The problem is with your code relying on particular
> behavior of
> executeBatch() + autocommit, which the spec explicitly
> warns is
> implementation-defined behavior that you shouldn't rely
> on.
> 
> Oliver
> 



view thread (21+ messages)  latest in thread

Message-ID: <678556.87919.qm@web33208.mail.mud.yahoo.com>
Permalink:  ../678556.87919.qm@web33208.mail.mud.yahoo.com/
Also on:    postgresql.org/message-id/678556.87919.qm@web33208.mail.mud.yahoo.com

 · 

reply

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: quartz12h@yahoo.com
  Subject: Re: JDBC gripe list (the autocommit subthread)
  In-Reply-To: <678556.87919.qm@web33208.mail.mud.yahoo.com>
  References: <AANLkTi=Bcs6ZoWfE9tbA0RpSVjD3j4G98rKXXPs1fUcE@mail.gmail.com> <678556.87919.qm@web33208.mail.mud.yahoo.com>

* 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