@@ -11898,4 +11898,46 @@ public void testBug85223() throws Exception {
1189811898 String value = this.rs.getString(1);
1189911899 assertEquals("LName", value);
1190011900 }
11901+
11902+ /**
11903+ * Test fix for Bug#96900 (30355150), STATEMENT.CANCEL()CREATE A DATABASE CONNECTION BUT DOES NOT CLOSE THE CONNECTION.
11904+ *
11905+ * @throws Exception
11906+ */
11907+ @Test
11908+ public void testBug96900() throws Exception {
11909+ assumeTrue(versionMeetsMinimum(5, 6), "MySQL 5.6+ is required to run this test.");
11910+
11911+ Properties props = new Properties();
11912+ props.setProperty(PropertyKey.sslMode.getKeyName(), SslMode.DISABLED.name());
11913+ props.setProperty(PropertyKey.allowPublicKeyRetrieval.getKeyName(), "true");
11914+ props.setProperty(PropertyKey.connectionAttributes.getKeyName(), "testBug96900:1");
11915+
11916+ Connection con = getConnectionWithProps(props);
11917+ Statement st = con.createStatement();
11918+ new Thread(() -> {
11919+ try {
11920+ st.executeQuery("SELECT SLEEP(600)");
11921+ } catch (Throwable e) {
11922+ e.printStackTrace();
11923+ }
11924+ }).start();
11925+
11926+ String attCountQuery = "SELECT COUNT(*) FROM performance_schema.session_connect_attrs WHERE attr_name = 'testBug96900'";
11927+
11928+ this.rs = this.stmt.executeQuery(attCountQuery);
11929+ this.rs.next();
11930+ assertEquals(1, this.rs.getInt(1));
11931+
11932+ st.cancel();
11933+ this.rs = this.stmt.executeQuery(attCountQuery);
11934+ this.rs.next();
11935+ assertEquals(1, this.rs.getInt(1));
11936+
11937+ con.close();
11938+ this.rs = this.stmt.executeQuery(attCountQuery);
11939+ this.rs.next();
11940+ assertEquals(0, this.rs.getInt(1));
11941+ }
11942+
1190111943}
0 commit comments