提交 9df1d17c authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Allow abs(increment) == maxValue - minValue for sequences

上级 bc1b4559
......@@ -143,9 +143,9 @@ public class Sequence extends SchemaObjectBase {
maxValue >= value &&
maxValue > minValue &&
increment != 0 &&
// Math.abs(increment) < maxValue - minValue
// Math.abs(increment) <= maxValue - minValue
// Can use Long.compareUnsigned() on Java 8
Math.abs(increment) + Long.MIN_VALUE < maxValue - minValue + Long.MIN_VALUE;
Math.abs(increment) + Long.MIN_VALUE <= maxValue - minValue + Long.MIN_VALUE;
}
private static long getDefaultMinValue(Long startValue, long increment) {
......
......@@ -125,7 +125,7 @@ public class TestScript extends TestDb {
testScript("datatypes/" + s + ".sql");
}
for (String s : new String[] { "alterTableAdd", "alterTableDropColumn", "alterTableRename",
"createAlias", "createSynonym", "createTable", "createTrigger", "createView",
"createAlias", "createSequence", "createSynonym", "createTable", "createTrigger", "createView",
"dropDomain", "dropIndex", "dropSchema", "truncateTable" }) {
testScript("ddl/" + s + ".sql");
}
......
-- Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
--
CREATE SEQUENCE SEQ START WITH 0 INCREMENT BY 1 MINVALUE 0 MAXVALUE 1;
> ok
DROP SEQUENCE SEQ;
> ok
CREATE SEQUENCE SEQ START WITH 0 INCREMENT BY 1 MINVALUE 0 MAXVALUE 0;
> exception SEQUENCE_ATTRIBUTES_INVALID
CREATE SEQUENCE SEQ START WITH 1 INCREMENT BY 1 MINVALUE 1 MAXVALUE 0;
> exception SEQUENCE_ATTRIBUTES_INVALID
CREATE SEQUENCE SEQ START WITH 0 INCREMENT BY 0 MINVALUE 0 MAXVALUE 1;
> exception SEQUENCE_ATTRIBUTES_INVALID
CREATE SEQUENCE SEQ START WITH 1 INCREMENT BY 1 MINVALUE 2 MAXVALUE 10;
> exception SEQUENCE_ATTRIBUTES_INVALID
CREATE SEQUENCE SEQ START WITH 20 INCREMENT BY 1 MINVALUE 1 MAXVALUE 10;
> exception SEQUENCE_ATTRIBUTES_INVALID
CREATE SEQUENCE SEQ START WITH 0 INCREMENT BY 9223372036854775807 MINVALUE -9223372036854775808 MAXVALUE 9223372036854775807;
> ok
DROP SEQUENCE SEQ;
> ok
CREATE SEQUENCE SEQ START WITH 0 INCREMENT BY -9223372036854775808 MINVALUE -9223372036854775808 MAXVALUE 9223372036854775807;
> ok
DROP SEQUENCE SEQ;
> ok
CREATE SEQUENCE SEQ START WITH 0 INCREMENT BY -9223372036854775808 MINVALUE -1 MAXVALUE 9223372036854775807;
> ok
DROP SEQUENCE SEQ;
> ok
CREATE SEQUENCE SEQ START WITH 0 INCREMENT BY -9223372036854775808 MINVALUE 0 MAXVALUE 9223372036854775807;
> exception SEQUENCE_ATTRIBUTES_INVALID
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论