Re: DatabaseMetada.supportOpenCursorsAcrossCommit() return

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: "Dario V(dot) Fassi" <software(at)sistemat(dot)com(dot)ar>
Cc: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: DatabaseMetada.supportOpenCursorsAcrossCommit() return
Date: 2004-07-18 01:21:40
Message-ID: 40F9D0A4.2050401@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Dario V. Fassi wrote:
> I believe that this methods return wrong information.:
>
> DatabaseMetada.supportOpenCursorsAcrossCommit() return false /
> would return TRUE
> DatabaseMetada.supportOpenCursorsAcrossRollBack() return false /
> would return TRUE
>
> Code like this was user to say that.
>
> rs = executeQuery( ... );
> while ( rs.next() ) {
> con.rollback();
> con.commit();
> System.err.println( n++ ) ;
> }
>
> Count all the rows in the result set.

The metadata is correct -- the code you suggest above will fail if the
driver decides to use a resultset backed by a cursor. If it doesn't
decide to use a cursor, it'll work, but you can't rely on that behaviour
for all queries.

The right way to support this is to use JDBC3's holdable resultsets and
make the driver use a WITH HOLD cursor in that case.

It occurs to me that we can support holdable resultsets already by
disabling use of cursors when they are in use (along the lines of what
we do for scrollable resultsets) but I'm not convinced that's the best
thing to do -- better to implement proper cursor support instead.

-O

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Andrew Lazarus 2004-07-18 02:00:38 Re: [ADMIN] Migrate postgres databases from SQL_ASCII to UNICODE
Previous Message Dario V. Fassi 2004-07-18 00:25:24 DatabaseMetada.supportOpenCursorsAcrossCommit() return wrong information.