google-code-export / h2database

Automatically exported from code.google.com/p/h2database
0 stars 1 forks source link

Statement.getGeneratedKeys() is inconsistent and returns only one row #308

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
*What steps will reproduce the problem?
1. Run the attached program.

*What is the expected output? What do you see instead?

When no key gets generated, null should be returned, as it is the only value 
guaranteed to never come out of any generator in any DB.
Zero may be acceptable, nonetheless, the result should always be of the same 
type. For the last command three rows should be returned.

Instead I get
MERGE INTO t (b) KEY (b) VALUES (1) => 2 Integer
MERGE INTO t (b) KEY (b) VALUES (2) => 0 Long
MERGE INTO t (b) KEY (b) VALUES (3), (4), (5) => 5 Integer

*What version of the product are you using? On what operating system, file 
system, and virtual machine?

The most recent: trunk/h2@3567.

*Do you know a workaround?

For the inconsistecy, there's a trivial workaround using java.lang.Number. For 
the other problem, avoiding multiple values helps. I haven't looked yet at what 
happens for something like

MERGE INTO t (b) KEY (b) SELECT b FROM t2;

Original issue reported on code.google.com by Maaarti...@gmail.com on 7 Apr 2011 at 10:14

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks! I agree the behavior is unexpected. I have change the algorithm so that 
an empty result set is returned if no key is generated in revision 3568.

Original comment by thomas.t...@gmail.com on 8 Apr 2011 at 12:53

GoogleCodeExporter commented 9 years ago
This is fixed in version 1.3.155

Original comment by thomas.t...@gmail.com on 27 May 2011 at 10:54