Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Statement.getGeneratedKeys() returns unexpected value #484

Closed
dwenking opened this issue Oct 30, 2023 · 3 comments
Closed

Statement.getGeneratedKeys() returns unexpected value #484

dwenking opened this issue Oct 30, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@dwenking
Copy link

dwenking commented Oct 30, 2023

Describe the bug

In my test case, when I use Statement to execute and then attempt to retrieve the latest GeneratedKeys, I expect to get a value of 3.
However, the returned values are 1 and 2, which are the values I inserted previously. I think this behavior is incorrect. I also have this test case on MariaDB Connector J, and it returns 3. I think 3 may be more reasonable.

Expected Behavior

See bug description.

Current Behavior

See bug description.

Reproduction Steps

@Test
public void test() throws SQLException {
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?user=user&password=password");
    Statement stmt = con.createStatement();
    stmt.addBatch("DROP TABLE IF EXISTS table0_0;");
    stmt.addBatch("CREATE TABLE table0_0(id INT AUTO_INCREMENT PRIMARY KEY,value INT);");
    stmt.addBatch("INSERT INTO table0_0 VALUES(1, -179653912)");
    stmt.addBatch("INSERT INTO table0_0 VALUES(2, 1207965915)");
    stmt.executeBatch();

    stmt.executeUpdate("INSERT INTO table0_0 (value) VALUES(667711856)", Statement.RETURN_GENERATED_KEYS);
    ResultSet rs = stmt.getGeneratedKeys();
    while (rs.next()) {
        System.out.println(rs.getInt(1));
    }
}

Possible Solution

No response

Additional Information/Context

No response

The AWS JDBC Driver for MySQL version used

1.1.10

JDK version used

20

Operating System and version

Windows

@dwenking dwenking added the bug Something isn't working label Oct 30, 2023
@brunos-bq
Copy link

Hi @dwenking,

Thanks for reaching out and raising this issue.

We'll take a look at this and keep you updated as we investigate.

Thank you for your patience!

@crystall-bitquill
Copy link
Contributor

Hi @dwenking,

A fix for this issue (PR #490) was merged recently and was included in the latest release of the driver, version 1.1.11. Could you kindly check it out and let us know if the issue persists?

Thank you!

@crystall-bitquill
Copy link
Contributor

Hi @dwenking,

I wanted to check in and see if you were able to verify that the fix resolved the issue. If there are no further updates on this ticket in the next few days, it will be closed. However, if you have other questions or concerns, please feel free to reach out again.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants