postgresql-jdbc.git / summary / log / commit / refs

commit    f576eb5278372a855c50cef322b2bcc129ee2d9b
Author:   Kris Jurka <books@ejurka.com>
Date:     Wed Mar 23 19:47:45 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 d240dc45..3405bbd0 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.72 2005/02/15 08:56:26 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 a7124ac4..78f1a189 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 { [parent: 483ff75cd9b8]