This is an automated email from the git hooks/post-receive script. ebourg-guest pushed a commit to tag REL8_1_413 in repository libpostgresql-jdbc-java.
commit b714fe2cfad51faf3e2bb9a45fee5cc3de14be68 Author: Kris Jurka <[email protected]> Date: Wed Apr 2 17:06:21 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 | 32 +++++++++++++++++++++--- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/org/postgresql/jdbc2/AbstractJdbc2Statement.java b/org/postgresql/jdbc2/AbstractJdbc2Statement.java index a7df317..6d55bed 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.84.2.11 2007/06/22 21:37:47 jurka Exp $ +* $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java,v 1.84.2.12 2007/07/27 09:01:59 jurka Exp $ * *------------------------------------------------------------------------- */ @@ -493,13 +493,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 bc362ab..704e77d 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.17 2005/07/04 18:50:29 davec Exp $ +* $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/CallableStmtTest.java,v 1.17.2.1 2006/01/30 20:10:41 jurka Exp $ * *------------------------------------------------------------------------- */ @@ -77,10 +77,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

