Skip to content

Commit

Permalink
Test case for Bug#104349 (33563548).
Browse files Browse the repository at this point in the history
  • Loading branch information
soklakov committed Feb 22, 2022
1 parent 3feaf2c commit 7ad95bc
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Version 8.0.29

- Fix for Bug#105915 (33678490), Connector/J 8 server prepared statement precision loss in execute batch.

- Fix for Bug#104349 (33563548), com.mysql.cj NPE.

- WL#14750, Better unification of query bindings.

- WL#14834, Support for FIDO authentication.
Expand Down
49 changes: 49 additions & 0 deletions src/test/java/testsuite/regression/StatementRegressionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12041,4 +12041,53 @@ public void testBug85317() throws Exception {
} while ((useSPS = !useSPS) || (rewriteBS = !rewriteBS));

}

/**
* Tests fix for Bug#104349 (33563548), com.mysql.cj NPE.
*
* @throws Exception
*/
@Test
public void testBug104349() throws Exception {
createTable("testBug104349", "(col1 INT, col2 VARCHAR(100))");

this.stmt.executeUpdate("INSERT INTO testBug104349 VALUES (1, 'key 1')");
this.stmt.executeUpdate("INSERT INTO testBug104349 VALUES (2, 'key 2')");
this.stmt.executeUpdate("INSERT INTO testBug104349 VALUES (3, 'key 3')");

Properties props = new Properties();
props.setProperty(PropertyKey.useSSL.getKeyName(), "false");
props.setProperty(PropertyKey.allowPublicKeyRetrieval.getKeyName(), "true");
props.setProperty(PropertyKey.cachePrepStmts.getKeyName(), "true");

boolean useSPS = false;
do {
props.setProperty(PropertyKey.useServerPrepStmts.getKeyName(), "" + useSPS);
Connection testConn = getConnectionWithProps(props);

PreparedStatement ps = testConn.prepareStatement("SELECT * FROM testBug104349 WHERE col1 = ?");
assertTrue(ps.toString().endsWith("SELECT * FROM testBug104349 WHERE col1 = ** NOT SPECIFIED **"));
ps.setInt(1, 1);
assertTrue(ps.toString().endsWith("SELECT * FROM testBug104349 WHERE col1 = 1"));
this.rs = ps.executeQuery();
assertTrue(ps.toString().endsWith("SELECT * FROM testBug104349 WHERE col1 = 1"));
while (this.rs.next()) {
assertEquals(1, this.rs.getInt(1));
assertEquals("key 1", this.rs.getString(2));
}
ps.close();
ps = testConn.prepareStatement("SELECT * FROM testBug104349 WHERE col1 = ?");
assertTrue(ps.toString().endsWith("SELECT * FROM testBug104349 WHERE col1 = ** NOT SPECIFIED **"));
ps.setInt(1, 2);
assertTrue(ps.toString().endsWith("SELECT * FROM testBug104349 WHERE col1 = 2"));
this.rs = ps.executeQuery();
assertTrue(ps.toString().endsWith("SELECT * FROM testBug104349 WHERE col1 = 2"));
while (this.rs.next()) {
assertEquals(2, this.rs.getInt(1));
assertEquals("key 2", this.rs.getString(2));
}
testConn.close();

} while (useSPS = !useSPS);
}
}

0 comments on commit 7ad95bc

Please sign in to comment.