[libpostgresql-jdbc-java] 06/09: When moveToCurrentRow is called and the current row is off the end of the ResultSet we can't try to load that row because it doesn't exist and will throw an Exception.
Emmanuel Bourg
ebourg-guest at moszumanska.debian.org
Mon Jan 9 10:19:11 UTC 2017
This is an automated email from the git hooks/post-receive script.
ebourg-guest pushed a commit to tag REL8_0_311
in repository libpostgresql-jdbc-java.
commit b771da33c1ba7c930b57c199732d622243a7264e
Author: Kris Jurka <books at ejurka.com>
Date: Wed Mar 23 19:48:18 2005 +0000
When moveToCurrentRow is called and the current row is off the
end of the ResultSet we can't try to load that row because it
doesn't exist and will throw an Exception.
Reported by Prasanth.
---
org/postgresql/jdbc2/AbstractJdbc2ResultSet.java | 4 ++--
org/postgresql/test/jdbc2/UpdateableResultTest.java | 10 +++++++++-
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java b/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
index d240dc4..e45d5f1 100644
--- a/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
+++ b/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
@@ -3,7 +3,7 @@
* Copyright (c) 2003-2005, PostgreSQL Global Development Group
*
* IDENTIFICATION
-* $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java,v 1.71 2005/01/27 22:07:33 oliver Exp $
+* $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java,v 1.71.2.1 2005/02/15 08:55:50 jurka Exp $
*
*-------------------------------------------------------------------------
*/
@@ -844,7 +844,7 @@ public abstract class AbstractJdbc2ResultSet implements BaseResultSet, org.postg
{
checkUpdateable();
- if (current_row < 0)
+ if (current_row < 0 || current_row >= rows.size())
{
this_row = null;
rowBuffer = null;
diff --git a/org/postgresql/test/jdbc2/UpdateableResultTest.java b/org/postgresql/test/jdbc2/UpdateableResultTest.java
index a7124ac..78f1a18 100644
--- a/org/postgresql/test/jdbc2/UpdateableResultTest.java
+++ b/org/postgresql/test/jdbc2/UpdateableResultTest.java
@@ -3,7 +3,7 @@
* Copyright (c) 2001-2005, PostgreSQL Global Development Group
*
* IDENTIFICATION
-* $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java,v 1.18 2005/01/27 20:59:06 oliver Exp $
+* $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java,v 1.19 2005/01/27 22:07:40 oliver Exp $
*
*-------------------------------------------------------------------------
*/
@@ -233,6 +233,14 @@ public class UpdateableResultTest extends TestCase
stmt.close();
}
+ public void testZeroRowResult() throws SQLException
+ {
+ Statement st = con.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE );
+ ResultSet rs = st.executeQuery( "select * from updateable WHERE 0 > 1");
+ assertTrue(!rs.next());
+ rs.moveToInsertRow();
+ rs.moveToCurrentRow();
+ }
public void testUpdateable() throws SQLException
{
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libpostgresql-jdbc-java.git
More information about the pkg-java-commits
mailing list