List:Internals« Previous MessageNext Message »
From:mmatthews Date:August 23 2005 4:45pm
Subject:Connector/J commit: r4126 - in branches/branch_3_1/connector-j: . src/com/mysql/jdbc
View as plain text  
Modified:
   branches/branch_3_1/connector-j/CHANGES
   branches/branch_3_1/connector-j/src/com/mysql/jdbc/Connection.java
   branches/branch_3_1/connector-j/src/com/mysql/jdbc/ServerPreparedStatement.java
Log:
 The "sendBlobChunkSize" property is now clamped to "max_allowed_packet"
      with consideration of stream buffer size and packet headers to avoid
      PacketTooBigExceptions when "max_allowed_packet" is similar in size
      to the default "sendBlobChunkSize" which is 1M.

Modified: branches/branch_3_1/connector-j/CHANGES
===================================================================
--- branches/branch_3_1/connector-j/CHANGES	2005-08-23 16:16:23 UTC (rev 4125)
+++ branches/branch_3_1/connector-j/CHANGES	2005-08-23 16:45:55 UTC (rev 4126)
@@ -115,6 +115,11 @@
       parsed incorrectly when DatabaseMetaData methods use that
       information.
       
+    - The "sendBlobChunkSize" property is now clamped to "max_allowed_packet"
+      with consideration of stream buffer size and packet headers to avoid
+      PacketTooBigExceptions when "max_allowed_packet" is similar in size
+      to the default "sendBlobChunkSize" which is 1M.
+      
 06-23-05 - Version 3.1.10-stable
 
 	- Fixed connecting without a database specified raised an exception

Modified: branches/branch_3_1/connector-j/src/com/mysql/jdbc/Connection.java
===================================================================
--- branches/branch_3_1/connector-j/src/com/mysql/jdbc/Connection.java	2005-08-23 16:16:23 UTC (rev 4125)
+++ branches/branch_3_1/connector-j/src/com/mysql/jdbc/Connection.java	2005-08-23 16:45:55 UTC (rev 4126)
@@ -3736,6 +3736,15 @@
 				this.maxAllowedPacket = Integer
 						.parseInt((String) this.serverVariables
 								.get("max_allowed_packet"));
+				
+				int preferredBlobSendChunkSize = getBlobSendChunkSize();
+				
+				int allowedBlobSendChunkSize = Math.min(preferredBlobSendChunkSize, 
+						this.maxAllowedPacket) - 
+						ServerPreparedStatement.BLOB_STREAM_READ_BUF_SIZE 
+						- 11 /* LONG_DATA and MySQLIO packet header size */;
+				
+				setBlobSendChunkSize(String.valueOf(allowedBlobSendChunkSize));
 			}
 
 			if (this.serverVariables.containsKey("net_buffer_length")) {

Modified: branches/branch_3_1/connector-j/src/com/mysql/jdbc/ServerPreparedStatement.java
===================================================================
--- branches/branch_3_1/connector-j/src/com/mysql/jdbc/ServerPreparedStatement.java	2005-08-23 16:16:23 UTC (rev 4125)
+++ branches/branch_3_1/connector-j/src/com/mysql/jdbc/ServerPreparedStatement.java	2005-08-23 16:45:55 UTC (rev 4126)
@@ -61,6 +61,8 @@
  *          mmatthews Exp $
  */
 public class ServerPreparedStatement extends PreparedStatement {
+	protected static final int BLOB_STREAM_READ_BUF_SIZE = 8192;
+
 	static class BatchedBindValues {
 		BindValue[] batchedParameterValues;
 
@@ -2112,7 +2114,7 @@
 	//
 	private void storeReader(MysqlIO mysql, int parameterIndex, Buffer packet,
 			Reader inStream) throws SQLException {
-		char[] buf = new char[8192];
+		char[] buf = new char[BLOB_STREAM_READ_BUF_SIZE];
 
 		int numRead = 0;
 

Thread
Connector/J commit: r4126 - in branches/branch_3_1/connector-j: . src/com/mysql/jdbcmmatthews23 Aug