This is an automated email from the git hooks/post-receive script. ebourg-guest pushed a commit to tag REL8_0_323 in repository libpostgresql-jdbc-java.
commit e74f0325fe0705a4799e854d4b13a8ff58800fc5 Author: Kris Jurka <[email protected]> Date: Wed Apr 2 17:06:32 2008 +0000 CallableStatement#getUpdateCount was returning 1 when a function returned a ResultSet. Return -1 instead. Report by Sam Lawrence. Debugging assistance by Albe Laurenz. --- org/postgresql/jdbc2/AbstractJdbc2Statement.java | 10 ++----- org/postgresql/test/jdbc2/CallableStmtTest.java | 33 +++++++++++++++++++++--- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/org/postgresql/jdbc2/AbstractJdbc2Statement.java b/org/postgresql/jdbc2/AbstractJdbc2Statement.java index 3f4e4c8..5ec7177 100644 --- a/org/postgresql/jdbc2/AbstractJdbc2Statement.java +++ b/org/postgresql/jdbc2/AbstractJdbc2Statement.java @@ -3,7 +3,7 @@ * Copyright (c) 2004-2005, PostgreSQL Global Development Group * * IDENTIFICATION -* $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java,v 1.68.2.14 2007/06/22 21:37:53 jurka Exp $ +* $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java,v 1.68.2.15 2007/07/27 09:02:04 jurka Exp $ * *------------------------------------------------------------------------- */ @@ -433,13 +433,7 @@ public abstract class AbstractJdbc2Statement implements BaseStatement public int getUpdateCount() throws SQLException { checkClosed(); - if (result == null) - return -1; - - if (isFunction) - return 1; - - if (result.getResultSet() != null) + if (result == null || result.getResultSet() != null) return -1; return result.getUpdateCount(); diff --git a/org/postgresql/test/jdbc2/CallableStmtTest.java b/org/postgresql/test/jdbc2/CallableStmtTest.java index 23341d5..a54c161 100644 --- a/org/postgresql/test/jdbc2/CallableStmtTest.java +++ b/org/postgresql/test/jdbc2/CallableStmtTest.java @@ -3,7 +3,7 @@ * Copyright (c) 2004-2005, PostgreSQL Global Development Group * * IDENTIFICATION -* $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/CallableStmtTest.java,v 1.12.2.2 2005/06/08 16:21:02 davec Exp $ +* $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/CallableStmtTest.java,v 1.12.2.3 2005/06/21 20:11:52 davec Exp $ * *------------------------------------------------------------------------- */ @@ -71,9 +71,34 @@ public class CallableStmtTest extends TestCase final String func = "{ ? = call "; final String pkgName = "testspg__"; - // protected void runTest () throws Throwable { - //testGetString (); - //} + + public void testGetUpdateCount() throws SQLException + { + CallableStatement call = con.prepareCall (func + pkgName + "getDouble (?) }"); + call.setDouble (2, (double)3.04); + call.registerOutParameter (1, Types.DOUBLE); + call.execute (); + assertEquals(-1, call.getUpdateCount()); + assertNull(call.getResultSet()); + assertEquals(42.42, call.getDouble(1), 0.00001); + call.close(); + + // test without an out parameter + call = con.prepareCall( "{ call " + pkgName + "getDouble(?) }"); + call.setDouble( 1, (double)3.04 ); + call.execute(); + assertEquals(-1, call.getUpdateCount()); + ResultSet rs = call.getResultSet(); + assertNotNull(rs); + assertTrue(rs.next()); + assertEquals(42.42, rs.getDouble(1), 0.00001); + assertTrue(!rs.next()); + rs.close(); + + assertEquals(-1, call.getUpdateCount()); + assertTrue(!call.getMoreResults()); + call.close(); + } public void testGetDouble () throws Throwable { -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libpostgresql-jdbc-java.git _______________________________________________ pkg-java-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-commits

