提交 4ddf3347 authored 作者: noelgrandin's avatar noelgrandin

Fix in calling SET @X = IDENTITY() where it would return NULL incorrectly

上级 b730eb70
...@@ -22,6 +22,7 @@ Change Log ...@@ -22,6 +22,7 @@ Change Log
Thanks to Prashant Bhat for the patch! Thanks to Prashant Bhat for the patch!
</li><li>Fix for a bug where we would sometimes use the wrong unique constraint to validate foreign key constraints. </li><li>Fix for a bug where we would sometimes use the wrong unique constraint to validate foreign key constraints.
</li><li>Support BOM at the beginning of files for the RUNSCRIPT command </li><li>Support BOM at the beginning of files for the RUNSCRIPT command
</li><li>Fix in calling SET @X = IDENTITY() where it would return NULL incorrectly
</li></ul> </li></ul>
<h2>Version 1.3.169 (2012-09-09)</h2> <h2>Version 1.3.169 (2012-09-09)</h2>
......
...@@ -70,7 +70,7 @@ class CommandContainer extends Command { ...@@ -70,7 +70,7 @@ class CommandContainer extends Command {
recompileIfRequired(); recompileIfRequired();
setProgress(DatabaseEventListener.STATE_STATEMENT_START); setProgress(DatabaseEventListener.STATE_STATEMENT_START);
start(); start();
session.setLastIdentity(ValueNull.INSTANCE); session.setLastScopeIdentity(ValueNull.INSTANCE);
prepared.checkParameters(); prepared.checkParameters();
int updateCount = prepared.update(); int updateCount = prepared.update();
prepared.trace(startTime, updateCount); prepared.trace(startTime, updateCount);
......
...@@ -707,8 +707,8 @@ public class Session extends SessionWithState { ...@@ -707,8 +707,8 @@ public class Session extends SessionWithState {
} }
public void setLastIdentity(Value last) { public void setLastIdentity(Value last) {
this.lastScopeIdentity = last;
this.lastIdentity = last; this.lastIdentity = last;
this.lastScopeIdentity = last;
} }
public Value getLastIdentity() { public Value getLastIdentity() {
......
...@@ -335,7 +335,16 @@ public class TestStatement extends TestBase { ...@@ -335,7 +335,16 @@ public class TestStatement extends TestBase {
rs.next(); rs.next();
assertEquals(7, rs.getInt(1)); assertEquals(7, rs.getInt(1));
assertFalse(rs.next()); assertFalse(rs.next());
stat.execute("CREATE TABLE TEST2(ID identity primary key)");
stat.execute("INSERT INTO TEST2 VALUES()");
stat.execute("SET @X = IDENTITY()");
rs = stat.executeQuery("SELECT @X");
rs.next();
assertEquals(1, rs.getInt(1));
stat.execute("DROP TABLE TEST"); stat.execute("DROP TABLE TEST");
stat.execute("DROP TABLE TEST2");
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论