Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
7a212e63
提交
7a212e63
authored
6 年前
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix NO MINVALUE|MAXVALUE in ALTER SEQUENCE
上级
f28d45c5
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
60 行增加
和
13 行删除
+60
-13
Parser.java
h2/src/main/org/h2/command/Parser.java
+4
-4
AlterSequence.java
h2/src/main/org/h2/command/ddl/AlterSequence.java
+2
-2
CreateSequence.java
h2/src/main/org/h2/command/ddl/CreateSequence.java
+2
-2
SequenceOptions.java
h2/src/main/org/h2/command/ddl/SequenceOptions.java
+16
-2
Sequence.java
h2/src/main/org/h2/schema/Sequence.java
+2
-2
Column.java
h2/src/main/org/h2/table/Column.java
+1
-1
createSequence.sql
h2/src/test/org/h2/test/scripts/ddl/createSequence.sql
+33
-0
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
7a212e63
...
@@ -6201,20 +6201,20 @@ public class Parser {
...
@@ -6201,20 +6201,20 @@ public class Parser {
}
else
if
(
readIf
(
"MINVALUE"
))
{
}
else
if
(
readIf
(
"MINVALUE"
))
{
options
.
setMinValue
(
readExpression
());
options
.
setMinValue
(
readExpression
());
}
else
if
(
readIf
(
"NOMINVALUE"
))
{
}
else
if
(
readIf
(
"NOMINVALUE"
))
{
options
.
setMinValue
(
null
);
options
.
setMinValue
(
ValueExpression
.
getNull
()
);
}
else
if
(
readIf
(
"MAXVALUE"
))
{
}
else
if
(
readIf
(
"MAXVALUE"
))
{
options
.
setMaxValue
(
readExpression
());
options
.
setMaxValue
(
readExpression
());
}
else
if
(
readIf
(
"NOMAXVALUE"
))
{
}
else
if
(
readIf
(
"NOMAXVALUE"
))
{
options
.
setMaxValue
(
null
);
options
.
setMaxValue
(
ValueExpression
.
getNull
()
);
}
else
if
(
readIf
(
"CYCLE"
))
{
}
else
if
(
readIf
(
"CYCLE"
))
{
options
.
setCycle
(
true
);
options
.
setCycle
(
true
);
}
else
if
(
readIf
(
"NOCYCLE"
))
{
}
else
if
(
readIf
(
"NOCYCLE"
))
{
options
.
setCycle
(
false
);
options
.
setCycle
(
false
);
}
else
if
(
readIf
(
"NO"
))
{
}
else
if
(
readIf
(
"NO"
))
{
if
(
readIf
(
"MINVALUE"
))
{
if
(
readIf
(
"MINVALUE"
))
{
options
.
setMinValue
(
null
);
options
.
setMinValue
(
ValueExpression
.
getNull
()
);
}
else
if
(
readIf
(
"MAXVALUE"
))
{
}
else
if
(
readIf
(
"MAXVALUE"
))
{
options
.
setMaxValue
(
null
);
options
.
setMaxValue
(
ValueExpression
.
getNull
()
);
}
else
if
(
readIf
(
"CYCLE"
))
{
}
else
if
(
readIf
(
"CYCLE"
))
{
options
.
setCycle
(
false
);
options
.
setCycle
(
false
);
}
else
if
(
readIf
(
"CACHE"
))
{
}
else
if
(
readIf
(
"CACHE"
))
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/ddl/AlterSequence.java
浏览文件 @
7a212e63
...
@@ -84,8 +84,8 @@ public class AlterSequence extends SchemaCommand {
...
@@ -84,8 +84,8 @@ public class AlterSequence extends SchemaCommand {
sequence
.
setCacheSize
(
cache
);
sequence
.
setCacheSize
(
cache
);
}
}
if
(
options
.
isRangeSet
())
{
if
(
options
.
isRangeSet
())
{
sequence
.
modify
(
options
.
getStartValue
(
session
),
options
.
getMinValue
(
se
ssion
),
options
.
getMaxValue
(
session
),
sequence
.
modify
(
options
.
getStartValue
(
session
),
options
.
getMinValue
(
se
quence
,
session
),
options
.
getIncrement
(
session
));
options
.
get
MaxValue
(
sequence
,
session
),
options
.
get
Increment
(
session
));
}
}
db
.
updateMeta
(
session
,
sequence
);
db
.
updateMeta
(
session
,
sequence
);
return
0
;
return
0
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/ddl/CreateSequence.java
浏览文件 @
7a212e63
...
@@ -54,8 +54,8 @@ public class CreateSequence extends SchemaCommand {
...
@@ -54,8 +54,8 @@ public class CreateSequence extends SchemaCommand {
}
}
int
id
=
getObjectId
();
int
id
=
getObjectId
();
Sequence
sequence
=
new
Sequence
(
getSchema
(),
id
,
sequenceName
,
options
.
getStartValue
(
session
),
Sequence
sequence
=
new
Sequence
(
getSchema
(),
id
,
sequenceName
,
options
.
getStartValue
(
session
),
options
.
getIncrement
(
session
),
options
.
getCacheSize
(
session
),
options
.
getMinValue
(
session
),
options
.
getIncrement
(
session
),
options
.
getCacheSize
(
session
),
options
.
getMinValue
(
null
,
session
),
options
.
getMaxValue
(
session
),
Boolean
.
TRUE
.
equals
(
options
.
getCycle
()),
belongsToTable
);
options
.
getMaxValue
(
null
,
session
),
Boolean
.
TRUE
.
equals
(
options
.
getCycle
()),
belongsToTable
);
db
.
addSchemaObject
(
session
,
sequence
);
db
.
addSchemaObject
(
session
,
sequence
);
return
0
;
return
0
;
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/ddl/SequenceOptions.java
浏览文件 @
7a212e63
...
@@ -7,6 +7,8 @@ package org.h2.command.ddl;
...
@@ -7,6 +7,8 @@ package org.h2.command.ddl;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.expression.Expression
;
import
org.h2.expression.Expression
;
import
org.h2.expression.ValueExpression
;
import
org.h2.schema.Sequence
;
/**
/**
* Sequence options.
* Sequence options.
...
@@ -45,7 +47,11 @@ public class SequenceOptions {
...
@@ -45,7 +47,11 @@ public class SequenceOptions {
this
.
increment
=
increment
;
this
.
increment
=
increment
;
}
}
public
Long
getMaxValue
(
Session
session
)
{
public
Long
getMaxValue
(
Sequence
sequence
,
Session
session
)
{
if
(
maxValue
==
ValueExpression
.
getNull
()
&&
sequence
!=
null
)
{
return
Sequence
.
getDefaultMaxValue
(
getCurrentStart
(
sequence
,
session
),
increment
!=
null
?
getIncrement
(
session
)
:
sequence
.
getIncrement
());
}
return
getLong
(
session
,
maxValue
);
return
getLong
(
session
,
maxValue
);
}
}
...
@@ -53,10 +59,18 @@ public class SequenceOptions {
...
@@ -53,10 +59,18 @@ public class SequenceOptions {
this
.
maxValue
=
maxValue
;
this
.
maxValue
=
maxValue
;
}
}
public
Long
getMinValue
(
Session
session
)
{
public
Long
getMinValue
(
Sequence
sequence
,
Session
session
)
{
if
(
minValue
==
ValueExpression
.
getNull
()
&&
sequence
!=
null
)
{
return
Sequence
.
getDefaultMinValue
(
getCurrentStart
(
sequence
,
session
),
increment
!=
null
?
getIncrement
(
session
)
:
sequence
.
getIncrement
());
}
return
getLong
(
session
,
minValue
);
return
getLong
(
session
,
minValue
);
}
}
public
long
getCurrentStart
(
Sequence
sequence
,
Session
session
)
{
return
start
!=
null
?
getStartValue
(
session
)
:
sequence
.
getCurrentValue
()
+
sequence
.
getIncrement
();
}
public
void
setMinValue
(
Expression
minValue
)
{
public
void
setMinValue
(
Expression
minValue
)
{
this
.
minValue
=
minValue
;
this
.
minValue
=
minValue
;
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/schema/Sequence.java
浏览文件 @
7a212e63
...
@@ -148,7 +148,7 @@ public class Sequence extends SchemaObjectBase {
...
@@ -148,7 +148,7 @@ public class Sequence extends SchemaObjectBase {
Math
.
abs
(
increment
)
+
Long
.
MIN_VALUE
<=
maxValue
-
minValue
+
Long
.
MIN_VALUE
;
Math
.
abs
(
increment
)
+
Long
.
MIN_VALUE
<=
maxValue
-
minValue
+
Long
.
MIN_VALUE
;
}
}
p
rivate
static
long
getDefaultMinValue
(
Long
startValue
,
long
increment
)
{
p
ublic
static
long
getDefaultMinValue
(
Long
startValue
,
long
increment
)
{
long
v
=
increment
>=
0
?
1
:
Long
.
MIN_VALUE
;
long
v
=
increment
>=
0
?
1
:
Long
.
MIN_VALUE
;
if
(
startValue
!=
null
&&
increment
>=
0
&&
startValue
<
v
)
{
if
(
startValue
!=
null
&&
increment
>=
0
&&
startValue
<
v
)
{
v
=
startValue
;
v
=
startValue
;
...
@@ -156,7 +156,7 @@ public class Sequence extends SchemaObjectBase {
...
@@ -156,7 +156,7 @@ public class Sequence extends SchemaObjectBase {
return
v
;
return
v
;
}
}
p
rivate
static
long
getDefaultMaxValue
(
Long
startValue
,
long
increment
)
{
p
ublic
static
long
getDefaultMaxValue
(
Long
startValue
,
long
increment
)
{
long
v
=
increment
>=
0
?
Long
.
MAX_VALUE
:
-
1
;
long
v
=
increment
>=
0
?
Long
.
MAX_VALUE
:
-
1
;
if
(
startValue
!=
null
&&
increment
<
0
&&
startValue
>
v
)
{
if
(
startValue
!=
null
&&
increment
<
0
&&
startValue
>
v
)
{
v
=
startValue
;
v
=
startValue
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/Column.java
浏览文件 @
7a212e63
...
@@ -456,7 +456,7 @@ public class Column {
...
@@ -456,7 +456,7 @@ public class Column {
}
while
(
schema
.
findSequence
(
sequenceName
)
!=
null
);
}
while
(
schema
.
findSequence
(
sequenceName
)
!=
null
);
Sequence
seq
=
new
Sequence
(
schema
,
id
,
sequenceName
,
autoIncrementOptions
.
getStartValue
(
session
),
Sequence
seq
=
new
Sequence
(
schema
,
id
,
sequenceName
,
autoIncrementOptions
.
getStartValue
(
session
),
autoIncrementOptions
.
getIncrement
(
session
),
autoIncrementOptions
.
getCacheSize
(
session
),
autoIncrementOptions
.
getIncrement
(
session
),
autoIncrementOptions
.
getCacheSize
(
session
),
autoIncrementOptions
.
getMinValue
(
session
),
autoIncrementOptions
.
getMaxValue
(
session
),
autoIncrementOptions
.
getMinValue
(
null
,
session
),
autoIncrementOptions
.
getMaxValue
(
null
,
session
),
Boolean
.
TRUE
.
equals
(
autoIncrementOptions
.
getCycle
()),
true
);
Boolean
.
TRUE
.
equals
(
autoIncrementOptions
.
getCycle
()),
true
);
seq
.
setTemporary
(
temporary
);
seq
.
setTemporary
(
temporary
);
session
.
getDatabase
().
addSchemaObject
(
session
,
seq
);
session
.
getDatabase
().
addSchemaObject
(
session
,
seq
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/scripts/ddl/createSequence.sql
浏览文件 @
7a212e63
...
@@ -45,3 +45,36 @@ DROP SEQUENCE SEQ;
...
@@ -45,3 +45,36 @@ DROP SEQUENCE SEQ;
CREATE
SEQUENCE
SEQ
START
WITH
0
INCREMENT
BY
-
9223372036854775808
MINVALUE
0
MAXVALUE
9223372036854775807
;
CREATE
SEQUENCE
SEQ
START
WITH
0
INCREMENT
BY
-
9223372036854775808
MINVALUE
0
MAXVALUE
9223372036854775807
;
>
exception
SEQUENCE_ATTRIBUTES_INVALID
>
exception
SEQUENCE_ATTRIBUTES_INVALID
CREATE
SEQUENCE
SEQ
START
WITH
0
MINVALUE
-
10
MAXVALUE
10
;
>
ok
SELECT
SEQUENCE_NAME
,
CURRENT_VALUE
,
INCREMENT
,
CACHE
,
MIN_VALUE
,
MAX_VALUE
,
IS_CYCLE
FROM
INFORMATION_SCHEMA
.
SEQUENCES
;
>
SEQUENCE_NAME
CURRENT_VALUE
INCREMENT
CACHE
MIN_VALUE
MAX_VALUE
IS_CYCLE
>
------------- ------------- --------- ----- --------- --------- --------
>
SEQ
-
1
1
32
-
10
10
FALSE
>
rows
:
1
ALTER
SEQUENCE
SEQ
NO
MINVALUE
NO
MAXVALUE
;
>
ok
SELECT
SEQUENCE_NAME
,
CURRENT_VALUE
,
INCREMENT
,
CACHE
,
MIN_VALUE
,
MAX_VALUE
,
IS_CYCLE
FROM
INFORMATION_SCHEMA
.
SEQUENCES
;
>
SEQUENCE_NAME
CURRENT_VALUE
INCREMENT
CACHE
MIN_VALUE
MAX_VALUE
IS_CYCLE
>
------------- ------------- --------- ----- --------- ------------------- --------
>
SEQ
-
1
1
32
0
9223372036854775807
FALSE
>
rows
:
1
ALTER
SEQUENCE
SEQ
MINVALUE
-
100
MAXVALUE
100
;
>
ok
SELECT
SEQUENCE_NAME
,
CURRENT_VALUE
,
INCREMENT
,
CACHE
,
MIN_VALUE
,
MAX_VALUE
,
IS_CYCLE
FROM
INFORMATION_SCHEMA
.
SEQUENCES
;
>
SEQUENCE_NAME
CURRENT_VALUE
INCREMENT
CACHE
MIN_VALUE
MAX_VALUE
IS_CYCLE
>
------------- ------------- --------- ----- --------- --------- --------
>
SEQ
-
1
1
32
-
100
100
FALSE
>
rows
:
1
DROP
SEQUENCE
SEQ
;
>
ok
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论