bug in the jdbc driver for postgress 7.0 (ResultSet.java)

Started by Travis Baueralmost 26 years ago2 messagesbugs
Jump to latest
#1Travis Bauer
trbauer@indiana.edu

I think I've found a bug in how the jdbc driver (JDBC2) numbers the rows
in a result set. According to Sun's documentation for the ResultSet
interface, the rows in a result set should be numbered starting with
1. However, the ResultSet.java's first() routine set's current_row to
0. The odd thing is that beforeFirst() also sets current_row to 0, it
just does not load this_row. The bug manifests itself as such:

given ResultSet rs containing two rows:

rs.last();
System.out.println("Last id is: "+rs.getRow());
rs.first();
System.out.println("First id is: "+rs.getRow());

produces the output:

Last id is: 1
First id is: 0

I think the easiest fix would be to change getRow() so that it returns
current_row+1, and change beforeFirst so that it sets current_row to
-1. I'm not sure what other changes need to be made, but since the JDBC
driver does not allow one to refer directly to row numbers, I can't think
of any other changes offhand.

Or am I all wet and this is not a bug? Please respond to me directly, as
I'm not a member of this list.

----------------------------------------------------------------
Travis Bauer | CS Grad Student | IU |www.cs.indiana.edu/~trbauer
----------------------------------------------------------------

#2Bruce Momjian
bruce@momjian.us
In reply to: Travis Bauer (#1)
Re: bug in the jdbc driver for postgress 7.0 (ResultSet.java)

This fix will appear in 7.01, and is in tonight's snapshot. Please let
us know if that does not fix it.

I think I've found a bug in how the jdbc driver (JDBC2) numbers the rows
in a result set. According to Sun's documentation for the ResultSet
interface, the rows in a result set should be numbered starting with
1. However, the ResultSet.java's first() routine set's current_row to
0. The odd thing is that beforeFirst() also sets current_row to 0, it
just does not load this_row. The bug manifests itself as such:

given ResultSet rs containing two rows:

rs.last();
System.out.println("Last id is: "+rs.getRow());
rs.first();
System.out.println("First id is: "+rs.getRow());

produces the output:

Last id is: 1
First id is: 0

I think the easiest fix would be to change getRow() so that it returns
current_row+1, and change beforeFirst so that it sets current_row to
-1. I'm not sure what other changes need to be made, but since the JDBC
driver does not allow one to refer directly to row numbers, I can't think
of any other changes offhand.

Or am I all wet and this is not a bug? Please respond to me directly, as
I'm not a member of this list.

----------------------------------------------------------------
Travis Bauer | CS Grad Student | IU |www.cs.indiana.edu/~trbauer
----------------------------------------------------------------

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026