From: | Oliver Jowett <oliver(at)opencloud(dot)com> |
---|---|
To: | Quartz <quartz12h(at)yahoo(dot)com> |
Cc: | Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: JDBC gripe list (the autocommit subthread) |
Date: | 2011-03-31 22:32:42 |
Message-ID: | AANLkTi=Bcs6ZoWfE9tbA0RpSVjD3j4G98rKXXPs1fUcE@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
On 1 April 2011 10:34, Quartz <quartz12h(at)yahoo(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Kevin Grittner | 2011-03-31 23:06:17 | Re: JDBC gripe list (the autocommit subthread) |
Previous Message | Oliver Jowett | 2011-03-31 22:24:03 | Re: Cannot open connection while insert much data. |