Re: DatabaseMetada.supportOpenCursorsAcrossCommit() return - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: DatabaseMetada.supportOpenCursorsAcrossCommit() return
Date
Msg-id 40F9D0A4.2050401@opencloud.com
Whole thread Raw
In response to DatabaseMetada.supportOpenCursorsAcrossCommit() return wrong information.  ("Dario V. Fassi" <software@sistemat.com.ar>)
List 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

pgsql-jdbc by date:

Previous
From: "Dario V. Fassi"
Date:
Subject: DatabaseMetada.supportOpenCursorsAcrossCommit() return wrong information.
Next
From: "Andrew Lazarus"
Date:
Subject: Re: [ADMIN] Migrate postgres databases from SQL_ASCII to UNICODE