This is an automated email from the git hooks/post-receive script. ebourg-guest pushed a commit to tag REL8_1_405 in repository libpostgresql-jdbc-java.
commit f74b6741b62ecbdbca514992d213a3d47118175f Author: Kris Jurka <[email protected]> Date: Mon Jan 30 20:10:41 2006 +0000 Backpatch the fix for incorrect parameter indexes on CallableStatements that do not return values to 8.1 --- org/postgresql/jdbc2/AbstractJdbc2Statement.java | 11 +++++++++-- org/postgresql/jdbc2/Jdbc2CallableStatement.java | 6 ++++-- org/postgresql/jdbc3/Jdbc3CallableStatement.java | 6 ++++-- org/postgresql/jdbc3g/Jdbc3gCallableStatement.java | 6 ++++-- org/postgresql/test/jdbc2/CallableStmtTest.java | 15 ++++++++++++++- 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/org/postgresql/jdbc2/AbstractJdbc2Statement.java b/org/postgresql/jdbc2/AbstractJdbc2Statement.java index 83e4c4d..365786a 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 2005/10/03 17:27:31 jurka Exp $ +* $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java,v 1.84.2.1 2005/12/04 21:41:21 jurka Exp $ * *------------------------------------------------------------------------- */ @@ -68,9 +68,16 @@ public abstract class AbstractJdbc2Statement implements BaseStatement * logic and old function call logic * will be set to true if the server is < 8.1 or * if we are using v2 protocol + * There is an exception to this where we are using v3, and the + * call does not have an out parameter before the call */ protected boolean adjustIndex = false; + /* + * Used to set adjustIndex above + */ + protected boolean outParmBeforeFunc=false; + // Static variables for parsing SQL when replaceProcessing is true. private static final short IN_SQLCODE = 0; private static final short IN_STRING = 1; @@ -2098,7 +2105,7 @@ public abstract class AbstractJdbc2Statement implements BaseStatement int len = p_sql.length(); int state = 1; boolean inQuotes = false, inEscape = false; - boolean outParmBeforeFunc = false; + outParmBeforeFunc = false; int startIndex = -1, endIndex = -1; boolean syntaxError = false; int i = 0; diff --git a/org/postgresql/jdbc2/Jdbc2CallableStatement.java b/org/postgresql/jdbc2/Jdbc2CallableStatement.java index df01e38..bc25bf1 100644 --- a/org/postgresql/jdbc2/Jdbc2CallableStatement.java +++ b/org/postgresql/jdbc2/Jdbc2CallableStatement.java @@ -3,7 +3,7 @@ * Copyright (c) 2004-2005, PostgreSQL Global Development Group * * IDENTIFICATION -* $PostgreSQL: pgjdbc/org/postgresql/jdbc2/Jdbc2CallableStatement.java,v 1.11 2005/01/11 08:25:46 jurka Exp $ +* $PostgreSQL: pgjdbc/org/postgresql/jdbc2/Jdbc2CallableStatement.java,v 1.12 2005/07/08 17:38:30 davec Exp $ * *------------------------------------------------------------------------- */ @@ -24,7 +24,9 @@ class Jdbc2CallableStatement extends Jdbc2PreparedStatement implements CallableS super(connection, sql, true, rsType, rsConcurrency); if ( !connection.haveMinimumServerVersion("8.1") || connection.getProtocolVersion() == 2) { - adjustIndex = true; + // if there is no out parameter before the function determined by modifyJdbcCall then do not + // set adjustIndex to true + adjustIndex = outParmBeforeFunc; } } public void registerOutParameter( int parameterIndex, int sqlType ) throws SQLException diff --git a/org/postgresql/jdbc3/Jdbc3CallableStatement.java b/org/postgresql/jdbc3/Jdbc3CallableStatement.java index f0e9b0d..165c3d2 100644 --- a/org/postgresql/jdbc3/Jdbc3CallableStatement.java +++ b/org/postgresql/jdbc3/Jdbc3CallableStatement.java @@ -3,7 +3,7 @@ * Copyright (c) 2004-2005, PostgreSQL Global Development Group * * IDENTIFICATION -* $PostgreSQL: pgjdbc/org/postgresql/jdbc3/Jdbc3CallableStatement.java,v 1.12 2005/07/08 17:38:30 davec Exp $ +* $PostgreSQL: pgjdbc/org/postgresql/jdbc3/Jdbc3CallableStatement.java,v 1.13 2005/07/16 12:17:48 davec Exp $ * *------------------------------------------------------------------------- */ @@ -20,7 +20,9 @@ class Jdbc3CallableStatement extends Jdbc3PreparedStatement implements CallableS super(connection, sql, true, rsType, rsConcurrency, rsHoldability); if ( !connection.haveMinimumServerVersion("8.1") || connection.getProtocolVersion() == 2) { - adjustIndex = true; + // if there is no out parameter before the function determined by modifyJdbcCall then do not + // set adjustIndex to true + adjustIndex = outParmBeforeFunc; } } diff --git a/org/postgresql/jdbc3g/Jdbc3gCallableStatement.java b/org/postgresql/jdbc3g/Jdbc3gCallableStatement.java index 5a8b22c..6cf4a82 100644 --- a/org/postgresql/jdbc3g/Jdbc3gCallableStatement.java +++ b/org/postgresql/jdbc3g/Jdbc3gCallableStatement.java @@ -3,7 +3,7 @@ * Copyright (c) 2004-2005, PostgreSQL Global Development Group * * IDENTIFICATION -* $PostgreSQL: pgjdbc/org/postgresql/jdbc3g/Jdbc3gCallableStatement.java,v 1.4 2005/01/11 08:25:47 jurka Exp $ +* $PostgreSQL: pgjdbc/org/postgresql/jdbc3g/Jdbc3gCallableStatement.java,v 1.5 2005/08/12 18:09:02 jurka Exp $ * *------------------------------------------------------------------------- */ @@ -19,7 +19,9 @@ class Jdbc3gCallableStatement extends Jdbc3gPreparedStatement implements Callabl super(connection, sql, true, rsType, rsConcurrency, rsHoldability); if ( !connection.haveMinimumServerVersion("8.1") || connection.getProtocolVersion() == 2) { - adjustIndex = true; + // if there is no out parameter before the function determined by modifyJdbcCall then do not + // set adjustIndex to true + adjustIndex = outParmBeforeFunc; } } diff --git a/org/postgresql/test/jdbc2/CallableStmtTest.java b/org/postgresql/test/jdbc2/CallableStmtTest.java index 976ad8e..bc362ab 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.16 2005/06/21 18:07:08 davec Exp $ +* $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/CallableStmtTest.java,v 1.17 2005/07/04 18:50:29 davec Exp $ * *------------------------------------------------------------------------- */ @@ -37,6 +37,9 @@ public class CallableStmtTest extends TestCase stmt.execute ("CREATE OR REPLACE FUNCTION testspg__getDouble (float) " + "RETURNS float AS ' DECLARE inString alias for $1; begin " + "return 42.42; end; ' LANGUAGE 'plpgsql';"); + stmt.execute ("CREATE OR REPLACE FUNCTION testspg__getVoid (float) " + + "RETURNS void AS ' DECLARE inString alias for $1; begin " + + " return; end; ' LANGUAGE 'plpgsql';"); stmt.execute ("CREATE OR REPLACE FUNCTION testspg__getInt (int) RETURNS int " + " AS 'DECLARE inString alias for $1; begin " + "return 42; end;' LANGUAGE 'plpgsql';"); @@ -60,6 +63,7 @@ public class CallableStmtTest extends TestCase Statement stmt = con.createStatement (); stmt.execute ("drop FUNCTION testspg__getString (varchar);"); stmt.execute ("drop FUNCTION testspg__getDouble (float);"); + stmt.execute( "drop FUNCTION testspg__getVoid(float);"); stmt.execute ("drop FUNCTION testspg__getInt (int);"); stmt.execute ("drop FUNCTION testspg__getShort(int2)"); stmt.execute ("drop FUNCTION testspg__getNumeric (numeric);"); @@ -85,6 +89,15 @@ public class CallableStmtTest extends TestCase call.registerOutParameter (1, Types.DOUBLE); call.execute (); assertEquals(42.42, call.getDouble(1), 0.00001); + + // test without an out parameter + call = con.prepareCall( "{ call " + pkgName + "getDouble(?) }"); + call.setDouble( 1, (double)3.04 ); + call.execute(); + + call = con.prepareCall( "{ call " + pkgName + "getVoid(?) }"); + call.setDouble( 1, (double)3.04 ); + call.execute(); } public void testGetInt () 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

