Re: WARNING on setAutoCommit

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Barry Lind <blind(at)xythos(dot)com>
Cc: Daichi Ueura <daichi(at)lifeflow(dot)jp>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: WARNING on setAutoCommit
Date: 2003-03-19 04:05:34
Message-ID: 200303190405.h2J45ZI05219@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc


I am working on a fix for this bug right now.

---------------------------------------------------------------------------

Barry Lind wrote:
> Daichi,
>
> What you are reporting is a bug in the server. The "select 1" should
> start a new transaction and doesn't and that has already been reported
> as a bug on the pgsql-hackers mail list.
>
> Your suggested work around of the server bug is a good suggestion. I
> will implement this workaround in the driver.
>
> thanks,
> --Barry
>
>
> Daichi Ueura wrote:
> > Hi,
> >
> > The following warning is shown on postgres log when you use
> > JDBC driver; Build 108, for PostgreSQL 7.3.x.
> >
> > This is the server condition I use:
> > ----------------------------------------
> > PostgreSQL 7.3.2
> > JDBC pg73jdbc3.jar(Build 108)
> > J2SE 1.4.1_01
> > RedHatLinux 7.2
> > ----------------------------------------
> >
> > When "auto commit" is set true, and I run Connection.setAutoCommit(false)
> > command in JDBC program, the following warning is shown on the PostgreSQL log;
> >
> > WARNING: COMMIT: no transaction in progress
> >
> > Because of the warning, I looked at
> > org.postgresql.jdbc1.AbstractJdbc1Connection#setAutoCommit(), and this program
> > was written as follows;
> >
> > if (this.autoCommit == autoCommit)
> > return;
> > if (autoCommit)
> > {
> > if (haveMinimumServerVersion("7.3"))
> > {
> > //We do the select to ensure a transaction is in process
> > //before we do the commit to avoid warning messages
> > //from issuing a commit without a transaction in process
> > execSQL("select 1; commit; set autocommit = on;");
> > }
> > else
> > {
> > execSQL("end");
> > }
> > }
> >
> > At the command line; execSQL("select 1; commit; set autocommit = on;");,
> > the program must finish and not record "warning" in the log even though
> > the program processes either during or at the end of the transaction.
> > As a matter of fact, the warning appears when the program runs "commit;."
> > The program doesn't begin a new transaction even though "select 1;"
> > has been executed,
> >
> > I think if we change the command as follows,
> >
> > execSQL("select 1;");
> > execSQL("commit; set autocommit = on;");
> >
> > we can finish the transaction without the warning.
> >
> > ?
> > ? Daichi Ueura
> > ?
> > ? Hiroshima City Univ, Department of Intelligent Systems.
> > ? e-mail: (Private) daichi(at)lifeflow(dot)jp
> > ? : (Office) daichi(at)neu(dot)co(dot)jp
> > ? : (Univ) g23010(at)cr(dot)info(dot)hiroshima-cu(dot)ac(dot)jp
> > ?
> > ?
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 6: Have you searched our list archives?
> >
> > http://archives.postgresql.org
> >
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Tom Lane 2003-03-19 05:53:42 Re: Follow-up OpenOffice and Postgres 7.3.2
Previous Message Barry Lind 2003-03-19 04:03:47 Re: Sun J2SE 1.4 + postgresql-jdbc3-7.3.jar + Postgresql 7.2.1