List:Commits« Previous MessageNext Message »
From:mark.matthews Date:December 9 2010 2:21pm
Subject:bzr push into connector-j/branches/branch_5_1 branch (mark.matthews:1028 to
1029)
View as plain text  
 1029 mark.matthews@stripped	2010-12-09
      Fixed an issue where statement comments set via Connection.setStatementComment() weren't represented in autoGenerateTestcaseScript=true output.

    modified:
      CHANGES
      src/com/mysql/jdbc/MysqlIO.java
      src/testsuite/regression/ConnectionRegressionTest.java
 1028 mark.matthews@stripped	2010-12-06
      Bumped version #

    modified:
      build.xml
=== modified file 'CHANGES'
--- a/CHANGES	2010-12-06 18:27:50 +0000
+++ b/CHANGES	2010-12-09 14:20:23 +0000
@@ -1,6 +1,10 @@
 # Changelog
 # $Id$
+nn-nn-11 - Version 5.1.15
 
+   - Fixed an issue where statement comments set via Connection.setStatementComment()
+     weren't represented in autoGenerateTestcaseScript=true output.
+     
 12-06-10 - Version 5.1.14
 
    - Fix for Bug#58728, NPE in com.mysql.jdbc.jdbc2.optional.StatementWrappe.getResultSet()

=== modified file 'src/com/mysql/jdbc/MysqlIO.java'
--- a/src/com/mysql/jdbc/MysqlIO.java	2010-10-27 01:20:30 +0000
+++ b/src/com/mysql/jdbc/MysqlIO.java	2010-12-09 14:20:23 +0000
@@ -2048,15 +2048,14 @@ public class MysqlIO {
 	    	long queryStartTime = 0;
 	    	long queryEndTime = 0;
 
-	    	if (query != null) {
+    		String statementComment = this.connection.getStatementComment();
 
+	    	if (query != null) {
 	    		// We don't know exactly how many bytes we're going to get
 	    		// from the query. Since we're dealing with Unicode, the
 	    		// max is 2, so pad it (2 * query) + space for headers
 	    		int packLength = HEADER_LENGTH + 1 + (query.length() * 2) + 2;
 
-	    		String statementComment = this.connection.getStatementComment();
-
 	    		byte[] commentAsBytes = null;
 
 	    		if (statementComment != null) {
@@ -2123,7 +2122,11 @@ public class MysqlIO {
 	    		String testcaseQuery = null;
 
 	    		if (query != null) {
-	    			testcaseQuery = query;
+	    			if (statementComment != null) {
+	    				testcaseQuery = "/* " + statementComment + " */ " + query;
+	    			} else {
+	    				testcaseQuery = query;
+	    			}
 	    		} else {
 	    			testcaseQuery = new String(queryBuf, 5,
 	    					(oldPacketPosition - 5));

=== modified file 'src/testsuite/regression/ConnectionRegressionTest.java'
--- a/src/testsuite/regression/ConnectionRegressionTest.java	2010-12-03 22:38:04 +0000
+++ b/src/testsuite/regression/ConnectionRegressionTest.java	2010-12-09 14:20:23 +0000
@@ -3079,4 +3079,33 @@ public class ConnectionRegressionTest ex
 			}
 		}
 	}
+	
+	public void testStatementComment() throws Exception {
+		Connection c = getConnectionWithProps("autoGenerateTestcaseScript=true,logger=StandardLogger");
+		PrintStream oldErr = System.err;
+		
+		try {
+			ByteArrayOutputStream bOut = new ByteArrayOutputStream();
+			PrintStream printStream = new PrintStream(bOut);
+			System.setErr(printStream);
+			
+			((com.mysql.jdbc.Connection)c).setStatementComment("Hi there");
+			c.setAutoCommit(false);
+			
+			c.createStatement().execute("SELECT 1");
+			c.commit();
+			c.rollback();
+			Pattern pattern = Pattern.compile("Hi");
+			String loggedData = new String(bOut.toByteArray());
+			Matcher matcher = pattern.matcher(loggedData);
+			int count = 0;
+			while (matcher.find()) {
+				count++;
+			}
+			
+			assertEquals(4, count);
+		} finally {
+			System.setErr(oldErr);
+		}
+	}
 }
\ No newline at end of file


Attachment: [text/bzr-bundle] bzr/mark.matthews@oracle.com-20101209142023-k0ji34t6jn5lna4x.bundle
Thread
bzr push into connector-j/branches/branch_5_1 branch (mark.matthews:1028 to1029) mark.matthews9 Dec