Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
6089c852
提交
6089c852
authored
11月 13, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Formatting / Javadocs
上级
5d727252
显示空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
99 行增加
和
53 行删除
+99
-53
AlterSequence.java
h2/src/main/org/h2/command/dml/AlterSequence.java
+5
-5
BackupCommand.java
h2/src/main/org/h2/command/dml/BackupCommand.java
+1
-1
Replace.java
h2/src/main/org/h2/command/dml/Replace.java
+1
-1
SpatialTreeIndex.java
h2/src/main/org/h2/index/SpatialTreeIndex.java
+2
-8
Sequence.java
h2/src/main/org/h2/schema/Sequence.java
+24
-6
Task.java
h2/src/main/org/h2/util/Task.java
+2
-2
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+4
-2
TestLob.java
h2/src/test/org/h2/test/db/TestLob.java
+10
-4
TestReplace.java
h2/src/test/org/h2/test/db/TestReplace.java
+8
-2
TestSequence.java
h2/src/test/org/h2/test/db/TestSequence.java
+31
-16
TestView.java
h2/src/test/org/h2/test/db/TestView.java
+6
-2
CacheLIRS.java
h2/src/tools/org/h2/dev/cache/CacheLIRS.java
+5
-4
没有找到文件。
h2/src/main/org/h2/command/dml/AlterSequence.java
浏览文件 @
6089c852
h2/src/main/org/h2/command/dml/BackupCommand.java
浏览文件 @
6089c852
...
...
@@ -61,7 +61,7 @@ public class BackupCommand extends Prepared {
try
{
Store
store
=
db
.
getMvStore
();
if
(
store
!=
null
)
{
store
.
store
();
store
.
flush
();
}
String
name
=
db
.
getName
();
name
=
FileUtils
.
getName
(
name
);
...
...
h2/src/main/org/h2/command/dml/Replace.java
浏览文件 @
6089c852
h2/src/main/org/h2/index/SpatialTreeIndex.java
浏览文件 @
6089c852
...
...
@@ -43,7 +43,6 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
private
boolean
closed
;
private
boolean
needRebuild
;
private
boolean
persistent
;
/**
* Constructor.
...
...
@@ -52,8 +51,8 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
* @param id the index id
* @param indexName the index name
* @param columns the indexed columns (only one geometry column allowed)
* @param persistent whether the index should be persisted
* @param indexType the index type (only spatial index)
* @param persistent whether the index data should be persisted
* @param create whether to create a new index
* @param session the session.
*/
...
...
@@ -80,7 +79,6 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
}
initBaseIndex
(
table
,
id
,
indexName
,
columns
,
indexType
);
this
.
needRebuild
=
create
;
this
.
persistent
=
persistent
;
this
.
table
=
table
;
if
(!
database
.
isStarting
())
{
if
(
columns
[
0
].
column
.
getType
()
!=
Value
.
GEOMETRY
)
{
...
...
@@ -111,11 +109,7 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
@Override
public
void
close
(
Session
session
)
{
if
(
persistent
)
{
store
.
store
();
}
else
{
store
.
close
();
}
closed
=
true
;
}
...
...
h2/src/main/org/h2/schema/Sequence.java
浏览文件 @
6089c852
...
...
@@ -36,6 +36,12 @@ public class Sequence extends SchemaObjectBase {
/**
* Creates a new sequence for an auto-increment column.
*
* @param schema the schema
* @param id the object id
* @param name the sequence name
* @param startValue the first value to return
* @param increment the increment count
*/
public
Sequence
(
Schema
schema
,
int
id
,
String
name
,
long
startValue
,
long
increment
)
{
this
(
schema
,
id
,
name
,
startValue
,
increment
,
null
,
null
,
null
,
false
,
true
);
...
...
@@ -43,6 +49,18 @@ public class Sequence extends SchemaObjectBase {
/**
* Creates a new sequence.
*
* @param schema the schema
* @param id the object id
* @param name the sequence name
* @param startValue the first value to return
* @param increment the increment count
* @param cacheSize the number of entries to pre-fetch
* @param minValue the minimum value
* @param maxValue the maximum value
* @param cycle whether to jump back to the min value if needed
* @param belongsToTable whether this sequence belongs to a table (for
* auto-increment columns)
*/
public
Sequence
(
Schema
schema
,
int
id
,
String
name
,
Long
startValue
,
Long
increment
,
Long
cacheSize
,
Long
minValue
,
Long
maxValue
,
boolean
cycle
,
boolean
belongsToTable
)
{
...
...
@@ -98,9 +116,9 @@ public class Sequence extends SchemaObjectBase {
}
/**
* Validates the specified prospective start value, min value, max value and
increment relative
*
to each other, since each of their respective validities are contingent on the values of th
e
* other parameters.
* Validates the specified prospective start value, min value, max value and
*
increment relative to each other, since each of their respectiv
e
*
validities are contingent on the values of the
other parameters.
*
* @param value the prospective start value
* @param minValue the prospective min value
...
...
@@ -118,11 +136,11 @@ public class Sequence extends SchemaObjectBase {
BigInteger
.
valueOf
(
maxValue
).
subtract
(
BigInteger
.
valueOf
(
minValue
)))
<
0
;
}
private
long
getDefaultMinValue
(
long
increment
)
{
private
static
long
getDefaultMinValue
(
long
increment
)
{
return
increment
>=
0
?
1
:
Long
.
MIN_VALUE
;
}
private
long
getDefaultMaxValue
(
long
increment
)
{
private
static
long
getDefaultMaxValue
(
long
increment
)
{
return
increment
>=
0
?
Long
.
MAX_VALUE
:
-
1
;
}
...
...
h2/src/main/org/h2/util/Task.java
浏览文件 @
6089c852
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
6089c852
...
...
@@ -232,6 +232,7 @@ java org.h2.test.TestAll timer
*/
;
private
static
final
boolean
MV_STORE
=
true
;
/**
...
...
@@ -772,9 +773,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
new
TestFile
().
runTest
(
this
);
new
TestFileLock
().
runTest
(
this
);
new
TestFileLockProcess
().
runTest
(
this
);
new
TestFileLockSerialized
().
runTest
(
this
);
new
TestFtp
().
runTest
(
this
);
new
TestFileSystem
().
runTest
(
this
);
new
TestIntArray
().
runTest
(
this
);
...
...
@@ -804,7 +803,10 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
new
TestStringUtils
().
runTest
(
this
);
new
TestTools
().
runTest
(
this
);
new
TestTraceSystem
().
runTest
(
this
);
;
// TODO
new
TestUpgrade
().
runTest
(
this
);
new
TestUtils
().
runTest
(
this
);
new
TestValue
().
runTest
(
this
);
new
TestValueHashMap
().
runTest
(
this
);
...
...
h2/src/test/org/h2/test/db/TestLob.java
浏览文件 @
6089c852
...
...
@@ -46,6 +46,11 @@ import org.h2.value.ValueLob;
*/
public
class
TestLob
extends
TestBase
{
private
static
final
String
MORE_THAN_128_CHARS
=
"12345678901234567890123456789012345678901234567890"
+
"12345678901234567890123456789012345678901234567890"
+
"12345678901234567890123456789"
;
/**
* Run just this test.
*
...
...
@@ -1487,8 +1492,6 @@ public class TestLob extends TestBase {
conn
.
close
();
}
private
static
final
String
MORE_THAN_128_CHARS
=
"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
;
private
void
testCommitOnExclusiveConnection
()
throws
Exception
{
deleteDb
(
"lob"
);
Connection
conn
=
getConnection
(
"lob;EXCLUSIVE=1"
);
...
...
@@ -1498,8 +1501,11 @@ public class TestLob extends TestBase {
conn
.
setAutoCommit
(
false
);
statement
.
execute
(
"insert into TEST (COL, LOB) values (1, '"
+
MORE_THAN_128_CHARS
+
"')"
);
statement
.
execute
(
"update TEST set COL=2"
);
// statement.execute("commit"); // OK
conn
.
commit
();
// KO : should not hang
// OK
// statement.execute("commit");
// KO : should not hang
conn
.
commit
();
conn
.
close
();
}
}
h2/src/test/org/h2/test/db/TestReplace.java
浏览文件 @
6089c852
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: Cemo
*/
package
org
.
h2
.
test
.
db
;
import
org.h2.test.TestBase
;
...
...
h2/src/test/org/h2/test/db/TestSequence.java
浏览文件 @
6089c852
...
...
@@ -156,12 +156,17 @@ public class TestSequence extends TestBase {
private
void
testCreateWithMinValue
()
throws
SQLException
{
test
(
"create sequence s minvalue 3"
,
null
,
3
,
4
,
5
,
6
);
test
(
"create sequence s minvalue -3 increment by -1 cycle"
,
null
,
-
1
,
-
2
,
-
3
,
-
1
);
test
(
"create sequence s minvalue -3 increment by -1"
,
"Sequence \"S\" has run out of numbers"
,
-
1
,
-
2
,
-
3
);
test
(
"create sequence s minvalue -3 increment by -1 nocycle"
,
"Sequence \"S\" has run out of numbers"
,
-
1
,
-
2
,
-
3
);
test
(
"create sequence s minvalue -3 increment by -1 no cycle"
,
"Sequence \"S\" has run out of numbers"
,
-
1
,
-
2
,
-
3
);
test
(
"create sequence s minvalue -3 increment by -1"
,
"Sequence \"S\" has run out of numbers"
,
-
1
,
-
2
,
-
3
);
test
(
"create sequence s minvalue -3 increment by -1 nocycle"
,
"Sequence \"S\" has run out of numbers"
,
-
1
,
-
2
,
-
3
);
test
(
"create sequence s minvalue -3 increment by -1 no cycle"
,
"Sequence \"S\" has run out of numbers"
,
-
1
,
-
2
,
-
3
);
test
(
"create sequence s minvalue -3 increment by -1 nocache cycle"
,
null
,
-
1
,
-
2
,
-
3
,
-
1
);
test
(
"create sequence s minvalue -3 increment by -1 nocache"
,
"Sequence \"S\" has run out of numbers"
,
-
1
,
-
2
,
-
3
);
test
(
"create sequence s minvalue -3 increment by -1 nocache nocycle"
,
"Sequence \"S\" has run out of numbers"
,
-
1
,
-
2
,
-
3
);
test
(
"create sequence s minvalue -3 increment by -1 nocache"
,
"Sequence \"S\" has run out of numbers"
,
-
1
,
-
2
,
-
3
);
test
(
"create sequence s minvalue -3 increment by -1 nocache nocycle"
,
"Sequence \"S\" has run out of numbers"
,
-
1
,
-
2
,
-
3
);
test
(
"create sequence s minvalue -3 increment by -1 no cache no cycle"
,
"Sequence \"S\" has run out of numbers"
,
-
1
,
-
2
,
-
3
);
}
...
...
@@ -169,13 +174,19 @@ public class TestSequence extends TestBase {
private
void
testCreateWithMaxValue
()
throws
SQLException
{
test
(
"create sequence s maxvalue -3 increment by -1"
,
null
,
-
3
,
-
4
,
-
5
,
-
6
);
test
(
"create sequence s maxvalue 3 cycle"
,
null
,
1
,
2
,
3
,
1
);
test
(
"create sequence s maxvalue 3"
,
"Sequence \"S\" has run out of numbers"
,
1
,
2
,
3
);
test
(
"create sequence s maxvalue 3 nocycle"
,
"Sequence \"S\" has run out of numbers"
,
1
,
2
,
3
);
test
(
"create sequence s maxvalue 3 no cycle"
,
"Sequence \"S\" has run out of numbers"
,
1
,
2
,
3
);
test
(
"create sequence s maxvalue 3"
,
"Sequence \"S\" has run out of numbers"
,
1
,
2
,
3
);
test
(
"create sequence s maxvalue 3 nocycle"
,
"Sequence \"S\" has run out of numbers"
,
1
,
2
,
3
);
test
(
"create sequence s maxvalue 3 no cycle"
,
"Sequence \"S\" has run out of numbers"
,
1
,
2
,
3
);
test
(
"create sequence s maxvalue 3 nocache cycle"
,
null
,
1
,
2
,
3
,
1
);
test
(
"create sequence s maxvalue 3 nocache"
,
"Sequence \"S\" has run out of numbers"
,
1
,
2
,
3
);
test
(
"create sequence s maxvalue 3 nocache nocycle"
,
"Sequence \"S\" has run out of numbers"
,
1
,
2
,
3
);
test
(
"create sequence s maxvalue 3 no cache no cycle"
,
"Sequence \"S\" has run out of numbers"
,
1
,
2
,
3
);
test
(
"create sequence s maxvalue 3 nocache"
,
"Sequence \"S\" has run out of numbers"
,
1
,
2
,
3
);
test
(
"create sequence s maxvalue 3 nocache nocycle"
,
"Sequence \"S\" has run out of numbers"
,
1
,
2
,
3
);
test
(
"create sequence s maxvalue 3 no cache no cycle"
,
"Sequence \"S\" has run out of numbers"
,
1
,
2
,
3
);
}
private
void
testCreationErrors
()
throws
SQLException
{
...
...
@@ -215,8 +226,10 @@ public class TestSequence extends TestBase {
Connection
conn
=
getConnection
(
"sequence"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create sequence a"
);
stat
.
execute
(
"create sequence b start with 5 increment by 2 minvalue 3 maxvalue 7 cycle nocache"
);
stat
.
execute
(
"create sequence c start with 3 increment by 1 minvalue 2 maxvalue 9 nocycle cache 2"
);
stat
.
execute
(
"create sequence b start with 5 increment by 2 "
+
"minvalue 3 maxvalue 7 cycle nocache"
);
stat
.
execute
(
"create sequence c start with 3 increment by 1 "
+
"minvalue 2 maxvalue 9 nocycle cache 2"
);
stat
.
execute
(
"create sequence d nomaxvalue no minvalue no cache nocycle"
);
stat
.
execute
(
"create sequence e cache 1"
);
List
<
String
>
script
=
new
ArrayList
<
String
>();
...
...
@@ -226,8 +239,10 @@ public class TestSequence extends TestBase {
}
Collections
.
sort
(
script
);
assertEquals
(
"CREATE SEQUENCE PUBLIC.A START WITH 1;"
,
script
.
get
(
0
));
assertEquals
(
"CREATE SEQUENCE PUBLIC.B START WITH 5 INCREMENT BY 2 MINVALUE 3 MAXVALUE 7 CYCLE CACHE 1;"
,
script
.
get
(
1
));
assertEquals
(
"CREATE SEQUENCE PUBLIC.C START WITH 3 MINVALUE 2 MAXVALUE 9 CACHE 2;"
,
script
.
get
(
2
));
assertEquals
(
"CREATE SEQUENCE PUBLIC.B START WITH 5 INCREMENT BY 2 "
+
"MINVALUE 3 MAXVALUE 7 CYCLE CACHE 1;"
,
script
.
get
(
1
));
assertEquals
(
"CREATE SEQUENCE PUBLIC.C START WITH 3 MINVALUE 2 MAXVALUE 9 CACHE 2;"
,
script
.
get
(
2
));
assertEquals
(
"CREATE SEQUENCE PUBLIC.D START WITH 1 CACHE 1;"
,
script
.
get
(
3
));
assertEquals
(
"CREATE SEQUENCE PUBLIC.E START WITH 1 CACHE 1;"
,
script
.
get
(
4
));
conn
.
close
();
...
...
h2/src/test/org/h2/test/db/TestView.java
浏览文件 @
6089c852
...
...
@@ -207,7 +207,10 @@ public class TestView extends TestBase {
deleteDb
(
"view"
);
}
/** make sure that when we change a view, that change in reflected in other sessions command cache */
/**
* Make sure that when we change a view, that change in reflected in other
* sessions command cache.
*/
private
void
testViewAlterAndCommandCache
()
throws
SQLException
{
deleteDb
(
"view"
);
Connection
conn
=
getConnection
(
"view"
);
...
...
@@ -227,4 +230,5 @@ public class TestView extends TestBase {
conn
.
close
();
deleteDb
(
"view"
);
}
}
h2/src/tools/org/h2/dev/cache/CacheLIRS.java
浏览文件 @
6089c852
...
...
@@ -423,8 +423,6 @@ public class CacheLIRS<K, V> extends AbstractMap<K, V> {
*/
static
class
Segment
<
K
,
V
>
{
final
CacheLIRS
<
K
,
V
>
cache
;
/**
* The number of (hot, cold, and non-resident) entries in the map.
*/
...
...
@@ -450,6 +448,8 @@ public class CacheLIRS<K, V> extends AbstractMap<K, V> {
*/
long
usedMemory
;
private
final
CacheLIRS
<
K
,
V
>
cache
;
/**
* How many other item are to be moved to the top of the stack before
* the current item is moved.
...
...
@@ -507,6 +507,7 @@ public class CacheLIRS<K, V> extends AbstractMap<K, V> {
/**
* Create a new cache.
*
* @param cache the cache
* @param maxMemory the maximum memory to use
* @param averageMemory the average memory usage of an object
* @param stackMoveDistance the number of other entries to be moved to
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论