Re: Why are 'select1; commit' run along with 'set autocomm

From: "Mushran, Vrinda" <Vrinda(at)netopia(dot)com>
To: 'Oliver Jowett' <oliver(at)opencloud(dot)com>
Cc: "'pgsql-jdbc(at)postgresql(dot)org'" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Why are 'select1; commit' run along with 'set autocomm
Date: 2003-10-02 21:19:55
Message-ID: D778DFCC08F53A41B4895A6598889666026454D1@mxca1.netopia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

> NOTE: If this method is called during a transaction, the transaction is
committed.

Thanks for pointing that out. My fault for not reading the documentation
well.

Vrinda

-----Original Message-----
From: Oliver Jowett [mailto:oliver(at)opencloud(dot)com]
Sent: Thursday, October 02, 2003 1:54 PM
To: Mushran, Vrinda
Cc: 'pgsql-jdbc(at)postgresql(dot)org'
Subject: Re: [JDBC] Why are 'select1; commit' run along with 'set
autocommit=on' when turning autocommit on again on a jdbc connection

On Wed, Oct 01, 2003 at 09:23:07AM -0700, Mushran, Vrinda wrote:

> Why does the postgres jdbc driver execute 'select 1' and 'commit' followed
> by 'set autocommit = on'? Setting autocommit on again should just result
in
> 'set autocommit=on' statement to be executed, not 'select 1' and 'commit'.
> User would not expect commit to be issued by just turning autocommit on
and
> thus its execution here alarms me.

Committing the existing transaction is correct behaviour. The JDBC javadoc
for setAutoCommit includes this:

NOTE: If this method is called during a transaction, the transaction is
committed.

Whether committing when the existing transaction hasn't done any work is
"correct" seems to be a non-issue since it'll always be harmless by
definition.

-O

Browse pgsql-jdbc by date

  From Date Subject
Next Message balaji 2003-10-03 02:37:38 Postgresql 7.3.4 download problem
Previous Message Oliver Jowett 2003-10-02 20:53:47 Re: Why are 'select1; commit' run along with 'set autocommit=on' when turning autocommit on again on a jdbc connection