Re: IDENTITY() behaviour change - possible regression?

110 views
Skip to first unread message

Peter Rodgers

unread,
Oct 24, 2012, 11:01:28 AM10/24/12
to h2-da...@googlegroups.com
Hi - just wondering if anyone has any ideas?  If this is expected behaviour then we'll have to go with a workaround.

Thanks in advance for any help.

Noel Grandin

unread,
Oct 25, 2012, 4:00:20 AM10/25/12
to h2-da...@googlegroups.com, Peter Rodgers, Thomas Mueller
The change happened in revision 3568 and is related to this issue:
Issue 308: Statement.getGeneratedKeys() now returns an empty result
set if no key was generated.

The relevant code change is in the CommandContainer#update() method,
where it calls session.setLastIdentity(ValueNull.INSTANCE)

Unfortunately I'm not sure how to fix this. Thomas, the easiest way to
test this is:

create table test(id identity primary key);
insert into test values();
set @x = identity();
select @x;

which will return null instead of a valid number.



Noel Grandin

unread,
Oct 26, 2012, 4:45:06 AM10/26/12
to h2-da...@googlegroups.com, Peter Rodgers
I have committed a fix for this to SVN.

On 2012-10-24 17:01, Peter Rodgers wrote:
> --
> You received this message because you are subscribed to the Google
> Groups "H2 Database" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/h2-database/-/xDNOL_-9aI4J.
> To post to this group, send email to h2-da...@googlegroups.com.
> To unsubscribe from this group, send email to
> h2-database...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/h2-database?hl=en.

Peter Rodgers

unread,
Oct 31, 2012, 11:10:08 AM10/31/12
to h2-da...@googlegroups.com, Peter Rodgers

On Friday, 26 October 2012 09:45:09 UTC+1, Noel Grandin wrote:
I have committed a fix for this to SVN.


Great stuff - thanks very much for tracking this down.  Please let me know if there is a snapshot build that we can test for you.

All the best,

Peter
 

Noel Grandin

unread,
Oct 31, 2012, 12:04:00 PM10/31/12
to h2-da...@googlegroups.com, Peter Rodgers
There is a daily build here:
http://www.h2database.com/automated/h2-latest.jar
> --
> You received this message because you are subscribed to the Google Groups
> "H2 Database" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/h2-database/-/1Pctn73XE_cJ.

Peter Rodgers

unread,
Nov 7, 2012, 9:27:39 AM11/7/12
to h2-da...@googlegroups.com, Peter Rodgers
Finally got a chance to try the h2-latest.jar (built 6th November 2012).  I can confirm that this fixes the Identity() regression.

Great stuff - thank you!
Reply all
Reply to author
Forward
0 new messages