[CONJ-1128] Setting Negative Fetch Size on ResultSet Without Throwing Error Created: 2023-11-21  Updated: 2023-11-22  Resolved: 2023-11-22

Status: Closed
Project: MariaDB Connector/J
Component/s: JDBC compatibility
Affects Version/s: 3.3.0
Fix Version/s: 3.3.1

Type: Bug Priority: Major
Reporter: Wenqian Deng Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None


 Description   

According to JDBC specifications, setting a fetch size with a negative value on a ResultSet should result in an SQLException.
However, in the provided test case, when the fetch size is set to -2 on a ResultSet, the connector accepts this value without throwing any exception, which is contrary to the expected behavior.

@Test
public void test5() throws SQLException {
    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;
    con = DriverManager.getConnection("jdbc:mariadb://localhost:3366/test968?user=user&password=password");
    stmt = con.createStatement();
    stmt.execute("CREATE TABLE t0(id INT PRIMARY KEY AUTO_INCREMENT,value FLOAT);");
    stmt = con.createStatement();
    stmt.addBatch("INSERT INTO t0 (value)  VALUES(0.05)");
    stmt.addBatch("DELETE FROM t0 WHERE id <= 2");
    stmt.addBatch("INSERT INTO t0 (value) VALUES(0.03)");
    stmt.executeBatch();
    rs = stmt.getGeneratedKeys();
    rs.setFetchSize(-2); // not throw error
}



 Comments   
Comment by Diego Dupin [ 2023-11-22 ]

right, i've taken care of that at same time than CONJ-1126, but I'll take advantage of this task to add a non-regression test

Comment by Diego Dupin [ 2023-11-22 ]

test case added with https://github.com/mariadb-corporation/mariadb-connector-j/commit/7b8db20fd1a7615c6dd3157d1521041a46bf5c61

Generated at Thu Feb 08 03:20:50 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.