Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2cfb14e

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

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
publicvoidafterLast()throwsSQLException
799799
{
800-
current_row =rows.size() +1;
800+
if (rows.size() >0)
801+
current_row =rows.size();
801802
}
802803

803804
publicvoidbeforeFirst()throwsSQLException
804805
{
805-
current_row =0;
806+
if (rows.size() >0)
807+
current_row = -1;
806808
}
807809

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

947949
publicintgetRow()throwsSQLException
948950
{
949-
returncurrent_row;
951+
returncurrent_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
publicbooleanisAfterLast()throwsSQLException
969971
{
970-
throworg.postgresql.Driver.notImplemented();
972+
return (current_row >=rows.size() &&rows.size() >0);
971973
}
972-
974+
973975
publicbooleanisBeforeFirst()throwsSQLException
974976
{
975-
throworg.postgresql.Driver.notImplemented();
977+
return (current_row <0 &&rows.size() >0);
976978
}
977-
979+
978980
publicbooleanisFirst()throwsSQLException
979981
{
980-
throworg.postgresql.Driver.notImplemented();
982+
return (current_row ==0 &&rows.size() >=0);
981983
}
982-
984+
983985
publicbooleanisLast()throwsSQLException
984986
{
985-
throworg.postgresql.Driver.notImplemented();
987+
return (current_row ==rows.size() -1 &&rows.size() >0);
986988
}
987-
989+
988990
publicbooleanlast()throwsSQLException
989991
{
990992
if (rows.size() <=0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp