? src/interfaces/jdbc/org/postgresql/test/jdbc2/myoid Index: src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v retrieving revision 1.22.2.1 diff -c -r1.22.2.1 AbstractJdbc1ResultSet.java *** src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java 12 Dec 2003 17:59:08 -0000 1.22.2.1 --- src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java 20 Jan 2004 02:18:05 -0000 *************** *** 9,15 **** * Copyright (c) 2003, PostgreSQL Global Development Group * * IDENTIFICATION ! * $Header: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.22.2.1 2003/12/12 17:59:08 davec Exp $ * *------------------------------------------------------------------------- */ --- 9,15 ---- * Copyright (c) 2003, PostgreSQL Global Development Group * * IDENTIFICATION ! * $Header: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java,v 1.22.2.1 2003/12/12 17:59:08 davec Exp $ * *------------------------------------------------------------------------- */ *************** *** 137,147 **** if (rows == null) throw new PSQLException("postgresql.con.closed", PSQLState.CONNECTION_DOES_NOT_EXIST); ! if (++current_row >= rows.size()) { String cursorName = statement.getFetchingCursorName(); ! if (cursorName == null || lastFetchSize == 0 || rows.size() < lastFetchSize) return false; // Not doing a cursor-based fetch or the last fetch was the end of the query // Use the ref to the statement to get // the details we need to do another cursor --- 137,149 ---- if (rows == null) throw new PSQLException("postgresql.con.closed", PSQLState.CONNECTION_DOES_NOT_EXIST); ! if (current_row+1 >= rows.size()) { String cursorName = statement.getFetchingCursorName(); ! if (cursorName == null || lastFetchSize == 0 || rows.size() < lastFetchSize) { ! current_row = rows.size(); return false; // Not doing a cursor-based fetch or the last fetch was the end of the query + } // Use the ref to the statement to get // the details we need to do another cursor *************** *** 167,172 **** --- 169,176 ---- // Otherwise reset the counter and let it go on... current_row = 0; + } else { + current_row++; } this_row = (byte [][])rows.elementAt(current_row); Index: src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v retrieving revision 1.25.2.2 diff -c -r1.25.2.2 AbstractJdbc2ResultSet.java *** src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java 18 Dec 2003 03:35:55 -0000 1.25.2.2 --- src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java 20 Jan 2004 02:18:05 -0000 *************** *** 9,15 **** * Copyright (c) 2003, PostgreSQL Global Development Group * * IDENTIFICATION ! * $Header: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v 1.25.2.2 2003/12/18 03:35:55 davec Exp $ * *------------------------------------------------------------------------- */ --- 9,15 ---- * Copyright (c) 2003, PostgreSQL Global Development Group * * IDENTIFICATION ! * $Header: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java,v 1.25.2.2 2003/12/18 03:35:55 davec Exp $ * *------------------------------------------------------------------------- */ *************** *** 490,497 **** public boolean previous() throws SQLException { ! if (--current_row < 0) return false; this_row = (byte[][]) rows.elementAt(current_row); rowBuffer = new byte[this_row.length][]; System.arraycopy(this_row, 0, rowBuffer, 0, this_row.length); --- 490,501 ---- public boolean previous() throws SQLException { ! if (current_row-1 < 0) { ! current_row = -1; return false; + } else { + current_row--; + } this_row = (byte[][]) rows.elementAt(current_row); rowBuffer = new byte[this_row.length][]; System.arraycopy(this_row, 0, rowBuffer, 0, this_row.length); Index: src/interfaces/jdbc/org/postgresql/test/jdbc2/ResultSetTest.java =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/test/jdbc2/Attic/ResultSetTest.java,v retrieving revision 1.11.2.1 diff -c -r1.11.2.1 ResultSetTest.java *** src/interfaces/jdbc/org/postgresql/test/jdbc2/ResultSetTest.java 18 Dec 2003 03:35:55 -0000 1.11.2.1 --- src/interfaces/jdbc/org/postgresql/test/jdbc2/ResultSetTest.java 20 Jan 2004 02:18:05 -0000 *************** *** 4,9 **** --- 4,10 ---- import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; + import java.sql.SQLException; import junit.framework.TestCase; *************** *** 285,289 **** fail("Exception expected."); } } ! } --- 286,332 ---- fail("Exception expected."); } } ! ! public void testZeroRowResultPositioning() throws SQLException ! { ! Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); ! ResultSet rs = stmt.executeQuery("SELECT * FROM pg_database WHERE datname='nonexistantdatabase'"); ! assertEquals(rs.previous(),false); ! assertEquals(rs.previous(),false); ! assertEquals(rs.next(),false); ! assertEquals(rs.next(),false); ! assertEquals(rs.next(),false); ! assertEquals(rs.next(),false); ! assertEquals(rs.next(),false); ! assertEquals(rs.previous(),false); ! assertEquals(rs.first(),false); ! assertEquals(rs.last(),false); ! assertEquals(rs.getRow(),0); ! assertEquals(rs.absolute(1),false); ! assertEquals(rs.relative(1),false); ! assertEquals(rs.isBeforeFirst(),false); ! assertEquals(rs.isAfterLast(),false); ! assertEquals(rs.isFirst(),false); ! assertEquals(rs.isLast(),false); ! rs.close(); ! stmt.close(); ! } ! ! public void testRowResultPositioning() throws SQLException ! { ! Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); ! // Create a one row result set. ! ResultSet rs = stmt.executeQuery("SELECT * FROM pg_database WHERE datname='template1'"); ! assertTrue(rs.isBeforeFirst()); ! assertTrue(rs.next()); ! assertTrue(rs.isFirst()); ! assertTrue(rs.isLast()); ! assertTrue(!rs.next()); ! assertTrue(rs.isAfterLast()); ! assertTrue(rs.previous()); ! assertTrue(rs.absolute(1)); ! rs.close(); ! stmt.close(); ! } ! }