Bug #39956 | getGenerateyKeys() does not respect auto_increment_increment variable | ||
---|---|---|---|
Submitted: | 9 Oct 2008 16:00 | Modified: | 14 Oct 2008 14:21 |
Reporter: | Christian Schwanke | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / J | Severity: | S1 (Critical) |
Version: | 5.1.6 | OS: | Any |
Assigned to: | Mark Matthews | CPU Architecture: | Any |
Tags: | autoincrement, generated keys |
[9 Oct 2008 16:00]
Christian Schwanke
[10 Oct 2008 6:41]
Christian Schwanke
Patch/Diff for the ConnectionImpl class. The auto_increment_increment variable is added
Attachment: ConnectionImpl.patch (application/octet-stream, text), 1.06 KiB.
[10 Oct 2008 6:42]
Christian Schwanke
Added retrieval of auto_increment_increment variable and modified getGeneratedKeysInternal accordingly
Attachment: StatementImpl.patch (application/octet-stream, text), 1.18 KiB.
[10 Oct 2008 8:11]
Tonci Grgin
Hi Christian and thanks for your report. Checking http://dev.mysql.com/doc/refman/5.1/en/c-api-prepared-statements.html this appears more complex than it looks. It seems prior to 5.1, the server returned "normal" update counts for "ON DUPLICATE KEY UPDATE" (for example), and now it returns *2*. This confuses the JDBC driver's code for creating the result set for getGeneratedKeys(), because it also has to support statements of the form you use ("INSERT INTO ... VALUES (...), (....), (...)..."), which will also have an update count > 1. The server also returns only the "first" generated key for a statement, the rest have to be "computed" (more like "divined" in the case of REPLACE and "ON DUPLICATE KEY UPDATE")... Let me check on code, probably your problem can be dealt with more quickly than wholesome solution.
[10 Oct 2008 8:22]
Tonci Grgin
Verified as described by looking into latest sources. c/J pays no attention to "auto_increment_increment" variable available since 5.0.2 and 5.0.47-cluster. This can cause serious problems to users thus such severe triage. Will notify Mark ASAP.
[13 Oct 2008 14:44]
Mark Matthews
Fixed for 5.1.7.
[14 Oct 2008 14:21]
Tony Bedford
An entry was added to the 5.1.7 changelog: Connector/J ignored the value of the MySQL Server variable auto_increment_increment.
[20 Oct 2010 0:14]
Greg Gilles
I'm using the mysql-connector-odbc-5.1.7-winx64.msi. I've linked to MYSQL from Microsoft Access 2007. I'm having what appears to be the same problem; Microsoft Access is disregarding the auto_increment_increment setting and just adding 1 each time.
[20 Oct 2010 6:45]
Tonci Grgin
Greg, could you please open a new bug report (for c/ODBC) and be more specific there? Probably a good thing would be to provide ODBC traces, see our docs on how to do that.