patch: enforce the requirements for scrollable resultsets

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: patch: enforce the requirements for scrollable resultsets
Date: 2004-04-01 09:37:51
Message-ID: 406BE2EF.5040301@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

This patch (against CVS HEAD) adds enforcement of the requirement that
you're working with a scrollable resultset before calling some methods
(last(), absolute(), etc) of ResultSet. Without this patch, these
methods complete "normally" but can return incorrect data if the
resultset is backed by a cursor. It also adds tests for this behaviour,
and fixes a number of tests and one case in the driver itself that try
to use these methods with the wrong resultset type.

There are also a couple of minor other fixes in related areas that I
made along the way.

Details:

- Add AbstractJdbc2ResultSet.checkScrollable() that throws if the
resultset is not scrollable, call it from appropriate methods.
- Allow ResultSet.absolute(0) per the spec: it should position before
the start of the resultset, not throw an exception. Add a test for this
case.
- Check the ResultSet.setFetchDirection() parameter and throw an
exception if it's not one of the allowed values.
- Use rs.next() not rs.first() in AbstractJdbc2ResultSet.refreshRow(),
as the resultset in use is not scrollable.
- If a SQLException is caught in AbstractJdbc2ResultSet.refreshRow(),
rethrow it unchanged to preserve the stack trace.
- Fix multiple cases in ResultSetTest where we were expecting a
scrollable resultset but didn't ask for one.
- Add a testcase for throwing an exception when inappropriate methods
are called on TYPE_FORWARD_ONLY resultsets.

-O

Attachment Content-Type Size
pgjdbc_enforce_scrollable_requirements.txt text/plain 8.5 KB

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Hans-Jürgen Schönig 2004-04-01 09:52:53 Re: very interesting JDBC problem ...
Previous Message Oliver Jowett 2004-04-01 08:54:22 testGetTimeZone failures using CVS driver