提交 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
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>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>
<h2>Version 1.3.169 (2012-09-09)</h2>
......
......@@ -70,7 +70,7 @@ class CommandContainer extends Command {
recompileIfRequired();
setProgress(DatabaseEventListener.STATE_STATEMENT_START);
start();
session.setLastIdentity(ValueNull.INSTANCE);
session.setLastScopeIdentity(ValueNull.INSTANCE);
prepared.checkParameters();
int updateCount = prepared.update();
prepared.trace(startTime, updateCount);
......
......@@ -707,8 +707,8 @@ public class Session extends SessionWithState {
}
public void setLastIdentity(Value last) {
this.lastScopeIdentity = last;
this.lastIdentity = last;
this.lastScopeIdentity = last;
}
public Value getLastIdentity() {
......
......@@ -335,7 +335,16 @@ public class TestStatement extends TestBase {
rs.next();
assertEquals(7, rs.getInt(1));
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 TEST2");
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论