List:Commits« Previous MessageNext Message »
From:mmatthews Date:September 4 2007 7:31pm
Subject:Connector/J commit: r6546 - in trunk: . connector-j connector-j/src/com/mysql/jdbc connector-j/src/testsuite/regression
View as plain text  
Modified:
   trunk/
   trunk/connector-j/CHANGES
   trunk/connector-j/src/com/mysql/jdbc/CallableStatement.java
   trunk/connector-j/src/com/mysql/jdbc/ConnectionPropertiesImpl.java
   trunk/connector-j/src/testsuite/regression/CallableStatementRegressionTest.java
Log:
Merged revisions 6545 via svnmerge from 
svn+ssh://mmatthews@stripped/connectors-svnroot/connector-j/branches/branch_5_0

.......
  r6545 | mmatthews | 2007-09-04 11:54:36 -0500 (Tue, 04 Sep 2007) | 7 lines
  
  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.
.......



Property changes on: trunk
___________________________________________________________________
Name: svnmerge-integrated
   - /branches/branch_5_0:1-6540 /branches/branch_5_1:1-6517
   + /branches/branch_5_0:1-6540,6545 /branches/branch_5_1:1-6517

Modified: trunk/connector-j/CHANGES
===================================================================
--- trunk/connector-j/CHANGES	2007-09-04 16:54:36 UTC (rev 6545)
+++ trunk/connector-j/CHANGES	2007-09-04 17:31:26 UTC (rev 6546)
@@ -214,8 +214,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: trunk/connector-j/src/com/mysql/jdbc/CallableStatement.java
===================================================================
--- trunk/connector-j/src/com/mysql/jdbc/CallableStatement.java	2007-09-04 16:54:36 UTC
(rev 6545)
+++ trunk/connector-j/src/com/mysql/jdbc/CallableStatement.java	2007-09-04 17:31:26 UTC
(rev 6546)
@@ -659,7 +659,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$
@@ -752,7 +759,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: trunk/connector-j/src/com/mysql/jdbc/ConnectionPropertiesImpl.java
===================================================================
--- trunk/connector-j/src/com/mysql/jdbc/ConnectionPropertiesImpl.java	2007-09-04 16:54:36
UTC (rev 6545)
+++ trunk/connector-j/src/com/mysql/jdbc/ConnectionPropertiesImpl.java	2007-09-04 17:31:26
UTC (rev 6546)
@@ -1070,10 +1070,14 @@
 			"5.1.0", MISC_CATEGORY, Integer.MIN_VALUE); //$NON-NLS-1$
 	
 	private BooleanConnectionProperty noAccessToProcedureBodies = new
BooleanConnectionProperty(
-			"noAccessToProcedureBodies", //$NON-NLS-1$
+			"noAccessToProcedureBodies",
 			false,
-			Messages.getString("ConnectionProperties.noAccessToProcedureBodies"), //$NON-NLS-1$
-			"5.0.3", MISC_CATEGORY, Integer.MIN_VALUE); //$NON-NLS-1$
+			"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 IN
VARCHARs,"
+			+ " but allowing registerOutParameter() to be called on them anyway) instead "
+			+ " of throwing an exception?",
+			"5.0.3", MISC_CATEGORY, Integer.MIN_VALUE);
 			
 	private BooleanConnectionProperty noDatetimeStringSync = new BooleanConnectionProperty(
 			"noDatetimeStringSync", //$NON-NLS-1$

Modified: trunk/connector-j/src/testsuite/regression/CallableStatementRegressionTest.java
===================================================================
---
trunk/connector-j/src/testsuite/regression/CallableStatementRegressionTest.java	2007-09-04
16:54:36 UTC (rev 6545)
+++
trunk/connector-j/src/testsuite/regression/CallableStatementRegressionTest.java	2007-09-04
17:31:26 UTC (rev 6546)
@@ -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

Thread
Connector/J commit: r6546 - in trunk: . connector-j connector-j/src/com/mysql/jdbc connector-j/src/testsuite/regressionmmatthews4 Sep