Re: JDBC gripe list (the autocommit subthread)

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: Quartz <quartz12h(at)yahoo(dot)com>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: JDBC gripe list (the autocommit subthread)
Date: 2011-03-31 23:15:45
Message-ID: AANLkTi=eWSrsEJJJcXRcmO31=u2r8DBOgBoguaX_scbT@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On 1 April 2011 12:06, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov> wrote:
> Oliver Jowett <oliver(at)opencloud(dot)com> wrote:
>
>> (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;
>
> I did not know that.  Is that required by spec?

Depending on how you read the javadoc, yes:

---
void setAutoCommit(boolean autoCommit)
throws SQLException
[...]
The commit occurs when the statement completes. The time when the
statement completes depends on the type of SQL Statement:
[...]
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 don't think we strictly follow that - as the commit is driven by the
server, we may commit before all resultsets are closed, in general -
but the intent is the same, a single JDBC statement that does multiple
things executes in one transaction, not several.

It's also consistent with how the v2 protocol works.

> It definitely doesn't happen in psql:

psql does things differently, but psql is not a JDBC driver..

Oliver

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message A.M. 2011-03-31 23:21:10 Re: JDBC gripe list (the autocommit subthread)
Previous Message Kevin Grittner 2011-03-31 23:06:17 Re: JDBC gripe list (the autocommit subthread)