List:Commits« Previous MessageNext Message »
From:mmatthews Date:June 17 2006 12:07am
Subject:Connector/J commit: r5404 - branches/branch_5_0/connector-j/src/testsuite/regression
View as plain text  
Modified:
   branches/branch_5_0/connector-j/src/testsuite/regression/StatementRegressionTest.java
Log:
Testcase for BUG#20029.

Modified:
branches/branch_5_0/connector-j/src/testsuite/regression/StatementRegressionTest.java
===================================================================
---
branches/branch_5_0/connector-j/src/testsuite/regression/StatementRegressionTest.java	2006-06-16
21:50:01 UTC (rev 5403)
+++
branches/branch_5_0/connector-j/src/testsuite/regression/StatementRegressionTest.java	2006-06-16
22:07:05 UTC (rev 5404)
@@ -3177,6 +3177,11 @@
 		}
 	}
 	
+	/**
+	 * Tests fix for BUG#20029 - NPE thrown from executeBatch().
+	 * 
+	 * @throws Exception
+	 */
 	public void testBug20029() throws Exception {
 		createTable("testBug20029", ("(field1 int)"));
 		
@@ -3234,4 +3239,50 @@
 			}
 		}
 	}
+	
+	public void testLikeWithBackslashes() throws Exception {
+		if (!versionMeetsMinimum(5, 0, 0)) {
+			return;
+		}
+
+		Connection noBackslashEscapesConn = null;
+
+		try {
+			Properties props = new Properties();
+			props.setProperty("sessionVariables",
+					"sql_mode=NO_BACKSLASH_ESCAPES");
+
+			noBackslashEscapesConn = getConnectionWithProps(props);
+
+			createTable(
+					"X_TEST",
+					"(userName varchar(32) not null, ivalue integer, CNAME varchar(255), bvalue CHAR(1),
svalue varchar(255), ACTIVE CHAR(1), primary key (userName))");
+
+			String insert_sql = "insert into X_TEST (ivalue, CNAME, bvalue, svalue, ACTIVE,
userName) values (?, ?, ?, ?, ?, ?)";
+
+			this.pstmt = noBackslashEscapesConn.prepareStatement(insert_sql);
+			this.pstmt.setInt(1, 0);
+			this.pstmt.setString(2, "c:\\jetson");
+			this.pstmt.setInt(3, 1);
+			this.pstmt.setString(4, "c:\\jetson");
+			this.pstmt.setInt(5, 1);
+			this.pstmt.setString(6, "c:\\jetson");
+			this.pstmt.execute();
+
+			String select_sql = "select user0_.userName as userName0_0_, user0_.ivalue as
ivalue0_0_, user0_.CNAME as CNAME0_0_, user0_.bvalue as bvalue0_0_, user0_.svalue as
svalue0_0_, user0_.ACTIVE as ACTIVE0_0_ from X_TEST user0_ where user0_.userName like ?";
+			this.pstmt = noBackslashEscapesConn.prepareStatement(select_sql);
+			this.pstmt.setString(1, "c:\\j%");
+			// if we comment out the previous line and uncomment the following, the like clause
matches
+			// stmt.setString(1,"c:\\\\j%");
+			System.out.println("about to execute query " + select_sql);
+			this.rs = this.pstmt.executeQuery();
+			assertTrue(this.rs.next());
+		} finally {
+			closeMemberJDBCResources();
+
+			if (noBackslashEscapesConn != null) {
+				noBackslashEscapesConn.close();
+			}
+		}
+	}
 }

Thread
Connector/J commit: r5404 - branches/branch_5_0/connector-j/src/testsuite/regressionmmatthews17 Jun