List:Commits« Previous MessageNext Message »
From:mmatthews Date:September 4 2007 7:34pm
Subject:Connector/J commit: r6547 - in branches/branch_5_1: . connector-j connector-j/src/com/mysql/jdbc connector-j/src/testsuite/regression
View as plain text  
Modified:
   branches/branch_5_1/
   branches/branch_5_1/connector-j/CHANGES
   branches/branch_5_1/connector-j/src/com/mysql/jdbc/CallableStatement.java
   branches/branch_5_1/connector-j/src/com/mysql/jdbc/ConnectionPropertiesImpl.java
   branches/branch_5_1/connector-j/src/testsuite/regression/CallableStatementRegressionTest.java
Log:
Merged revisions 6398-6402,6405-6407,6414-6473,6475,6477,6480,6483-6486,6489-6492,6496-6500,6509-6511,6513,6517-6518,6521-6522,6524,6526-6528,6530-6531,6533-6534,6536-6537,6539-6540,6543-6546 via svnmerge from 
svn+ssh://mmatthews@stripped/connectors-svnroot/connector-j/trunk

...............
  r6546 | mmatthews | 2007-09-04 12:31:26 -0500 (Tue, 04 Sep 2007) | 21 lines
  
  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: branches/branch_5_1
___________________________________________________________________
Name: svnmerge-integrated
   - /trunk:1-6396,6398-6402,6405-6407,6414-6473,6475,6477,6480,6483-6486,6489-6492,6496-6500,6509-6511,6513,6517-6518,6521-6542
   + /trunk:1-6396,6398-6402,6405-6407,6414-6473,6475,6477,6480,6483-6486,6489-6492,6496-6500,6509-6511,6513,6517-6518,6521-6546

Modified: branches/branch_5_1/connector-j/CHANGES
===================================================================
--- branches/branch_5_1/connector-j/CHANGES	2007-09-04 17:31:26 UTC (rev 6546)
+++ branches/branch_5_1/connector-j/CHANGES	2007-09-04 17:34:45 UTC (rev 6547)
@@ -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: branches/branch_5_1/connector-j/src/com/mysql/jdbc/CallableStatement.java
===================================================================
--- branches/branch_5_1/connector-j/src/com/mysql/jdbc/CallableStatement.java	2007-09-04 17:31:26 UTC (rev 6546)
+++ branches/branch_5_1/connector-j/src/com/mysql/jdbc/CallableStatement.java	2007-09-04 17:34:45 UTC (rev 6547)
@@ -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: branches/branch_5_1/connector-j/src/com/mysql/jdbc/ConnectionPropertiesImpl.java
===================================================================
--- branches/branch_5_1/connector-j/src/com/mysql/jdbc/ConnectionPropertiesImpl.java	2007-09-04 17:31:26 UTC (rev 6546)
+++ branches/branch_5_1/connector-j/src/com/mysql/jdbc/ConnectionPropertiesImpl.java	2007-09-04 17:34:45 UTC (rev 6547)
@@ -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: branches/branch_5_1/connector-j/src/testsuite/regression/CallableStatementRegressionTest.java
===================================================================
--- branches/branch_5_1/connector-j/src/testsuite/regression/CallableStatementRegressionTest.java	2007-09-04 17:31:26 UTC (rev 6546)
+++ branches/branch_5_1/connector-j/src/testsuite/regression/CallableStatementRegressionTest.java	2007-09-04 17:34:45 UTC (rev 6547)
@@ -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: r6547 - in branches/branch_5_1: . connector-j connector-j/src/com/mysql/jdbc connector-j/src/testsuite/regressionmmatthews4 Sep