Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
b6a3142e
提交
b6a3142e
authored
12月 15, 2006
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
550fd0a1
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
64 行增加
和
37 行删除
+64
-37
features.html
h2/src/docsrc/html/features.html
+3
-0
Database.java
h2/src/main/org/h2/engine/Database.java
+1
-1
DiskFile.java
h2/src/main/org/h2/store/DiskFile.java
+19
-4
Recover.java
h2/src/main/org/h2/tools/Recover.java
+16
-16
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+15
-10
TestCrashAPI.java
h2/src/test/org/h2/test/synth/TestCrashAPI.java
+10
-6
没有找到文件。
h2/src/docsrc/html/features.html
浏览文件 @
b6a3142e
...
@@ -268,6 +268,9 @@ Features
...
@@ -268,6 +268,9 @@ Features
</tr><tr>
</tr><tr>
<td><a
href=
"http://sql-workbench.net"
>
SQL Workbench/J
</a></td>
<td><a
href=
"http://sql-workbench.net"
>
SQL Workbench/J
</a></td>
<td>
Free DBMS-independent SQL Tool.
</td>
<td>
Free DBMS-independent SQL Tool.
</td>
</tr><tr>
<td><a
href=
"http://www.streamcruncher.com"
>
StreamCruncher
</a></td>
<td>
Event (Stream) Processing Kernel.
</td>
</tr>
</tr>
</table>
</table>
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
b6a3142e
...
@@ -596,7 +596,7 @@ public class Database implements DataHandler {
...
@@ -596,7 +596,7 @@ public class Database implements DataHandler {
if
(
storages
.
size
()
>
id
)
{
if
(
storages
.
size
()
>
id
)
{
storage
=
(
Storage
)
storages
.
get
(
id
);
storage
=
(
Storage
)
storages
.
get
(
id
);
if
(
storage
!=
null
)
{
if
(
storage
!=
null
)
{
if
(
Constants
.
CHECK
&&
storage
!=
null
&&
storage
.
getDiskFile
()
!=
file
)
{
if
(
Constants
.
CHECK
&&
storage
.
getDiskFile
()
!=
file
)
{
throw
Message
.
getInternalError
();
throw
Message
.
getInternalError
();
}
}
}
}
...
...
h2/src/main/org/h2/store/DiskFile.java
浏览文件 @
b6a3142e
...
@@ -43,10 +43,10 @@ public class DiskFile implements CacheWriter {
...
@@ -43,10 +43,10 @@ public class DiskFile implements CacheWriter {
private
Database
database
;
private
Database
database
;
private
String
fileName
;
private
String
fileName
;
private
FileStore
file
;
private
FileStore
file
;
private
BitField
used
=
new
BitField
()
;
private
BitField
used
;
private
BitField
deleted
=
new
BitField
()
;
private
BitField
deleted
;
private
int
fileBlockCount
;
private
int
fileBlockCount
;
private
IntArray
pageOwners
=
new
IntArray
()
;
private
IntArray
pageOwners
;
private
Cache
cache
;
private
Cache
cache
;
private
LogSystem
log
;
private
LogSystem
log
;
private
DataPage
rowBuff
;
private
DataPage
rowBuff
;
...
@@ -55,11 +55,12 @@ public class DiskFile implements CacheWriter {
...
@@ -55,11 +55,12 @@ public class DiskFile implements CacheWriter {
private
boolean
logChanges
;
private
boolean
logChanges
;
private
int
recordOverhead
;
private
int
recordOverhead
;
private
boolean
init
,
initAlreadyTried
;
private
boolean
init
,
initAlreadyTried
;
private
ObjectArray
redoBuffer
=
new
ObjectArray
()
;
private
ObjectArray
redoBuffer
;
private
int
redoBufferSize
;
private
int
redoBufferSize
;
private
int
readCount
,
writeCount
;
private
int
readCount
,
writeCount
;
public
DiskFile
(
Database
database
,
String
fileName
,
boolean
dataFile
,
boolean
logChanges
,
int
cacheSize
)
throws
SQLException
{
public
DiskFile
(
Database
database
,
String
fileName
,
boolean
dataFile
,
boolean
logChanges
,
int
cacheSize
)
throws
SQLException
{
reset
();
this
.
database
=
database
;
this
.
database
=
database
;
this
.
log
=
database
.
getLog
();
this
.
log
=
database
.
getLog
();
this
.
fileName
=
fileName
;
this
.
fileName
=
fileName
;
...
@@ -92,6 +93,13 @@ public class DiskFile implements CacheWriter {
...
@@ -92,6 +93,13 @@ public class DiskFile implements CacheWriter {
throw
e
;
throw
e
;
}
}
}
}
private
void
reset
()
{
used
=
new
BitField
();
deleted
=
new
BitField
();
pageOwners
=
new
IntArray
();
redoBuffer
=
new
ObjectArray
();
}
private
void
setBlockCount
(
int
count
)
{
private
void
setBlockCount
(
int
count
)
{
fileBlockCount
=
count
;
fileBlockCount
=
count
;
...
@@ -183,6 +191,13 @@ public class DiskFile implements CacheWriter {
...
@@ -183,6 +191,13 @@ public class DiskFile implements CacheWriter {
public
synchronized
void
initFromSummary
(
byte
[]
summary
)
{
public
synchronized
void
initFromSummary
(
byte
[]
summary
)
{
if
(
summary
==
null
||
summary
.
length
==
0
)
{
if
(
summary
==
null
||
summary
.
length
==
0
)
{
ObjectArray
list
=
database
.
getAllStorages
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
Storage
s
=
(
Storage
)
list
.
get
(
i
);
database
.
removeStorage
(
s
.
getId
(),
this
);
}
reset
();
initAlreadyTried
=
false
;
init
=
false
;
init
=
false
;
return
;
return
;
}
}
...
...
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
b6a3142e
...
@@ -375,20 +375,17 @@ public class Recover implements DataHandler {
...
@@ -375,20 +375,17 @@ public class Recover implements DataHandler {
s
.
reset
();
s
.
reset
();
}
}
blocks
=
s
.
readInt
();
blocks
=
s
.
readInt
();
if
(
blocks
<
0
)
{
if
(
blocks
<=
0
)
{
writer
.
println
(
"// ["
+
pos
+
"] blocks: "
+
blocks
);
writer
.
println
(
"// ["
+
pos
+
"] blocks: "
+
blocks
+
" (end)"
);
}
else
if
(
blocks
==
0
)
{
break
;
writer
.
println
(
"// ["
+
pos
+
"] blocks: 0 (end)"
);
}
else
{
}
else
{
char
type
=
(
char
)
s
.
readByte
();
char
type
=
(
char
)
s
.
readByte
();
int
sessionId
=
s
.
readInt
();
int
sessionId
=
s
.
readInt
();
writer
.
println
(
"// type: "
+
type
+
" session: "
+
sessionId
);
if
(
type
==
'P'
)
{
if
(
type
==
'P'
)
{
String
transaction
=
s
.
readString
();
String
transaction
=
s
.
readString
();
writer
.
println
(
"//
transaction
: "
+
transaction
);
writer
.
println
(
"//
prepared session:"
+
sessionId
+
" tx
: "
+
transaction
);
}
else
if
(
type
==
'C'
)
{
}
else
if
(
type
==
'C'
)
{
writer
.
println
(
"// commit"
);
writer
.
println
(
"// commit session:"
+
sessionId
);
break
;
}
else
{
}
else
{
int
storageId
=
s
.
readInt
();
int
storageId
=
s
.
readInt
();
int
recordId
=
s
.
readInt
();
int
recordId
=
s
.
readInt
();
...
@@ -404,21 +401,21 @@ public class Recover implements DataHandler {
...
@@ -404,21 +401,21 @@ public class Recover implements DataHandler {
if
(
sumLength
>
0
)
{
if
(
sumLength
>
0
)
{
s
.
read
(
summary
,
0
,
sumLength
);
s
.
read
(
summary
,
0
,
sumLength
);
}
}
writer
.
println
(
"// fileType: "
+
fileType
+
" sumLength: "
+
sumLength
);
writer
.
println
(
"//
summary session:"
+
sessionId
+
"
fileType: "
+
fileType
+
" sumLength: "
+
sumLength
);
dumpSummary
(
writer
,
summary
);
dumpSummary
(
writer
,
summary
);
break
;
break
;
}
}
case
'T'
:
case
'T'
:
writer
.
println
(
"// storage: "
+
storageId
+
" recordId: "
+
recordId
+
" blockCount: "
+
blockCount
);
writer
.
println
(
"//
truncate session:"
+
sessionId
+
"
storage: "
+
storageId
+
" recordId: "
+
recordId
+
" blockCount: "
+
blockCount
);
break
;
break
;
case
'I'
:
case
'I'
:
writer
.
println
(
"// storage: "
+
storageId
+
" recordId: "
+
recordId
+
" blockCount: "
+
blockCount
);
writer
.
println
(
"//
insert session:"
+
sessionId
+
"
storage: "
+
storageId
+
" recordId: "
+
recordId
+
" blockCount: "
+
blockCount
);
break
;
break
;
case
'D'
:
case
'D'
:
writer
.
println
(
"// storage: "
+
storageId
+
" recordId: "
+
recordId
+
" blockCount: "
+
blockCount
);
writer
.
println
(
"//
delete session:"
+
sessionId
+
"
storage: "
+
storageId
+
" recordId: "
+
recordId
+
" blockCount: "
+
blockCount
);
break
;
break
;
default
:
default
:
writer
.
println
(
"// storage: "
+
storageId
+
" recordId: "
+
recordId
+
" blockCount: "
+
blockCount
);
writer
.
println
(
"//
type?:"
+
type
+
" session:"
+
sessionId
+
"
storage: "
+
storageId
+
" recordId: "
+
recordId
+
" blockCount: "
+
blockCount
);
break
;
break
;
}
}
}
}
...
@@ -434,7 +431,7 @@ public class Recover implements DataHandler {
...
@@ -434,7 +431,7 @@ public class Recover implements DataHandler {
private
void
dumpSummary
(
PrintWriter
writer
,
byte
[]
summary
)
throws
SQLException
{
private
void
dumpSummary
(
PrintWriter
writer
,
byte
[]
summary
)
throws
SQLException
{
if
(
summary
==
null
||
summary
.
length
==
0
)
{
if
(
summary
==
null
||
summary
.
length
==
0
)
{
writer
.
println
(
"// summary is empty"
);
writer
.
println
(
"//
summary is empty"
);
return
;
return
;
}
}
try
{
try
{
...
@@ -445,7 +442,10 @@ public class Recover implements DataHandler {
...
@@ -445,7 +442,10 @@ public class Recover implements DataHandler {
}
}
int
len
=
in
.
readInt
();
int
len
=
in
.
readInt
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
in
.
readInt
();
int
storageId
=
in
.
readInt
();
if
(
storageId
!=
-
1
)
{
writer
.
println
(
"// pos:"
+(
i
*
DiskFile
.
BLOCKS_PER_PAGE
)+
" storage:"
+
storageId
);
}
}
}
while
(
true
)
{
while
(
true
)
{
int
s
=
in
.
readInt
();
int
s
=
in
.
readInt
();
...
@@ -525,7 +525,7 @@ public class Recover implements DataHandler {
...
@@ -525,7 +525,7 @@ public class Recover implements DataHandler {
}
else
{
}
else
{
pageOwners
[
page
]
=
storageId
;
pageOwners
[
page
]
=
storageId
;
}
}
writer
.
println
(
"// ["
+
block
+
"] p
:"
+
page
+
" c:"
+
blockCount
+
" s
:"
+
storageId
);
writer
.
println
(
"// ["
+
block
+
"] p
age:"
+
page
+
" blocks:"
+
blockCount
+
" storage
:"
+
storageId
);
}
}
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
writeError
(
writer
,
e
);
writeError
(
writer
,
e
);
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
b6a3142e
...
@@ -90,19 +90,26 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2
...
@@ -90,19 +90,26 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2
TestAll
test
=
new
TestAll
();
TestAll
test
=
new
TestAll
();
test
.
printSystem
();
test
.
printSystem
();
// code coverage
// java.lang.Error: query was too quick; result: 0
// at org.h2.test.db.TestCases$1.run(TestCases.java:156)
//max / hibernate
// at java.lang.Thread.run(Thread.java:595)
// Sorry, a typo by me. I don't specify any database name and then when
//java.lang.Error: query was too quick; result: 0
// I call getTables I get a catalog name that I pass on to getColumns and
// at org.h2.test.db.TestCases$1.run(TestCases.java:156)
// here getColumns does not return anything unless I null out the return
// at java.lang.Thread.run(Thread.java:595)
// catalog name.
//java.lang.Exception: closing took 1266
// at org.h2.test.TestBase.error(TestBase.java:206)
// at org.h2.test.db.TestCases.testDisconnect(TestCases.java:173)
// at org.h2.test.db.TestCases.test(TestCases.java:25)
// at org.h2.test.TestBase.runTest(TestBase.java:55)
// at org.h2.test.TestAll.testDatabase(TestAll.java:414)
// at org.h2.test.TestAll.testAll(TestAll.java:377)
// at org.h2.test.TestAll.testEverything(TestAll.java:273)
// at org.h2.test.TestAll.main(TestAll.java:196)
// Check if new Hibernate dialect for H2 is ok
// Check if new Hibernate dialect for H2 is ok
// http://opensource.atlassian.com/projects/hibernate/browse/HHH-2300
// http://opensource.atlassian.com/projects/hibernate/browse/HHH-2300
// open JPA test - submit patch
// open JPA test - submit patch
// ant mavenUploadLocal
// d:\data\h2test\openjpa\openjpa-persistence-jdbc\src\test\resources\META-INF\persistence.xml
// d:\data\h2test\openjpa\openjpa-persistence-jdbc\src\test\resources\META-INF\persistence.xml
// <!-- <property name="openjpa.ConnectionProperties"
// <!-- <property name="openjpa.ConnectionProperties"
// value="DriverClassName=org.apache.derby.jdbc.EmbeddedDriver,Url=jdbc:derby:target/database/openjpa-test-database;create=true,MaxActive=100,MaxWait=10000,TestOnBorrow=true"/>
// value="DriverClassName=org.apache.derby.jdbc.EmbeddedDriver,Url=jdbc:derby:target/database/openjpa-test-database;create=true,MaxActive=100,MaxWait=10000,TestOnBorrow=true"/>
...
@@ -117,11 +124,9 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2
...
@@ -117,11 +124,9 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2
// Test and document JDK 1.6 QueryObjectFactory
// Test and document JDK 1.6 QueryObjectFactory
// submit hibernate dialect
// clean build path (remove hibernate librarires)
// clean build path (remove hibernate librarires)
// test with PostgreSQL Version 8.2
// test with PostgreSQL Version 8.2
// create table testoe(id int primary key, name varchar(255))
// create table testoe(id int primary key, name varchar(255))
// create user oe identified by merlin
// create user oe identified by merlin
...
...
h2/src/test/org/h2/test/synth/TestCrashAPI.java
浏览文件 @
b6a3142e
...
@@ -48,7 +48,7 @@ public class TestCrashAPI extends TestBase {
...
@@ -48,7 +48,7 @@ public class TestCrashAPI extends TestBase {
private
long
callCount
;
private
long
callCount
;
private
String
DIR
=
"synth"
;
private
String
DIR
=
"synth"
;
private
void
deleteDb
(
int
seed
)
{
private
void
deleteDb
()
{
try
{
try
{
deleteDb
(
BASE_DIR
+
"/"
+
DIR
,
null
);
deleteDb
(
BASE_DIR
+
"/"
+
DIR
,
null
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -59,13 +59,16 @@ public class TestCrashAPI extends TestBase {
...
@@ -59,13 +59,16 @@ public class TestCrashAPI extends TestBase {
private
Connection
getConnection
(
int
seed
,
boolean
delete
)
throws
Exception
{
private
Connection
getConnection
(
int
seed
,
boolean
delete
)
throws
Exception
{
openCount
++;
openCount
++;
if
(
delete
)
{
if
(
delete
)
{
deleteDb
(
seed
);
deleteDb
();
}
}
// can not use FILE_LOCK=NO, otherwise something could be written into the database in the finalizer
// can not use FILE_LOCK=NO, otherwise something could be written into the database in the finalizer
String
add
=
""
;
// ";STORAGE=TEXT";
String
add
=
""
;
// ";STORAGE=TEXT";
// int testing;
// int testing;
// if(openCount>=10) {
// add = ";STORAGE=TEXT";
// if(openCount>=24) {
// System.exit(1);
// }
// add = ";LOG=2";
// add = ";LOG=2";
// System.out.println("now open " + openCount);
// System.out.println("now open " + openCount);
// add += ";TRACE_LEVEL_FILE=3";
// add += ";TRACE_LEVEL_FILE=3";
...
@@ -73,6 +76,7 @@ public class TestCrashAPI extends TestBase {
...
@@ -73,6 +76,7 @@ public class TestCrashAPI extends TestBase {
// }
// }
String
url
=
getURL
(
DIR
+
"/crashapi"
+
seed
,
true
)
+
add
;
String
url
=
getURL
(
DIR
+
"/crashapi"
+
seed
,
true
)
+
add
;
Connection
conn
=
null
;
Connection
conn
=
null
;
// System.gc();
// System.gc();
conn
=
DriverManager
.
getConnection
(
url
,
"sa"
,
""
);
conn
=
DriverManager
.
getConnection
(
url
,
"sa"
,
""
);
...
@@ -114,7 +118,7 @@ public class TestCrashAPI extends TestBase {
...
@@ -114,7 +118,7 @@ public class TestCrashAPI extends TestBase {
private
void
testOne
(
int
seed
)
throws
Exception
{
private
void
testOne
(
int
seed
)
throws
Exception
{
printTime
(
"TestCrashAPI "
+
seed
);
printTime
(
"TestCrashAPI "
+
seed
);
callCount
=
0
;
openCount
=
0
;
openCount
=
0
;
random
=
new
RandomGen
(
null
);
random
=
new
RandomGen
(
null
);
random
.
setSeed
(
seed
);
random
.
setSeed
(
seed
);
...
@@ -371,10 +375,10 @@ public class TestCrashAPI extends TestBase {
...
@@ -371,10 +375,10 @@ public class TestCrashAPI extends TestBase {
}
}
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
for
(
int
i
=
0
;
i
<
Integer
.
MAX_VALUE
;
i
++
)
{
while
(
true
)
{
int
seed
=
RandomUtils
.
nextInt
(
Integer
.
MAX_VALUE
);
int
seed
=
RandomUtils
.
nextInt
(
Integer
.
MAX_VALUE
);
testCase
(
seed
);
testCase
(
seed
);
deleteDb
(
seed
);
deleteDb
();
}
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论