Unverified 提交 edb5cf4f authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #1767 from katzyn/sequence

Use Sequence.flush() in AlterSequence to avoid concurrent update exception
...@@ -21,6 +21,8 @@ Change Log ...@@ -21,6 +21,8 @@ Change Log
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul> <ul>
<li>Issue #1758: sequence restart issue with 1.4.198
</li>
<li>Issue #1759: SELECT &#8230; FOR UPDATE returns old data in 1.4.198 <li>Issue #1759: SELECT &#8230; FOR UPDATE returns old data in 1.4.198
</li> </li>
<li>PR #1756: Fix DISTINCT ON in presence of ORDER BY <li>PR #1756: Fix DISTINCT ON in presence of ORDER BY
......
...@@ -7,7 +7,6 @@ package org.h2.command.ddl; ...@@ -7,7 +7,6 @@ package org.h2.command.ddl;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.command.CommandInterface; import org.h2.command.CommandInterface;
import org.h2.engine.Database;
import org.h2.engine.Right; import org.h2.engine.Right;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.message.DbException; import org.h2.message.DbException;
...@@ -62,7 +61,6 @@ public class AlterSequence extends SchemaCommand { ...@@ -62,7 +61,6 @@ public class AlterSequence extends SchemaCommand {
@Override @Override
public int update() { public int update() {
Database db = session.getDatabase();
if (sequence == null) { if (sequence == null) {
sequence = getSchema().findSequence(sequenceName); sequence = getSchema().findSequence(sequenceName);
if (sequence == null) { if (sequence == null) {
...@@ -87,7 +85,7 @@ public class AlterSequence extends SchemaCommand { ...@@ -87,7 +85,7 @@ public class AlterSequence extends SchemaCommand {
sequence.modify(options.getStartValue(session), options.getMinValue(sequence, session), sequence.modify(options.getStartValue(session), options.getMinValue(sequence, session),
options.getMaxValue(sequence, session), options.getIncrement(session)); options.getMaxValue(sequence, session), options.getIncrement(session));
} }
db.updateMeta(session, sequence); sequence.flush(session);
return 0; return 0;
} }
......
...@@ -78,3 +78,23 @@ SELECT SEQUENCE_NAME, CURRENT_VALUE, INCREMENT, CACHE, MIN_VALUE, MAX_VALUE, IS_ ...@@ -78,3 +78,23 @@ SELECT SEQUENCE_NAME, CURRENT_VALUE, INCREMENT, CACHE, MIN_VALUE, MAX_VALUE, IS_
DROP SEQUENCE SEQ; DROP SEQUENCE SEQ;
> ok > ok
SET AUTOCOMMIT OFF;
> ok
CREATE SEQUENCE SEQ;
> ok
ALTER SEQUENCE SEQ RESTART WITH 1;
> ok
SELECT NEXT VALUE FOR SEQ;
>> 1
DROP SEQUENCE SEQ;
> ok
COMMIT;
> ok
SET AUTOCOMMIT ON;
> ok
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论