This is an automated email from the git hooks/post-receive script. ebourg-guest pushed a commit to tag REL8_2_509 in repository libpostgresql-jdbc-java.
commit d919c4d0b011e7c7326fbd5d79d21d459be30d43 Author: Kris Jurka <[email protected]> Date: Wed Apr 2 17:06:13 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 c237234..91e640e 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.96.2.5 2007/07/27 09:01:53 jurka Exp $ +* $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java,v 1.96.2.6 2008/01/30 12:49:00 davecramer 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 e9876d8..7c72944 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.19 2006/11/03 04:44:50 jurka Exp $ +* $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/CallableStmtTest.java,v 1.20 2006/11/29 04:34:29 jurka Exp $ * *------------------------------------------------------------------------- */ @@ -81,10 +81,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

