Result Set Cursor Patch

From: Andy Zeneski <jaz(at)ofbiz(dot)org>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Result Set Cursor Patch
Date: 2004-04-30 15:04:27
Message-ID: AC8D227A-9AB7-11D8-A094-000A95DA1A7C@ofbiz.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

I am not sure if this is the right place, or if the pgsql-patches list
is where this should go, since the CVS repositories are now in
different locations, I hoped this would be the right area.

Attached is a patch against the current CVS head for added support for
cursors in result set.

The reason for this patch I needed to iterate over a very large result
set, at first I was using PGSQL 7.3.x and the query crashed each time.
I believe out of memory errors were the cause. Later I realized that
the entire result set was being sent over, this was several millions of
rows.

I upgraded to PGSQL 7.4.2 since I saw it has support for cursors in
result sets, but it didn't work with my code. The problem was, I would
jump to last() and obtain the row for the total count, then jump back
to first() to begin my iteration. When setting the fetch size to 50, it
would only report 50 rows total. The last(), first(), absolute()
methods only looked at the current 'chunk' of rows. I think this may
have been a bug since later it appears that when scrollable was set it
was supposed to ignore the fetch size and grab all rows. This just will
not do.

This patch implements the absolute() method, using the cursor. The code
which checks for scrollable now creates the cursor with the SCROLL
keyword rather then avoiding cursors all together.

The patch passes the entire test suite, and I added a new test to test
absolute positioning. I am happy to answer any questions, and if anyone
sees any problems with the code please let me know. I think this will
be a great addition to PostgreSQL as I am having users switch to MySQL
MaxDB (SAPDB) due to performance problems. This patch solved a good
number of those problems!

Again, let me know if you see anything wrong and I will try to get it
corrected ASAP so this can get included with the next release!

Thanks,

-Andy

Attachment Content-Type Size
pgjdbc-cursor.patch.gz application/x-gzip 5.0 KB

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2004-04-30 15:43:18 Re: Result Set Cursor Patch
Previous Message Oliver Jowett 2004-04-30 11:16:14 Re: number to string conversion