Re: JDBC gripe list (the autocommit subthread) - Mailing list pgsql-jdbc

From Quartz
Subject Re: JDBC gripe list (the autocommit subthread)
Date
Msg-id 678556.87919.qm@web33208.mail.mud.yahoo.com
Whole thread Raw
In response to Re: JDBC gripe list (the autocommit subthread)  (Oliver Jowett <oliver@opencloud.com>)
List pgsql-jdbc
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
previousstatement are supposed to be completed and NOT rolled back (regardless of the other statement at or after the
failedstatement). 

> (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
>

pgsql-jdbc by date:

Previous
From: Quartz
Date:
Subject: Re: JDBC gripe list (the autocommit subthread)
Next
From: Quartz
Date:
Subject: Re: JDBC gripe list (the autocommit subthread)