summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian2000-05-12 20:54:22 +0000
committerBruce Momjian2000-05-12 20:54:22 +0000
commit2cfb14e8ea8968bb8d3d2a724c3e896016c99d81 (patch)
tree0f5aaf0900a775d4d4d4fe146a58d0dd39498c5a
parenta28f1177901506aa32aafda987fc643dfefcbb8b (diff)
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
-rw-r--r--src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java b/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java
index 76119b7b8ce..e3d1693629f 100644
--- a/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java
+++ b/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java
@@ -797,12 +797,14 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
public void afterLast() throws SQLException
{
- current_row = rows.size() + 1;
+ if (rows.size() > 0)
+ current_row = rows.size();
}
public void beforeFirst() throws SQLException
{
- current_row = 0;
+ if (rows.size() > 0)
+ current_row = -1;
}
public void cancelRowUpdates() throws SQLException
@@ -946,7 +948,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
public int getRow() throws SQLException
{
- return current_row;
+ return current_row + 1;
}
// This one needs some thought, as not all ResultSets come from a statement
@@ -967,24 +969,24 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
public boolean isAfterLast() throws SQLException
{
- throw org.postgresql.Driver.notImplemented();
+ return (current_row >= rows.size() && rows.size() > 0);
}
-
+
public boolean isBeforeFirst() throws SQLException
{
- throw org.postgresql.Driver.notImplemented();
+ return (current_row < 0 && rows.size() > 0);
}
-
+
public boolean isFirst() throws SQLException
{
- throw org.postgresql.Driver.notImplemented();
+ return (current_row == 0 && rows.size() >= 0);
}
-
+
public boolean isLast() throws SQLException
{
- throw org.postgresql.Driver.notImplemented();
+ return (current_row == rows.size() -1 && rows.size() > 0);
}
-
+
public boolean last() throws SQLException
{
if (rows.size() <= 0)