use of testsuite.simple.StatementsTest in project JavaSegundasQuintas by ecteruel.
the class StatementRegressionTest method testBug103612.
/**
* Test fix for Bug#103612 (32902019), Incorrectly identified WITH...SELECT as unsafe for read-only connections.
*
* @throws Exception
*
* @see StatementsTest#testReadOnlySafeStatements()
*/
@Test
public void testBug103612() throws Exception {
assumeTrue(versionMeetsMinimum(8, 0, 1), "MySQL 8.0.1+ is required to run this test.");
createTable("testBug103612", "(id INT)");
String query = "WITH cte AS (SELECT * FROM testBug103612) SELECT * FROM cte";
boolean useSPS = false;
boolean readOnly = false;
do {
final String testCase = String.format("Case [SPS: %s, ReadOnly: %s]", useSPS ? "Y" : "N", readOnly ? "Y" : "N");
Properties props = new Properties();
props.setProperty(PropertyKey.useServerPrepStmts.getKeyName(), Boolean.toString(useSPS));
Connection testConn = getConnectionWithProps(props);
testConn.setReadOnly(readOnly);
try (Statement testStmt = testConn.createStatement()) {
assertTrue(testStmt.execute(query), testCase);
}
try (PreparedStatement testPstmt = testConn.prepareStatement(query)) {
assertTrue(testPstmt.execute(), testCase);
}
testConn.close();
} while ((useSPS = !useSPS) || (readOnly = !readOnly));
}
use of testsuite.simple.StatementsTest in project ABC by RuiPinto96274.
the class StatementRegressionTest method testBug103612.
/**
* Test fix for Bug#103612 (32902019), Incorrectly identified WITH...SELECT as unsafe for read-only connections.
*
* @throws Exception
*
* @see StatementsTest#testReadOnlySafeStatements()
*/
@Test
public void testBug103612() throws Exception {
assumeTrue(versionMeetsMinimum(8, 0, 1), "MySQL 8.0.1+ is required to run this test.");
createTable("testBug103612", "(id INT)");
String query = "WITH cte AS (SELECT * FROM testBug103612) SELECT * FROM cte";
boolean useSPS = false;
boolean readOnly = false;
do {
final String testCase = String.format("Case [SPS: %s, ReadOnly: %s]", useSPS ? "Y" : "N", readOnly ? "Y" : "N");
Properties props = new Properties();
props.setProperty(PropertyKey.useServerPrepStmts.getKeyName(), Boolean.toString(useSPS));
Connection testConn = getConnectionWithProps(props);
testConn.setReadOnly(readOnly);
try (Statement testStmt = testConn.createStatement()) {
assertTrue(testStmt.execute(query), testCase);
}
try (PreparedStatement testPstmt = testConn.prepareStatement(query)) {
assertTrue(testPstmt.execute(), testCase);
}
testConn.close();
} while ((useSPS = !useSPS) || (readOnly = !readOnly));
}
use of testsuite.simple.StatementsTest in project aws-mysql-jdbc by awslabs.
the class StatementRegressionTest method testBug103612.
/**
* Test fix for Bug#103612 (32902019), Incorrectly identified WITH...SELECT as unsafe for read-only connections.
*
* @throws Exception
*
* @see StatementsTest#testReadOnlySafeStatements()
*/
@Test
public void testBug103612() throws Exception {
assumeTrue(versionMeetsMinimum(8, 0, 1), "MySQL 8.0.1+ is required to run this test.");
createTable("testBug103612", "(id INT)");
String query = "WITH cte AS (SELECT * FROM testBug103612) SELECT * FROM cte";
boolean useSPS = false;
boolean readOnly = false;
do {
final String testCase = String.format("Case [SPS: %s, ReadOnly: %s]", useSPS ? "Y" : "N", readOnly ? "Y" : "N");
Properties props = new Properties();
props.setProperty(PropertyKey.useServerPrepStmts.getKeyName(), Boolean.toString(useSPS));
Connection testConn = getConnectionWithProps(props);
testConn.setReadOnly(readOnly);
try (Statement testStmt = testConn.createStatement()) {
assertTrue(testStmt.execute(query), testCase);
}
try (PreparedStatement testPstmt = testConn.prepareStatement(query)) {
assertTrue(testPstmt.execute(), testCase);
}
testConn.close();
} while ((useSPS = !useSPS) || (readOnly = !readOnly));
}
Aggregations