pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-jdbc@postgresql.org
Subject: Re: jdbc spec violation for autocommit=true & addbatch/executeBatch
Date: Tue, 18 Jan 2011 23:45:59 +0100
Message-ID: <ih5577$251$1@dough.gmane.org> (raw)
In-Reply-To: <728504.34967.qm@web33202.mail.mud.yahoo.com>
References: <4D3606CD.7080707@opencloud.com>
	<728504.34967.qm@web33202.mail.mud.yahoo.com>

Quartz, 18.01.2011 22:55:
> This is very sad. The batch never mean transaction. It happens to be
> the supporting fixture for the transaction, but also to avoid
> roundtrips with connection pools and such overhead when not using
> transaction as autocommit=true suggest.

The JDBC Specification (jdbc-4.0-fr-spec.pdf, Chapter 14.1.1) has a little note on this topic:

"auto-commit should always be turned off when batch updates are done.
The commit behavior of executeBatch is always implementation-defined when an error
occurs and auto-commit is true"


I cannot find any clear definition whether the batch should be treated as a single transaction or multiple transactions depending on the state of autocommit.

There is one hint though:

Chapter 10.1

"The Connection attribute auto-commit specifies when to end transactions. Enabling
auto-commit causes a transaction commit after each individual SQL statement as
soon as that statement is complete. The point at which a statement is considered to
be “complete” depends on the type of SQL statement as well as what the application
does after executing it:"

   For Data Manipulation Language (DML) statements such as Insert, Update,
   Delete, and DDL statements, the statement is complete as soon as it has finished
   executing.

   ....

   For CallableStatement objects or for statements that return multiple results,
   the statement is complete when all of the associated result sets have been closed,
   and all update counts and output parameters have been retrieved.


I think the second item (actually the third because I left out one) is interesting. A prepared statement that is using batches might be considered as one that returns multiple results (as it can return multiple update counts).

So according to that note, I would actually say that batched statements _can_ be treated as a single transaction.

Pretty vague though I have to admit.

Regards
Thomas







view thread (10+ messages)  latest in thread

Message-ID: <ih5577$251$1@dough.gmane.org>
Permalink:  ../ih5577$251$1@dough.gmane.org/
Also on:    postgresql.org/message-id/ih5577$251$1@dough.gmane.org

 · 

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: spam_eater@gmx.net
  Subject: Re: jdbc spec violation for autocommit=true & addbatch/executeBatch
  In-Reply-To: <ih5577$251$1@dough.gmane.org>
  References: <4D3606CD.7080707@opencloud.com> <728504.34967.qm@web33202.mail.mud.yahoo.com> <ih5577$251$1@dough.gmane.org>

* 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