[CONJ-706] getGeneratedKey implementation correction for multiple result for one query Created: 2019-06-03  Updated: 2019-10-08  Resolved: 2019-08-02

Status: Closed
Project: MariaDB Connector/J
Component/s: batch
Affects Version/s: None
Fix Version/s: 2.4.2

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

Issue Links:
Problem/Incident
causes CONJ-735 Multi insert should return multi gene... Closed
Relates
relates to CONJ-698 Statement#getGeneratedKeys() returns ... Closed

 Description   

When executing a single query, getGeneratedKey currently might return a resultset with multiple keys.

example :
INSERT INTO testMultiGeneratedKey (text) VALUES ('someValue'), ('someOtherValue');

But MariaDB protocol returns only one OK_Packet indicating first automatically generated Id and number of affected rows.

This can cause alternate issues like INSERT ...ON DUPLICATE KEY that return 2 affected rows in case of existing ID. (And so returning 2 rows in getGeneratedKey)

Driver must not trying to be better than what server returns.



 Comments   
Comment by Iwao AVE! [ 2019-08-02 ]

Hi Diego,
Thank you for your work!

I noticed that your closed this issue, but the fix was reverted in [this commit](https://github.com/MariaDB/mariadb-connector-j/commit/fc4a288a5af34b48a4bd57d8d8abfe46dc70cd81) (which, I thought, was reasonable, BTW).

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