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

From Oliver Jowett
Subject Re: JDBC gripe list (the autocommit subthread)
Date
Msg-id AANLkTi=eWSrsEJJJcXRcmO31=u2r8DBOgBoguaX_scbT@mail.gmail.com
Whole thread Raw
In response to Re: JDBC gripe list (the autocommit subthread)  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
List pgsql-jdbc
On 1 April 2011 12:06, Kevin Grittner <Kevin.Grittner@wicourts.gov> wrote:
> Oliver Jowett <oliver@opencloud.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

pgsql-jdbc by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Re: JDBC gripe list (the autocommit subthread)
Next
From: "A.M."
Date:
Subject: Re: JDBC gripe list (the autocommit subthread)