From: Date: September 4 2007 6:54pm Subject: Connector/J commit: r6545 - in branches/branch_5_0/connector-j: . src/com/mysql/jdbc src/testsuite/regression List-Archive: http://lists.mysql.com/commits/33652 X-Bug: 28689 Message-Id: <200709041654.l84GsbKS005636@bk-internal.mysql.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modified: branches/branch_5_0/connector-j/CHANGES branches/branch_5_0/connector-j/src/com/mysql/jdbc/CallableStatement.java branches/branch_5_0/connector-j/src/com/mysql/jdbc/ConnectionProperties.java branches/branch_5_0/connector-j/src/testsuite/regression/CallableStatementRegressionTest.java Log: Fixed BUG#28689 - CallableStatement.executeBatch() doesn't work when connection property "noAccessToProcedureBodies" has been set to "true". The fix involves changing the behavior of "noAccessToProcedureBodies",in that the driver will now report all paramters as "IN" paramters but allow callers to call registerOutParameter() on them without throwing an exception. Modified: branches/branch_5_0/connector-j/CHANGES =================================================================== --- branches/branch_5_0/connector-j/CHANGES 2007-08-31 06:14:57 UTC (rev 6544) +++ branches/branch_5_0/connector-j/CHANGES 2007-09-04 16:54:36 UTC (rev 6545) @@ -36,8 +36,16 @@ - Fixed BUG#27867 - Schema objects with identifiers other than the connection character aren't retrieved correctly in - ResultSetMetadata. + ResultSetMetadata. + - Fixed BUG#28689 - CallableStatement.executeBatch() doesn't work when + connection property "noAccessToProcedureBodies" has been set to "true". + + The fix involves changing the behavior of "noAccessToProcedureBodies",in + that the driver will now report all paramters as "IN" paramters + but allow callers to call registerOutParameter() on them without throwing + an exception. + 07-19-07 - Version 5.0.7 - Setting the configuration parameter "useCursorFetch" to "true" for Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/CallableStatement.java =================================================================== --- branches/branch_5_0/connector-j/src/com/mysql/jdbc/CallableStatement.java 2007-08-31 06:14:57 UTC (rev 6544) +++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/CallableStatement.java 2007-09-04 16:54:36 UTC (rev 6545) @@ -560,7 +560,14 @@ CallableStatementParam paramDescriptor = this.paramInfo .getParameter(localParamIndex); - if (!paramDescriptor.isOut) { + // We don't have reliable metadata in this case, trust + // the caller + + if (this.connection.getNoAccessToProcedureBodies()) { + paramDescriptor.isOut = true; + paramDescriptor.isIn = true; + paramDescriptor.inOutModifier = DatabaseMetaData.procedureColumnInOut; + } else if (!paramDescriptor.isOut) { throw SQLError.createSQLException( Messages.getString("CallableStatement.9") + paramIndex //$NON-NLS-1$ + Messages.getString("CallableStatement.10"), //$NON-NLS-1$ @@ -653,7 +660,7 @@ row[3] = StringUtils.s2b(String.valueOf(i), this.connection); // COLUMN_NAME row[4] = StringUtils.s2b(String - .valueOf(DatabaseMetaData.procedureColumnInOut), + .valueOf(DatabaseMetaData.procedureColumnIn), this.connection); row[5] = StringUtils.s2b(String.valueOf(Types.VARCHAR), Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/ConnectionProperties.java =================================================================== --- branches/branch_5_0/connector-j/src/com/mysql/jdbc/ConnectionProperties.java 2007-08-31 06:14:57 UTC (rev 6544) +++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/ConnectionProperties.java 2007-09-04 16:54:36 UTC (rev 6545) @@ -1112,7 +1112,8 @@ false, "When determining procedure parameter types for CallableStatements, and the connected user " + " can't access procedure bodies through \"SHOW CREATE PROCEDURE\" or select on mysql.proc " - + " should the driver instead create basic metadata (all parameters reported as INOUT VARCHARs) instead " + + " should the driver instead create basic metadata (all parameters reported as IN VARCHARs," + + " but allowing registerOutParameter() to be called on them anyway) instead " + " of throwing an exception?", "5.0.3", MISC_CATEGORY, Integer.MIN_VALUE); Modified: branches/branch_5_0/connector-j/src/testsuite/regression/CallableStatementRegressionTest.java =================================================================== --- branches/branch_5_0/connector-j/src/testsuite/regression/CallableStatementRegressionTest.java 2007-08-31 06:14:57 UTC (rev 6544) +++ branches/branch_5_0/connector-j/src/testsuite/regression/CallableStatementRegressionTest.java 2007-09-04 16:54:36 UTC (rev 6545) @@ -1194,4 +1194,55 @@ } } } -} + + /** + * Tests fix for BUG#28689 - CallableStatement.executeBatch() + * doesn't work when connection property "noAccessToProcedureBodies" + * has been set to "true". + * + * The fix involves changing the behavior of "noAccessToProcedureBodies", + * in that the driver will now report all paramters as "IN" paramters + * but allow callers to call registerOutParameter() on them. + * + * @throws Exception + */ + public void testBug28689() throws Exception { + if (!versionMeetsMinimum(5, 0)) { + return; // no stored procedures + } + + createTable("testBug28689", "(" + + + "`id` int(11) NOT NULL auto_increment," + + "`usuario` varchar(255) default NULL," + + "PRIMARY KEY (`id`)" + + ")"); + + this.stmt.executeUpdate("INSERT INTO testBug28689 (usuario) VALUES ('AAAAAA')"); + + createProcedure("sp_testBug28689", "(tid INT)" + + "\nBEGIN" + + "\nUPDATE testBug28689 SET usuario = 'BBBBBB' WHERE id = tid;" + + "\nEND"); + + Connection noProcedureBodiesConn = getConnectionWithProps("noAccessToProcedureBodies=true"); + CallableStatement cStmt = null; + + try { + cStmt = noProcedureBodiesConn.prepareCall("{CALL sp_testBug28689(?)}"); + cStmt.setInt(1, 1); + cStmt.addBatch(); + cStmt.executeBatch(); + + assertEquals("BBBBBB", getSingleIndexedValueWithQuery(noProcedureBodiesConn, 1, "SELECT `usuario` FROM testBug28689 WHERE id=1")); + } finally { + if (cStmt != null) { + cStmt.close(); + } + + if (noProcedureBodiesConn != null) { + noProcedureBodiesConn.close(); + } + } + } +} \ No newline at end of file