Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
48a8b9c7
提交
48a8b9c7
authored
11 年前
作者:
noelgrandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix bug in calculating default MIN and MAX values for SEQUENCE
上级
c11011ec
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
28 行增加
和
8 行删除
+28
-8
changelog.html
h2/src/docsrc/html/changelog.html
+1
-0
Sequence.java
h2/src/main/org/h2/schema/Sequence.java
+16
-8
TestSequence.java
h2/src/test/org/h2/test/db/TestSequence.java
+11
-0
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
48a8b9c7
...
@@ -20,6 +20,7 @@ Change Log
...
@@ -20,6 +20,7 @@ Change Log
<h2>
Next Version (unreleased)
</h2>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
Storing LOBs in separate files (outside of the database) is no longer supported for new databases.
<ul><li>
Storing LOBs in separate files (outside of the database) is no longer supported for new databases.
</li><li>
Lucene 2 is no longer supported.
</li><li>
Lucene 2 is no longer supported.
</li><li>
Fix bug in calculating default MIN and MAX values for SEQUENCE
</li></ul>
</li></ul>
<h2>
Version 1.3.175 (2014-01-18)
</h2>
<h2>
Version 1.3.175 (2014-01-18)
</h2>
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/schema/Sequence.java
浏览文件 @
48a8b9c7
...
@@ -66,8 +66,8 @@ public class Sequence extends SchemaObjectBase {
...
@@ -66,8 +66,8 @@ public class Sequence extends SchemaObjectBase {
Long
minValue
,
Long
maxValue
,
boolean
cycle
,
boolean
belongsToTable
)
{
Long
minValue
,
Long
maxValue
,
boolean
cycle
,
boolean
belongsToTable
)
{
initSchemaObjectBase
(
schema
,
id
,
name
,
Trace
.
SEQUENCE
);
initSchemaObjectBase
(
schema
,
id
,
name
,
Trace
.
SEQUENCE
);
this
.
increment
=
increment
!=
null
?
increment
:
1
;
this
.
increment
=
increment
!=
null
?
increment
:
1
;
this
.
minValue
=
minValue
!=
null
?
minValue
:
getDefaultMinValue
(
this
.
increment
);
this
.
minValue
=
minValue
!=
null
?
minValue
:
getDefaultMinValue
(
startValue
,
this
.
increment
);
this
.
maxValue
=
maxValue
!=
null
?
maxValue
:
getDefaultMaxValue
(
this
.
increment
);
this
.
maxValue
=
maxValue
!=
null
?
maxValue
:
getDefaultMaxValue
(
startValue
,
this
.
increment
);
this
.
value
=
startValue
!=
null
?
startValue
:
getDefaultStartValue
(
this
.
increment
);
this
.
value
=
startValue
!=
null
?
startValue
:
getDefaultStartValue
(
this
.
increment
);
this
.
valueWithMargin
=
value
;
this
.
valueWithMargin
=
value
;
this
.
cacheSize
=
cacheSize
!=
null
?
Math
.
max
(
1
,
cacheSize
)
:
DEFAULT_CACHE_SIZE
;
this
.
cacheSize
=
cacheSize
!=
null
?
Math
.
max
(
1
,
cacheSize
)
:
DEFAULT_CACHE_SIZE
;
...
@@ -136,12 +136,20 @@ public class Sequence extends SchemaObjectBase {
...
@@ -136,12 +136,20 @@ public class Sequence extends SchemaObjectBase {
BigInteger
.
valueOf
(
maxValue
).
subtract
(
BigInteger
.
valueOf
(
minValue
)))
<
0
;
BigInteger
.
valueOf
(
maxValue
).
subtract
(
BigInteger
.
valueOf
(
minValue
)))
<
0
;
}
}
private
static
long
getDefaultMinValue
(
long
increment
)
{
private
static
long
getDefaultMinValue
(
Long
startValue
,
long
increment
)
{
return
increment
>=
0
?
1
:
Long
.
MIN_VALUE
;
long
v
=
increment
>=
0
?
1
:
Long
.
MIN_VALUE
;
if
(
startValue
!=
null
&&
increment
>=
0
&&
startValue
<
v
)
{
v
=
startValue
;
}
return
v
;
}
}
private
static
long
getDefaultMaxValue
(
long
increment
)
{
private
static
long
getDefaultMaxValue
(
Long
startValue
,
long
increment
)
{
return
increment
>=
0
?
Long
.
MAX_VALUE
:
-
1
;
long
v
=
increment
>=
0
?
Long
.
MAX_VALUE
:
-
1
;
if
(
startValue
!=
null
&&
increment
<
0
&&
startValue
>
v
)
{
v
=
startValue
;
}
return
v
;
}
}
private
long
getDefaultStartValue
(
long
increment
)
{
private
long
getDefaultStartValue
(
long
increment
)
{
...
@@ -192,10 +200,10 @@ public class Sequence extends SchemaObjectBase {
...
@@ -192,10 +200,10 @@ public class Sequence extends SchemaObjectBase {
if
(
increment
!=
1
)
{
if
(
increment
!=
1
)
{
buff
.
append
(
" INCREMENT BY "
).
append
(
increment
);
buff
.
append
(
" INCREMENT BY "
).
append
(
increment
);
}
}
if
(
minValue
!=
getDefaultMinValue
(
increment
))
{
if
(
minValue
!=
getDefaultMinValue
(
value
,
increment
))
{
buff
.
append
(
" MINVALUE "
).
append
(
minValue
);
buff
.
append
(
" MINVALUE "
).
append
(
minValue
);
}
}
if
(
maxValue
!=
getDefaultMaxValue
(
increment
))
{
if
(
maxValue
!=
getDefaultMaxValue
(
value
,
increment
))
{
buff
.
append
(
" MAXVALUE "
).
append
(
maxValue
);
buff
.
append
(
" MAXVALUE "
).
append
(
maxValue
);
}
}
if
(
cycle
)
{
if
(
cycle
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/db/TestSequence.java
浏览文件 @
48a8b9c7
...
@@ -41,6 +41,7 @@ public class TestSequence extends TestBase {
...
@@ -41,6 +41,7 @@ public class TestSequence extends TestBase {
testCreateWithMaxValue
();
testCreateWithMaxValue
();
testCreationErrors
();
testCreationErrors
();
testCreateSql
();
testCreateSql
();
testDefaultMinMax
();
deleteDb
(
"sequence"
);
deleteDb
(
"sequence"
);
}
}
...
@@ -252,6 +253,16 @@ public class TestSequence extends TestBase {
...
@@ -252,6 +253,16 @@ public class TestSequence extends TestBase {
conn
.
close
();
conn
.
close
();
}
}
private
void
testDefaultMinMax
()
throws
SQLException
{
// test that we calculate default MIN and MAX values correctly
deleteDb
(
"sequence"
);
Connection
conn
=
getConnection
(
"sequence"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create sequence a START WITH -7320917853639540658"
);
stat
.
execute
(
"create sequence b START WITH 7320917853639540658 INCREMENT -1"
);
conn
.
close
();
}
private
void
testTwo
()
throws
SQLException
{
private
void
testTwo
()
throws
SQLException
{
deleteDb
(
"sequence"
);
deleteDb
(
"sequence"
);
Connection
conn
=
getConnection
(
"sequence"
);
Connection
conn
=
getConnection
(
"sequence"
);
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论