Skip to content

Commit 2cfb14e

Browse files
committed
Fix the off by one errors in ResultSet from 6.5.3, and more.
I'm including a diff of postgresql-7.0/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java. I've clearly marked all the fixes I did. Would *someone* who has access to the cvs please put this in? Joseph Shraibman
1 parent a28f117 commit 2cfb14e

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -797,12 +797,14 @@ public boolean absolute(int index) throws SQLException
797797

798798
public void afterLast() throws SQLException
799799
{
800-
current_row = rows.size() + 1;
800+
if (rows.size() > 0)
801+
current_row = rows.size();
801802
}
802803

803804
public void beforeFirst() throws SQLException
804805
{
805-
current_row = 0;
806+
if (rows.size() > 0)
807+
current_row = -1;
806808
}
807809

808810
public void cancelRowUpdates() throws SQLException
@@ -946,7 +948,7 @@ public Ref getRef(int i) throws SQLException
946948

947949
public int getRow() throws SQLException
948950
{
949-
return current_row;
951+
return current_row + 1;
950952
}
951953

952954
// This one needs some thought, as not all ResultSets come from a statement
@@ -967,24 +969,24 @@ public void insertRow() throws SQLException
967969

968970
public boolean isAfterLast() throws SQLException
969971
{
970-
throw org.postgresql.Driver.notImplemented();
972+
return (current_row >= rows.size() && rows.size() > 0);
971973
}
972-
974+
973975
public boolean isBeforeFirst() throws SQLException
974976
{
975-
throw org.postgresql.Driver.notImplemented();
977+
return (current_row < 0 && rows.size() > 0);
976978
}
977-
979+
978980
public boolean isFirst() throws SQLException
979981
{
980-
throw org.postgresql.Driver.notImplemented();
982+
return (current_row == 0 && rows.size() >= 0);
981983
}
982-
984+
983985
public boolean isLast() throws SQLException
984986
{
985-
throw org.postgresql.Driver.notImplemented();
987+
return (current_row == rows.size() -1 && rows.size() > 0);
986988
}
987-
989+
988990
public boolean last() throws SQLException
989991
{
990992
if (rows.size() <= 0)

0 commit comments

Comments
 (0)