MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:mmatthews Date:January 10 2007 9:29pm
Subject:Connector/J commit: r6288 - branches/branch_5_0/connector-j branches/branch_5_0/connector-j/src/com/mysql/jdbc branches/branch_5_0/connector-j/src/tes...
View as plain text  
Modified:
   branches/branch_5_0/connector-j/CHANGES
   branches/branch_5_0/connector-j/src/com/mysql/jdbc/StringUtils.java
   branches/branch_5_0/connector-j/src/testsuite/regression/StringRegressionTest.java
   trunk/connector-j/CHANGES
   trunk/connector-j/src/com/mysql/jdbc/StringUtils.java
   trunk/connector-j/src/testsuite/regression/StringRegressionTest.java
Log:
Fixed BUG#25047 - StringUtils.indexOfIgnoreCaseRespectQuotes() isn't
	  case-insensitive on the first character of the target. This bug broke
	  rewriteBatchedStatements functionality when prepared statements don't
	  use upper-case for the VALUES clause in their statements.

Modified: branches/branch_5_0/connector-j/CHANGES
===================================================================
--- branches/branch_5_0/connector-j/CHANGES	2007-01-10 21:04:31 UTC (rev 6287)
+++ branches/branch_5_0/connector-j/CHANGES	2007-01-10 21:29:26 UTC (rev 6288)
@@ -56,6 +56,11 @@
 	- Fixed BUG#25009 - Results from updates not handled correctly in 
 	  multi-statement queries, leading to erroneous "Result is from UPDATE" 
 	  exceptions.
+
+	- Fixed BUG#25047 - StringUtils.indexOfIgnoreCaseRespectQuotes() isn't
+	  case-insensitive on the first character of the target. This bug broke
+	  rewriteBatchedStatements functionality when prepared statements don't
+	  use upper-case for the VALUES clause in their statements.
 	  
 10-20-06 - Version 5.0.4
 

Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/StringUtils.java
===================================================================
--- branches/branch_5_0/connector-j/src/com/mysql/jdbc/StringUtils.java	2007-01-10 21:04:31 UTC (rev 6287)
+++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/StringUtils.java	2007-01-10 21:29:26 UTC (rev 6288)
@@ -968,7 +968,10 @@
 			} else if (c == quoteChar && !escaped
 					&& contextMarker == Character.MIN_VALUE) {
 				contextMarker = c;
-			} else if (c == target.charAt(0) && !escaped
+			// This test looks complex, but remember that in certain locales, upper case
+			// of two different codepoints coverts to same codepoint, and vice-versa.
+			} else if ((Character.toUpperCase(c) == Character.toUpperCase(target.charAt(0)) ||
+					Character.toLowerCase(c) == Character.toLowerCase(target.charAt(0))) && !escaped
 					&& contextMarker == Character.MIN_VALUE) {
 				if (startsWithIgnoreCase(src, i, target))
 					return i;

Modified: branches/branch_5_0/connector-j/src/testsuite/regression/StringRegressionTest.java
===================================================================
--- branches/branch_5_0/connector-j/src/testsuite/regression/StringRegressionTest.java	2007-01-10 21:04:31 UTC (rev 6287)
+++ branches/branch_5_0/connector-j/src/testsuite/regression/StringRegressionTest.java	2007-01-10 21:29:26 UTC (rev 6288)
@@ -895,4 +895,26 @@
 		
 		getConnectionWithProps(props).close();
 	}
+	
+	/**
+	 * Tests fix for BUG#25047 - StringUtils.indexOfIgnoreCaseRespectQuotes() isn't
+	 * case-insensitive on the first character of the target.
+	 * 
+	 * @throws Exception if the test fails.
+	 */
+	public void testBug25047() throws Exception {
+		assertEquals(26, StringUtils.indexOfIgnoreCaseRespectQuotes(0, "insert into Test (TestID) values (?)",
+				"VALUES", '`', false));
+		assertEquals(26, StringUtils.indexOfIgnoreCaseRespectQuotes(0, "insert into Test (TestID) VALUES (?)",
+				"values", '`', false));
+		
+		assertEquals(StringUtils.indexOfIgnoreCaseRespectQuotes(0, 
+				"insert into Test (TestID) values (?)", "VALUES",'`', false),
+				StringUtils.indexOfIgnoreCaseRespectQuotes(0, 
+						"insert into Test (TestID) VALUES (?)",  "VALUES",'`', false));
+		assertEquals(StringUtils.indexOfIgnoreCaseRespectQuotes(0,  
+				"insert into Test (TestID) values (?)", "values", '`', false),
+				StringUtils.indexOfIgnoreCaseRespectQuotes(0, 
+						"insert into Test (TestID) VALUES (?)", "values", '`', false));
+	}
 }

Modified: trunk/connector-j/CHANGES
===================================================================
--- trunk/connector-j/CHANGES	2007-01-10 21:04:31 UTC (rev 6287)
+++ trunk/connector-j/CHANGES	2007-01-10 21:29:26 UTC (rev 6288)
@@ -52,7 +52,12 @@
 	- Fixed BUG#25009 - Results from updates not handled correctly in 
 	  multi-statement queries, leading to erroneous "Result is from UPDATE" 
 	  exceptions.
-	    	  	  	  	   	  	   
+
+	- Fixed BUG#25047 - StringUtils.indexOfIgnoreCaseRespectQuotes() isn't
+	  case-insensitive on the first character of the target. This bug broke
+	  rewriteBatchedStatements functionality when prepared statements don't
+	  use upper-case for the VALUES clause in their statements.
+	  	    	  	  	  	   	  	   
 10-20-06 - Version 5.0.4
 
     - Fixed BUG#21379 - column names don't match metadata in cases 

Modified: trunk/connector-j/src/com/mysql/jdbc/StringUtils.java
===================================================================
--- trunk/connector-j/src/com/mysql/jdbc/StringUtils.java	2007-01-10 21:04:31 UTC (rev 6287)
+++ trunk/connector-j/src/com/mysql/jdbc/StringUtils.java	2007-01-10 21:29:26 UTC (rev 6288)
@@ -968,7 +968,10 @@
 			} else if (c == quoteChar && !escaped
 					&& contextMarker == Character.MIN_VALUE) {
 				contextMarker = c;
-			} else if (c == target.charAt(0) && !escaped
+			// This test looks complex, but remember that in certain locales, upper case
+			// of two different codepoints coverts to same codepoint, and vice-versa.
+			} else if ((Character.toUpperCase(c) == Character.toUpperCase(target.charAt(0)) ||
+					Character.toLowerCase(c) == Character.toLowerCase(target.charAt(0))) && !escaped
 					&& contextMarker == Character.MIN_VALUE) {
 				if (startsWithIgnoreCase(src, i, target))
 					return i;

Modified: trunk/connector-j/src/testsuite/regression/StringRegressionTest.java
===================================================================
--- trunk/connector-j/src/testsuite/regression/StringRegressionTest.java	2007-01-10 21:04:31 UTC (rev 6287)
+++ trunk/connector-j/src/testsuite/regression/StringRegressionTest.java	2007-01-10 21:29:26 UTC (rev 6288)
@@ -895,4 +895,27 @@
 		
 		getConnectionWithProps(props).close();
 	}
+
+	/**
+	 * Tests fix for BUG#25047 - StringUtils.indexOfIgnoreCaseRespectQuotes() isn't
+	 * case-insensitive on the first character of the target.
+	 * 
+	 * @throws Exception if the test fails.
+	 */
+	public void testBug25047() throws Exception {
+		assertEquals(26, StringUtils.indexOfIgnoreCaseRespectQuotes(0, "insert into Test (TestID) values (?)",
+				"VALUES", '`', false));
+		assertEquals(26, StringUtils.indexOfIgnoreCaseRespectQuotes(0, "insert into Test (TestID) VALUES (?)",
+				"values", '`', false));
+		
+		assertEquals(StringUtils.indexOfIgnoreCaseRespectQuotes(0, 
+				"insert into Test (TestID) values (?)", "VALUES",'`', false),
+				StringUtils.indexOfIgnoreCaseRespectQuotes(0, 
+						"insert into Test (TestID) VALUES (?)",  "VALUES",'`', false));
+		assertEquals(StringUtils.indexOfIgnoreCaseRespectQuotes(0,  
+				"insert into Test (TestID) values (?)", "values", '`', false),
+				StringUtils.indexOfIgnoreCaseRespectQuotes(0, 
+						"insert into Test (TestID) VALUES (?)", "values", '`', false));
+	}
+	}
 }

Thread
Connector/J commit: r6288 - branches/branch_5_0/connector-j branches/branch_5_0/connector-j/src/com/mysql/jdbc branches/branch_5_0/connector-j/src/tes...mmatthews10 Jan