This is an automated email from the git hooks/post-receive script. ebourg-guest pushed a commit to tag REL8_3_604 in repository libpostgresql-jdbc-java.
commit 3c303dc95021445681a4d9ff7d02737e923ea349 Author: Kris Jurka <[email protected]> Date: Wed Apr 2 17:06:04 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 | 30 +++++++++++++++++++++++- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/org/postgresql/jdbc2/AbstractJdbc2Statement.java b/org/postgresql/jdbc2/AbstractJdbc2Statement.java index 11ee6ba..f59a820 100644 --- a/org/postgresql/jdbc2/AbstractJdbc2Statement.java +++ b/org/postgresql/jdbc2/AbstractJdbc2Statement.java @@ -3,7 +3,7 @@ * Copyright (c) 2004-2008, PostgreSQL Global Development Group * * IDENTIFICATION -* $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java,v 1.106 2008/01/08 06:56:28 jurka Exp $ +* $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java,v 1.107 2008/01/15 03:29:15 jurka Exp $ * *------------------------------------------------------------------------- */ @@ -492,13 +492,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 3496bd4..9050717 100644 --- a/org/postgresql/test/jdbc2/CallableStmtTest.java +++ b/org/postgresql/test/jdbc2/CallableStmtTest.java @@ -3,7 +3,7 @@ * Copyright (c) 2004-2008, PostgreSQL Global Development Group * * IDENTIFICATION -* $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/CallableStmtTest.java,v 1.21 2007/05/18 21:42:24 jurka Exp $ +* $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/CallableStmtTest.java,v 1.22 2008/01/08 06:56:30 jurka Exp $ * *------------------------------------------------------------------------- */ @@ -85,6 +85,34 @@ public class CallableStmtTest extends TestCase final String func = "{ ? = call "; final String pkgName = "testspg__"; + + 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

