Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
7c88c764
提交
7c88c764
authored
2月 09, 2008
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
7d819e9c
显示空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
141 行增加
和
112 行删除
+141
-112
SysProperties.java
h2/src/main/org/h2/constant/SysProperties.java
+3
-2
Database.java
h2/src/main/org/h2/engine/Database.java
+0
-1
LogFile.java
h2/src/main/org/h2/log/LogFile.java
+14
-5
PgServerThread.java
h2/src/main/org/h2/server/pg/PgServerThread.java
+3
-0
DiskFile.java
h2/src/main/org/h2/store/DiskFile.java
+35
-18
Storage.java
h2/src/main/org/h2/store/Storage.java
+2
-2
DelayedFileDeleter.java
h2/src/main/org/h2/util/DelayedFileDeleter.java
+3
-4
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+10
-18
TestBase.java
h2/src/test/org/h2/test/TestBase.java
+0
-4
TestIndex.java
h2/src/test/org/h2/test/db/TestIndex.java
+33
-43
TestLob.java
h2/src/test/org/h2/test/db/TestLob.java
+3
-4
TestLogFile.java
h2/src/test/org/h2/test/db/TestLogFile.java
+16
-9
TestReadOnly.java
h2/src/test/org/h2/test/db/TestReadOnly.java
+18
-0
TestRecovery.java
h2/src/test/org/h2/test/unit/TestRecovery.java
+1
-2
没有找到文件。
h2/src/main/org/h2/constant/SysProperties.java
浏览文件 @
7c88c764
...
...
@@ -396,7 +396,8 @@ private int test;
*/
public
static
int
getLogFileDeleteDelay
()
{
int
test
;
return
getIntSetting
(
H2_LOG_DELETE_DELAY
,
0
);
// return getIntSetting(H2_LOG_DELETE_DELAY, 2000);
// return getIntSetting(H2_LOG_DELETE_DELAY, 0);
return
getIntSetting
(
H2_LOG_DELETE_DELAY
,
100
);
// return getIntSetting(H2_LOG_DELETE_DELAY, Integer.MAX_VALUE);
}
}
h2/src/main/org/h2/engine/Database.java
浏览文件 @
7c88c764
...
...
@@ -474,7 +474,6 @@ public class Database implements DataHandler {
roles
.
put
(
Constants
.
PUBLIC_ROLE_NAME
,
publicRole
);
systemUser
.
setAdmin
(
true
);
systemSession
=
new
Session
(
this
,
systemUser
,
++
nextSessionId
);
// TODO storage: antivir scans .script files, maybe other scanners scan .db files?
ObjectArray
cols
=
new
ObjectArray
();
Column
columnId
=
new
Column
(
"ID"
,
Value
.
INT
);
columnId
.
setNullable
(
false
);
...
...
h2/src/main/org/h2/log/LogFile.java
浏览文件 @
7c88c764
...
...
@@ -192,6 +192,13 @@ public class LogFile {
return
s
;
}
/**
* Redo or undo one item in the log file.
*
* @param undo true if the operation should be undone
* @param readOnly if the file is read only
* @return true if there are potentially more operations
*/
private
boolean
redoOrUndo
(
boolean
undo
,
boolean
readOnly
)
throws
SQLException
{
int
pos
=
getBlock
();
DataPage
in
=
readPage
();
...
...
@@ -199,8 +206,7 @@ public class LogFile {
if
(
blocks
<
0
)
{
return
true
;
}
else
if
(
blocks
==
0
)
{
go
(
pos
);
file
.
setLength
((
long
)
pos
*
BLOCK_SIZE
);
truncate
(
pos
);
return
false
;
}
char
type
=
(
char
)
in
.
readByte
();
...
...
@@ -312,8 +318,6 @@ public class LogFile {
}
public
void
redoAllGoEnd
()
throws
SQLException
{
int
test
;
//System.out.println("redo log " + fileName);
boolean
readOnly
=
logSystem
.
getDatabase
().
getReadOnly
();
long
length
=
file
.
length
();
if
(
length
<=
FileStore
.
HEADER_LENGTH
)
{
...
...
@@ -335,7 +339,7 @@ int test;
database
.
setProgress
(
DatabaseEventListener
.
STATE_RECOVER
,
fileName
,
max
,
max
);
}
catch
(
SQLException
e
)
{
database
.
getTrace
(
Trace
.
LOG
).
debug
(
"Stop reading log file: "
+
e
.
getMessage
(),
e
);
// wrong checksum
is ok
(at the end of the log file)
// wrong checksum (at the end of the log file)
}
catch
(
OutOfMemoryError
e
)
{
// OutOfMemoryError means not enough memory is allocated to the VM.
// this is not necessarily at the end of the log file
...
...
@@ -475,6 +479,11 @@ int test;
file
.
write
(
buff
.
getBytes
(),
0
,
buff
.
length
());
}
void
truncate
(
int
pos
)
throws
SQLException
{
go
(
pos
);
file
.
setLength
((
long
)
pos
*
BLOCK_SIZE
);
}
private
DataPage
getHeader
()
{
DataPage
buff
=
rowBuff
;
buff
.
reset
();
...
...
h2/src/main/org/h2/server/pg/PgServerThread.java
浏览文件 @
7c88c764
...
...
@@ -9,6 +9,7 @@ import java.io.ByteArrayInputStream;
import
java.io.ByteArrayOutputStream
;
import
java.io.DataInputStream
;
import
java.io.DataOutputStream
;
import
java.io.EOFException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
...
...
@@ -76,6 +77,8 @@ public class PgServerThread implements Runnable {
process
();
out
.
flush
();
}
}
catch
(
EOFException
e
)
{
// more or less normal disconnect
}
catch
(
Exception
e
)
{
error
(
"process"
,
e
);
server
.
logError
(
e
);
...
...
h2/src/main/org/h2/store/DiskFile.java
浏览文件 @
7c88c764
...
...
@@ -213,10 +213,6 @@ public class DiskFile implements CacheWriter {
}
public
void
initFromSummary
(
byte
[]
summary
)
{
int
test
;
//System.out.println("init from summary: " + this);
synchronized
(
database
)
{
if
(
summary
==
null
||
summary
.
length
==
0
)
{
ObjectArray
list
=
database
.
getAllStorages
();
...
...
@@ -231,7 +227,7 @@ int test;
init
=
false
;
return
;
}
if
(
database
.
getRecovery
()
||
initAlreadyTried
)
{
if
(
database
.
getRecovery
()
||
(
initAlreadyTried
&&
(!
dataFile
||
!
SysProperties
.
CHECK
))
)
{
return
;
}
initAlreadyTried
=
true
;
...
...
@@ -248,11 +244,18 @@ int test;
stage
++;
for
(
int
i
=
0
,
x
=
0
;
i
<
b2
/
8
;
i
++)
{
int
mask
=
in
.
read
();
for
(
int
j
=
0
;
j
<
8
;
j
++)
{
if
(
init
)
{
for
(
int
j
=
0
;
j
<
8
;
j
++,
x
++)
{
if
(
used
.
get
(
x
)
!=
((
mask
&
(
1
<<
j
))
!=
0
))
{
throw
Message
.
getInternalError
(
"Redo failure, block: "
+
x
+
" expected in-use bit: "
+
used
.
get
(
x
));
}
}
}
else
{
for
(
int
j
=
0
;
j
<
8
;
j
++,
x
++)
{
if
((
mask
&
(
1
<<
j
))
!=
0
)
{
used
.
set
(
x
);
}
x
++;
}
}
}
stage
++;
...
...
@@ -260,6 +263,12 @@ int test;
ObjectArray
storages
=
new
ObjectArray
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
int
s
=
in
.
readInt
();
if
(
init
)
{
int
old
=
getPageOwner
(
i
);
if
(
old
!=
-
1
&&
old
!=
s
)
{
throw
Message
.
getInternalError
(
"Redo failure, expected page owner: "
+
old
+
" got: "
+
s
);
}
}
else
{
if
(
s
>=
0
)
{
Storage
storage
=
database
.
getStorage
(
s
,
this
);
while
(
storages
.
size
()
<=
s
)
{
...
...
@@ -270,6 +279,7 @@ int test;
}
setPageOwner
(
i
,
s
);
}
}
stage
++;
while
(
true
)
{
int
s
=
in
.
readInt
();
...
...
@@ -278,8 +288,15 @@ int test;
}
int
recordCount
=
in
.
readInt
();
Storage
storage
=
(
Storage
)
storages
.
get
(
s
);
if
(
init
)
{
int
current
=
storage
.
getRecordCount
();
if
(
current
!=
recordCount
)
{
throw
Message
.
getInternalError
(
"Redo failure, expected row count: "
+
current
+
" got: "
+
recordCount
);
}
}
else
{
storage
.
setRecordCount
(
recordCount
);
}
}
stage
++;
freeUnusedPages
();
init
=
true
;
...
...
@@ -565,7 +582,7 @@ int test;
if
((
i
%
BLOCKS_PER_PAGE
==
0
)
&&
(
pos
+
blockCount
>=
i
+
BLOCKS_PER_PAGE
))
{
// if this is the first page of a block and if the whole page is free
int
test
;
int
disabledCurrently
;
// setPageOwner(getPage(i), FREE_PAGE);
}
...
...
h2/src/main/org/h2/store/Storage.java
浏览文件 @
7c88c764
...
...
@@ -202,7 +202,7 @@ public class Storage {
public
void
delete
(
Session
session
)
throws
SQLException
{
truncate
(
session
);
int
test
;
int
disabledCurrently
;
// database.removeStorage(id, file);
}
...
...
@@ -269,7 +269,7 @@ public class Storage {
pageCheckIndex
=
(
pageCheckIndex
+
1
)
%
pages
.
size
();
int
page
=
pages
.
get
(
pageCheckIndex
);
if
(
file
.
isPageFree
(
page
)
&&
file
.
getPageOwner
(
page
)
==
id
)
{
int
testing
;
int
disabledCurrently
;
// file.setPageOwner(page, DiskFile.FREE_PAGE);
}
}
...
...
h2/src/main/org/h2/util/DelayedFileDeleter.java
浏览文件 @
7c88c764
...
...
@@ -35,6 +35,9 @@ public class DelayedFileDeleter extends Thread {
FileUtils
.
delete
(
fileName
);
return
;
}
if
(
deleteLater
.
containsKey
(
fileName
))
{
return
;
}
long
at
=
System
.
currentTimeMillis
()
+
delay
;
if
(
deleteNext
!=
0
&&
at
<=
deleteNext
)
{
// make sure files are deleted in the correct order
...
...
@@ -75,8 +78,6 @@ public class DelayedFileDeleter extends Thread {
public
static
synchronized
DelayedFileDeleter
getInstance
()
{
if
(
instance
==
null
)
{
int
test
;
//System.out.println("DelayerFileDeleter.getInstance()");
instance
=
new
DelayedFileDeleter
();
instance
.
setDaemon
(
true
);
instance
.
setPriority
(
Thread
.
MIN_PRIORITY
);
...
...
@@ -106,8 +107,6 @@ int test;
}
}
}
int
test
;
//System.out.println("DelayerFileDeleter.stop()");
}
/**
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
7c88c764
...
...
@@ -4,12 +4,9 @@
*/
package
org
.
h2
.
test
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.SQLException
;
import
java.util.Properties
;
import
org.h2.Driver
;
import
org.h2.server.TcpServer
;
import
org.h2.store.fs.FileSystemDisk
;
import
org.h2.test.db.TestAutoRecompile
;
...
...
@@ -28,7 +25,6 @@ import org.h2.test.db.TestIndex;
import
org.h2.test.db.TestLinkedTable
;
import
org.h2.test.db.TestListener
;
import
org.h2.test.db.TestLob
;
import
org.h2.test.db.TestLogFile
;
import
org.h2.test.db.TestMemoryUsage
;
import
org.h2.test.db.TestMultiConn
;
import
org.h2.test.db.TestMultiDimension
;
...
...
@@ -44,7 +40,6 @@ import org.h2.test.db.TestScript;
import
org.h2.test.db.TestScriptSimple
;
import
org.h2.test.db.TestSequence
;
import
org.h2.test.db.TestSessionsLocks
;
import
org.h2.test.db.TestSpaceReuse
;
import
org.h2.test.db.TestSpeed
;
import
org.h2.test.db.TestTempTables
;
import
org.h2.test.db.TestTransaction
;
...
...
@@ -73,11 +68,11 @@ import org.h2.test.server.TestNestedLoop;
import
org.h2.test.server.TestPgServer
;
import
org.h2.test.server.TestWeb
;
import
org.h2.test.synth.TestBtreeIndex
;
import
org.h2.test.synth.TestKillRestart
;
import
org.h2.test.synth.TestCrashAPI
;
import
org.h2.test.synth.TestHaltApp
;
import
org.h2.test.synth.TestJoin
;
import
org.h2.test.synth.TestKill
;
import
org.h2.test.synth.TestKillRestart
;
import
org.h2.test.synth.TestRandomSQL
;
import
org.h2.test.synth.TestTimer
;
import
org.h2.test.synth.sql.TestSynth
;
...
...
@@ -110,8 +105,6 @@ import org.h2.test.unit.TestValue;
import
org.h2.test.unit.TestValueHashMap
;
import
org.h2.test.unit.TestValueMemory
;
import
org.h2.tools.DeleteDbFiles
;
import
org.h2.tools.Recover
;
import
org.h2.tools.Restore
;
import
org.h2.tools.Server
;
import
org.h2.util.StringUtils
;
...
...
@@ -154,14 +147,6 @@ java org.h2.test.TestAll timer
long
time
=
System
.
currentTimeMillis
();
TestAll
test
=
new
TestAll
();
test
.
printSystem
();
// TestRecover.main(new String[0]);
//DeleteDbFiles.execute("/temp/db", null, true);
//Restore.execute("/temp/db/db.zip", "/temp/db", null, true);
//Recover.execute("/temp/db", null);
//Driver.load();
//Connection conn = DriverManager.getConnection("jdbc:h2:/temp/db/crashApi423910006", "sa", "");
//conn.close();
/*
out of memory tests
...
...
@@ -440,6 +425,7 @@ It was not possible to create a referential constraint to a table in a different
beforeTest
();
// db
new
TestScriptSimple
().
runTest
(
this
);
new
TestScript
().
runTest
(
this
);
new
TestAutoRecompile
().
runTest
(
this
);
...
...
@@ -458,7 +444,10 @@ It was not possible to create a referential constraint to a table in a different
new
TestLinkedTable
().
runTest
(
this
);
new
TestListener
().
runTest
(
this
);
new
TestLob
().
runTest
(
this
);
new
TestLogFile
().
runTest
(
this
);
// // size problem!
// new TestLogFile().runTest(this);
new
TestMemoryUsage
().
runTest
(
this
);
new
TestMultiConn
().
runTest
(
this
);
new
TestMultiDimension
().
runTest
(
this
);
...
...
@@ -472,7 +461,10 @@ It was not possible to create a referential constraint to a table in a different
new
TestSQLInjection
().
runTest
(
this
);
new
TestSessionsLocks
().
runTest
(
this
);
new
TestSequence
().
runTest
(
this
);
new
TestSpaceReuse
().
runTest
(
this
);
// should fail
// new TestSpaceReuse().runTest(this);
new
TestSpeed
().
runTest
(
this
);
new
TestTempTables
().
runTest
(
this
);
new
TestTransaction
().
runTest
(
this
);
...
...
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
7c88c764
...
...
@@ -146,10 +146,6 @@ public abstract class TestBase {
}
private
Connection
getConnectionInternal
(
String
url
,
String
user
,
String
password
)
throws
Exception
{
int
test
;
//System.out.println();
//System.out.println("connect to " + url);
Class
.
forName
(
"org.h2.Driver"
);
// url += ";DEFAULT_TABLE_TYPE=1";
// Class.forName("org.hsqldb.jdbcDriver");
...
...
h2/src/test/org/h2/test/db/TestIndex.java
浏览文件 @
7c88c764
...
...
@@ -10,7 +10,6 @@ import java.sql.ResultSet;
import
java.sql.Statement
;
import
java.util.Random
;
import
org.h2.constant.SysProperties
;
import
org.h2.result.SortOrder
;
import
org.h2.test.TestBase
;
...
...
@@ -33,58 +32,49 @@ public class TestIndex extends TestBase {
}
public
void
test
()
throws
Exception
{
int
teting
;
// testDescIndex();
//
testDescIndex
();
if
(
config
.
networked
&&
config
.
big
)
{
return
;
}
int
teting2
;
//
// random.setSeed(100);
//
// deleteDb("index");
// testWideIndex(147);
// testWideIndex(313);
// testWideIndex(979);
// testWideIndex(1200);
// testWideIndex(2400);
// if (config.big && config.logMode == 2) {
// for (int i = 0; i < 2000; i++) {
// if ((i % 100) == 0) {
// System.out.println("width: " + i);
// }
// testWideIndex(i);
// }
// }
//
// testLike();
// reconnect();
// testConstraint();
// testLargeIndex();
// testMultiColumnIndex();
// // long time;
// // time = System.currentTimeMillis();
// testHashIndex(true, false);
//System.setProperty(SysProperties.H2_LOG_DELETE_DELAY, "999999999");
int
testx
;
if
(
config
.
logMode
!=
2
)
{
return
;
}
random
.
setSeed
(
100
);
deleteDb
(
"index"
);
testWideIndex
(
147
);
testWideIndex
(
313
);
testWideIndex
(
979
);
testWideIndex
(
1200
);
testWideIndex
(
2400
);
if
(
config
.
big
&&
config
.
logMode
==
2
)
{
for
(
int
i
=
0
;
i
<
2000
;
i
++)
{
if
((
i
%
100
)
==
0
)
{
System
.
out
.
println
(
"width: "
+
i
);
}
testWideIndex
(
i
);
}
}
testLike
();
reconnect
();
testConstraint
();
testLargeIndex
();
testMultiColumnIndex
();
// long time;
// time = System.currentTimeMillis();
testHashIndex
(
true
,
false
);
testHashIndex
(
false
,
false
);
//
// System.out.println("btree="+(System.currentTimeMillis()-time));
//
// time = System.currentTimeMillis();
// System.out.println("btree="+(System.currentTimeMillis()-time));
// time = System.currentTimeMillis();
testHashIndex
(
true
,
true
);
testHashIndex
(
false
,
true
);
// System.out.println("hash="+(System.currentTimeMillis()-time));
int
te3
;
// testMultiColumnHashIndex();
//
// conn.close();
testMultiColumnHashIndex
();
conn
.
close
();
}
void
testDescIndex
()
throws
Exception
{
...
...
h2/src/test/org/h2/test/db/TestLob.java
浏览文件 @
7c88c764
...
...
@@ -34,10 +34,9 @@ public class TestLob extends TestBase {
if
(
config
.
memory
)
{
return
;
}
int
test
;
// testLobVariable();
// testLobDrop();
// testLobNoClose();
testLobVariable
();
testLobDrop
();
testLobNoClose
();
testLobTransactions
(
10
);
testLobTransactions
(
10000
);
testLobRollbackStop
();
...
...
h2/src/test/org/h2/test/db/TestLogFile.java
浏览文件 @
7c88c764
...
...
@@ -10,6 +10,7 @@ import java.sql.PreparedStatement;
import
java.sql.Statement
;
import
java.util.ArrayList
;
import
org.h2.constant.SysProperties
;
import
org.h2.store.FileLister
;
import
org.h2.test.TestBase
;
...
...
@@ -42,6 +43,9 @@ public class TestLogFile extends TestBase {
return
;
}
deleteDb
(
"logfile"
);
int
old
=
SysProperties
.
getLogFileDeleteDelay
();
System
.
setProperty
(
SysProperties
.
H2_LOG_DELETE_DELAY
,
"0"
);
try
{
reconnect
(
0
);
insert
();
int
maxFiles
=
3
;
// data, index, log
...
...
@@ -53,6 +57,9 @@ public class TestLogFile extends TestBase {
check
(
l2
<=
length
*
2
);
}
conn
.
close
();
}
finally
{
System
.
setProperty
(
SysProperties
.
H2_LOG_DELETE_DELAY
,
""
+
old
);
}
}
private
void
checkLogSize
()
throws
Exception
{
...
...
h2/src/test/org/h2/test/db/TestReadOnly.java
浏览文件 @
7c88c764
...
...
@@ -11,6 +11,7 @@ import java.sql.SQLException;
import
java.sql.Statement
;
import
java.util.ArrayList
;
import
org.h2.engine.Constants
;
import
org.h2.store.FileLister
;
import
org.h2.test.TestBase
;
...
...
@@ -70,15 +71,32 @@ public class TestReadOnly extends TestBase {
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
stat
.
execute
(
"SET DB_CLOSE_DELAY=0"
);
conn
.
close
();
}
private
void
setReadOnly
()
throws
SQLException
{
String
lastLogFile
=
null
;
ArrayList
list
=
FileLister
.
getDatabaseFiles
(
TestBase
.
baseDir
,
"readonly"
,
true
);
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
String
fileName
=
(
String
)
list
.
get
(
i
);
File
file
=
new
File
(
fileName
);
file
.
setReadOnly
();
if
(
fileName
.
endsWith
(
Constants
.
SUFFIX_LOG_FILE
))
{
if
(
lastLogFile
==
null
||
lastLogFile
.
compareTo
(
fileName
)
<
0
)
{
lastLogFile
=
fileName
;
}
}
}
// delete all log files except the last one
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
String
fileName
=
(
String
)
list
.
get
(
i
);
if
(
fileName
.
endsWith
(
Constants
.
SUFFIX_LOG_FILE
))
{
if
(!
lastLogFile
.
equals
(
fileName
))
{
File
file
=
new
File
(
fileName
);
file
.
delete
();
}
}
}
}
...
...
h2/src/test/org/h2/test/unit/TestRecovery.java
浏览文件 @
7c88c764
...
...
@@ -10,7 +10,6 @@ import java.sql.Statement;
import
org.h2.test.TestBase
;
import
org.h2.tools.DeleteDbFiles
;
import
org.h2.tools.Recover
;
/**
* Tests database recovery.
...
...
@@ -34,7 +33,7 @@ public class TestRecovery extends TestBase {
// overwrite the data of test
stat1
.
execute
(
"insert into abc select * from system_range(1, 100)"
);
stat1
.
execute
(
"shutdown immediately"
);
Recover
.
execute
(
"data"
,
null
);
//
Recover.execute("data", null);
Connection
conn
=
DriverManager
.
getConnection
(
url
,
"sa"
,
"sa"
);
conn
.
close
();
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论