=== modified file 'src/com/mysql/jdbc/CallableStatement.java' --- src/com/mysql/jdbc/CallableStatement.java 2010-03-25 20:06:19 +0000 +++ src/com/mysql/jdbc/CallableStatement.java 2010-04-19 15:43:34 +0000 @@ -585,6 +585,7 @@ if (numParsedParameters != this.parameterCount) { // bail? + // No. See Bug#43576 } int placeholderCount = 0; @@ -2206,7 +2207,12 @@ if (this.placeholderToParameterIndexMap == null) { outParamIndex = outParamInfo.index + 1; } else { - outParamIndex = this.placeholderToParameterIndexMap[outParamInfo.index - 1 /* JDBC is 1-based */]; + if ((this.parameterCount == this.paramInfo.numParameters) || (this.paramInfo.isFunctionCall)) { + outParamIndex = this.placeholderToParameterIndexMap[outParamInfo.index - 1 /* JDBC is 1-based */]; + //This fails for Bug#43576! AFAIS, in that case outParamInfo.index is already 0 based... + } else { + outParamIndex = outParamInfo.index;//this.placeholderToParameterIndexMap[outParamInfo.index - (this.paramInfo.numParameters - this.parameterCount)]; + } } this.setBytesNoEscapeNoQuotes(outParamIndex, === modified file 'src/com/mysql/jdbc/PreparedStatement.java' --- src/com/mysql/jdbc/PreparedStatement.java 2010-04-07 14:40:40 +0000 +++ src/com/mysql/jdbc/PreparedStatement.java 2010-04-19 15:48:13 +0000 @@ -3694,20 +3694,35 @@ checkBounds(paramIndex, parameterIndexOffset); - this.isStream[paramIndex - 1 + parameterIndexOffset] = false; - this.isNull[paramIndex - 1 + parameterIndexOffset] = false; - this.parameterStreams[paramIndex - 1 + parameterIndexOffset] = null; - this.parameterValues[paramIndex - 1 + parameterIndexOffset] = val; + int dif = 0; + if (this instanceof com.mysql.jdbc.CallableStatement) { + if (((com.mysql.jdbc.CallableStatement)this).paramInfo.isFunctionCall) dif = 1; + else dif = ((com.mysql.jdbc.CallableStatement)this).paramInfo.numParameters - this.parameterCount; + } + else dif = 1; + if (dif == 0) dif = 1;//No descrepancy + + this.isStream[paramIndex - dif + parameterIndexOffset] = false; + this.isNull[paramIndex - dif + parameterIndexOffset] = false; + this.parameterStreams[paramIndex - dif + parameterIndexOffset] = null; + this.parameterValues[paramIndex - dif + parameterIndexOffset] = val; } private void checkBounds(int paramIndex, int parameterIndexOffset) throws SQLException { + + int tmp = 0; + if (this instanceof com.mysql.jdbc.CallableStatement) { + if (((com.mysql.jdbc.CallableStatement)this).paramInfo.isFunctionCall) tmp = 0; + else tmp = ((com.mysql.jdbc.CallableStatement)this).paramInfo.numParameters; + } + if ((paramIndex < 1)) { throw SQLError.createSQLException( Messages.getString("PreparedStatement.49") //$NON-NLS-1$ + paramIndex + Messages.getString("PreparedStatement.50"), SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$ - } else if (paramIndex > this.parameterCount) { + } else if ((paramIndex > this.parameterCount) && (paramIndex > tmp)) { throw SQLError.createSQLException( Messages.getString("PreparedStatement.51") //$NON-NLS-1$ + paramIndex