List:Commits« Previous MessageNext Message »
From:Craig L Russell Date:June 29 2011 10:55pm
Subject:bzr push into connector-j/branches/branch_5_1 branch (Craig.Russell:1063 to
1064)
View as plain text  
 1064 Craig L Russell	2011-06-29
      Add getBatchedArgs to StatementImpl to allow an interceptor to get the batched parameter values
      Relax visibility of implementation classes in PreparedStatement and ServerPreparedStatement
          to allow interceptor to examine batched parameter values
      Improve BindValue to store byte, short, int, and long values in one field instead of four

    modified:
      src/com/mysql/jdbc/PreparedStatement.java
      src/com/mysql/jdbc/ServerPreparedStatement.java
      src/com/mysql/jdbc/StatementImpl.java
 1063 mark.matthews@stripped	2011-06-03
       Fix for Bug#61105 - Avoid a concurrent bottleneck in Java's character set
          encoding/decoding when converting bytes to/from Strings.
      
      ** NOTE TO DEVELOPERS/MAINTAINERS **
      
      No longer use String.getBytes(...), or new String(byte[]...), use the StringUtils method instead. I'll be adding a findbugs pattern that detects when we use the wrong one.

    removed:
      src/testsuite/regression/jdbc4/
      src/testsuite/regression/jdbc4/ConnectionRegressionTest.java
    modified:
      CHANGES
      src/com/mysql/jdbc/Buffer.java
      src/com/mysql/jdbc/CallableStatement.java
      src/com/mysql/jdbc/Clob.java
      src/com/mysql/jdbc/ConnectionImpl.java
      src/com/mysql/jdbc/ConnectionPropertiesImpl.java
      src/com/mysql/jdbc/DatabaseMetaData.java
      src/com/mysql/jdbc/Field.java
      src/com/mysql/jdbc/MysqlIO.java
      src/com/mysql/jdbc/PreparedStatement.java
      src/com/mysql/jdbc/ResultSetImpl.java
      src/com/mysql/jdbc/ResultSetRow.java
      src/com/mysql/jdbc/Security.java
      src/com/mysql/jdbc/ServerPreparedStatement.java
      src/com/mysql/jdbc/StatementImpl.java
      src/com/mysql/jdbc/StringUtils.java
      src/com/mysql/jdbc/UpdatableResultSet.java
      src/com/mysql/jdbc/Util.java
      src/com/mysql/jdbc/profiler/ProfilerEvent.java
      src/testsuite/regression/CallableStatementRegressionTest.java
=== modified file 'src/com/mysql/jdbc/PreparedStatement.java'
--- a/src/com/mysql/jdbc/PreparedStatement.java	2011-06-03 22:47:21 +0000
+++ b/src/com/mysql/jdbc/PreparedStatement.java	2011-06-29 22:53:05 +0000
@@ -126,16 +126,16 @@ public class PreparedStatement extends c
 		}
 	}
 	
-	class BatchParams {
-		boolean[] isNull = null;
+	public class BatchParams {
+		public boolean[] isNull = null;
 
-		boolean[] isStream = null;
+		public boolean[] isStream = null;
 
-		InputStream[] parameterStreams = null;
+		public InputStream[] parameterStreams = null;
 
-		byte[][] parameterStrings = null;
+		public byte[][] parameterStrings = null;
 
-		int[] streamLengths = null;
+		public int[] streamLengths = null;
 
 		BatchParams(byte[][] strings, InputStream[] streams,
 				boolean[] isStreamFlags, int[] lengths, boolean[] isNullFlags) {

=== modified file 'src/com/mysql/jdbc/ServerPreparedStatement.java'
--- a/src/com/mysql/jdbc/ServerPreparedStatement.java	2011-06-03 22:47:21 +0000
+++ b/src/com/mysql/jdbc/ServerPreparedStatement.java	2011-06-29 22:53:05 +0000
@@ -84,8 +84,8 @@ public class ServerPreparedStatement ext
 	
 	protected static final int BLOB_STREAM_READ_BUF_SIZE = 8192;
 
-	static class BatchedBindValues {
-		BindValue[] batchedParameterValues;
+	public static class BatchedBindValues {
+		public BindValue[] batchedParameterValues;
 
 		BatchedBindValues(BindValue[] paramVals) {
 			int numParams = paramVals.length;
@@ -100,29 +100,23 @@ public class ServerPreparedStatement ext
 
 	public static class BindValue {
 
-		long boundBeforeExecutionNum = 0;
+		public long boundBeforeExecutionNum = 0;
 		
 		public long bindLength; /* Default length of data */
 
-		int bufferType; /* buffer type */
+		public int bufferType; /* buffer type */
 
-		byte byteBinding;
+		public double doubleBinding;
 
-		double doubleBinding;
-
-		float floatBinding;
-
-		int intBinding;
+		public float floatBinding;
 
 		public boolean isLongData; /* long data indicator */
 
 		public boolean isNull; /* NULL indicator */
 
-		boolean isSet = false; /* has this parameter been set? */
-
-		long longBinding;
+		public boolean isSet = false; /* has this parameter been set? */
 
-		short shortBinding;
+		public long longBinding; /* all integral values are stored here */
 
 		public Object value; /* The value to store */
 
@@ -136,9 +130,6 @@ public class ServerPreparedStatement ext
 			this.isNull = copyMe.isNull;
 			this.bufferType = copyMe.bufferType;
 			this.bindLength = copyMe.bindLength;
-			this.byteBinding = copyMe.byteBinding;
-			this.shortBinding = copyMe.shortBinding;
-			this.intBinding = copyMe.intBinding;
 			this.longBinding = copyMe.longBinding;
 			this.floatBinding = copyMe.floatBinding;
 			this.doubleBinding = copyMe.doubleBinding;
@@ -149,9 +140,6 @@ public class ServerPreparedStatement ext
 			this.value = null;
 			this.isLongData = false;
 
-			this.byteBinding = 0;
-			this.shortBinding = 0;
-			this.intBinding = 0;
 			this.longBinding = 0L;
 			this.floatBinding = 0;
 			this.doubleBinding = 0D;
@@ -168,11 +156,8 @@ public class ServerPreparedStatement ext
 
 			switch (this.bufferType) {
 			case MysqlDefs.FIELD_TYPE_TINY:
-				return String.valueOf(byteBinding);
 			case MysqlDefs.FIELD_TYPE_SHORT:
-				return String.valueOf(shortBinding);
 			case MysqlDefs.FIELD_TYPE_LONG:
-				return String.valueOf(intBinding);
 			case MysqlDefs.FIELD_TYPE_LONGLONG:
 				return String.valueOf(longBinding);
 			case MysqlDefs.FIELD_TYPE_FLOAT:
@@ -486,13 +471,13 @@ public class ServerPreparedStatement ext
 						switch (bindValue.bufferType) {
 
 						case MysqlDefs.FIELD_TYPE_TINY:
-							pStmtForSub.setByte(i + 1, bindValue.byteBinding);
+							pStmtForSub.setByte(i + 1, (byte)bindValue.longBinding);
 							break;
 						case MysqlDefs.FIELD_TYPE_SHORT:
-							pStmtForSub.setShort(i + 1, bindValue.shortBinding);
+							pStmtForSub.setShort(i + 1, (short)bindValue.longBinding);
 							break;
 						case MysqlDefs.FIELD_TYPE_LONG:
-							pStmtForSub.setInt(i + 1, bindValue.intBinding);
+							pStmtForSub.setInt(i + 1, (int)bindValue.longBinding);
 							break;
 						case MysqlDefs.FIELD_TYPE_LONGLONG:
 							pStmtForSub.setLong(i + 1, bindValue.longBinding);
@@ -1858,7 +1843,7 @@ public class ServerPreparedStatement ext
 		setType(binding, MysqlDefs.FIELD_TYPE_TINY);
 
 		binding.value = null;
-		binding.byteBinding = x;
+		binding.longBinding = x;
 		binding.isNull = false;
 		binding.isLongData = false;
 	}
@@ -2024,7 +2009,7 @@ public class ServerPreparedStatement ext
 		setType(binding, MysqlDefs.FIELD_TYPE_LONG);
 
 		binding.value = null;
-		binding.intBinding = x;
+		binding.longBinding = x;
 		binding.isNull = false;
 		binding.isLongData = false;
 	}
@@ -2104,7 +2089,7 @@ public class ServerPreparedStatement ext
 		setType(binding, MysqlDefs.FIELD_TYPE_SHORT);
 
 		binding.value = null;
-		binding.shortBinding = x;
+		binding.longBinding = x;
 		binding.isNull = false;
 		binding.isLongData = false;
 	}
@@ -2341,15 +2326,15 @@ public class ServerPreparedStatement ext
 			switch (bindValue.bufferType) {
 
 			case MysqlDefs.FIELD_TYPE_TINY:
-				packet.writeByte(bindValue.byteBinding);
+				packet.writeByte((byte)bindValue.longBinding);
 				return;
 			case MysqlDefs.FIELD_TYPE_SHORT:
 				packet.ensureCapacity(2);
-				packet.writeInt(bindValue.shortBinding);
+				packet.writeInt((int)bindValue.longBinding);
 				return;
 			case MysqlDefs.FIELD_TYPE_LONG:
 				packet.ensureCapacity(4);
-				packet.writeLong(bindValue.intBinding);
+				packet.writeLong((int)bindValue.longBinding);
 				return;
 			case MysqlDefs.FIELD_TYPE_LONGLONG:
 				packet.ensureCapacity(8);
@@ -2883,15 +2868,15 @@ public class ServerPreparedStatement ext
 	
 					case MysqlDefs.FIELD_TYPE_TINY:
 						batchedStatement.setByte(batchedParamIndex++,
-								paramArg[j].byteBinding);
+								(byte)paramArg[j].longBinding);
 						break;
 					case MysqlDefs.FIELD_TYPE_SHORT:
 						batchedStatement.setShort(batchedParamIndex++,
-								paramArg[j].shortBinding);
+								(short)paramArg[j].longBinding);
 						break;
 					case MysqlDefs.FIELD_TYPE_LONG:
 						batchedStatement.setInt(batchedParamIndex++,
-								paramArg[j].intBinding);
+								(int)paramArg[j].longBinding);
 						break;
 					case MysqlDefs.FIELD_TYPE_LONGLONG:
 						batchedStatement.setLong(batchedParamIndex++,

=== modified file 'src/com/mysql/jdbc/StatementImpl.java'
--- a/src/com/mysql/jdbc/StatementImpl.java	2011-06-03 22:47:21 +0000
+++ b/src/com/mysql/jdbc/StatementImpl.java	2011-06-29 22:53:05 +0000
@@ -31,6 +31,7 @@ import java.sql.SQLWarning;
 import java.sql.Types;
 import java.util.ArrayList;
 import java.util.Calendar;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.GregorianCalendar;
 import java.util.HashSet;
@@ -392,6 +393,16 @@ public class StatementImpl implements St
 		}
 	}
 
+	/** Get the batched args as added by the addBatch method(s).
+	 * The list is unmodifiable and might contain any combination of String,
+	 * BatchParams, or BatchedBindValues depending on how the parameters were
+	 * batched.
+	 * @return an unmodifiable List of batched args
+	 */
+	public List getBatchedArgs() {
+		return batchedArgs==null?null:Collections.unmodifiableList(batchedArgs);
+	}
+
 	/**
 	 * Cancels this Statement object if both the DBMS and driver support
 	 * aborting an SQL statement. This method can be used by one thread to

No bundle (reason: useless for push emails).
Thread
bzr push into connector-j/branches/branch_5_1 branch (Craig.Russell:1063 to1064)Craig L Russell4 Jul