Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
320543a6
提交
320543a6
authored
1月 08, 2014
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Don't create a *.h2.db file when using the MVStore
上级
6e74c6eb
隐藏空白字符变更
内嵌
并排
正在显示
24 个修改的文件
包含
247 行增加
和
64 行删除
+247
-64
mvstore.html
h2/src/docsrc/html/mvstore.html
+2
-3
BackupCommand.java
h2/src/main/org/h2/command/dml/BackupCommand.java
+4
-1
Explain.java
h2/src/main/org/h2/command/dml/Explain.java
+2
-0
Database.java
h2/src/main/org/h2/engine/Database.java
+25
-6
DatabaseInfo.java
h2/src/main/org/h2/jmx/DatabaseInfo.java
+52
-8
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+38
-3
Page.java
h2/src/main/org/h2/mvstore/Page.java
+3
-1
MVTable.java
h2/src/main/org/h2/mvstore/db/MVTable.java
+1
-1
Schema.java
h2/src/main/org/h2/schema/Schema.java
+1
-1
TcpServerThread.java
h2/src/main/org/h2/server/TcpServerThread.java
+2
-2
RecoverTester.java
h2/src/main/org/h2/store/RecoverTester.java
+2
-1
MetaTable.java
h2/src/main/org/h2/table/MetaTable.java
+19
-7
Backup.java
h2/src/main/org/h2/tools/Backup.java
+3
-1
Recover.java
h2/src/main/org/h2/tools/Recover.java
+11
-10
Restore.java
h2/src/main/org/h2/tools/Restore.java
+3
-0
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+0
-1
TestOpenClose.java
h2/src/test/org/h2/test/db/TestOpenClose.java
+18
-5
TestTempTables.java
h2/src/test/org/h2/test/db/TestTempTables.java
+3
-0
TestWeb.java
h2/src/test/org/h2/test/server/TestWeb.java
+10
-3
TestMVStore.java
h2/src/test/org/h2/test/store/TestMVStore.java
+27
-1
TestMVTableEngine.java
h2/src/test/org/h2/test/store/TestMVTableEngine.java
+1
-1
TestClearReferences.java
h2/src/test/org/h2/test/unit/TestClearReferences.java
+3
-0
TestJmx.java
h2/src/test/org/h2/test/unit/TestJmx.java
+16
-6
H2Database.java
h2/src/tools/org/h2/android/H2Database.java
+1
-2
没有找到文件。
h2/src/docsrc/html/mvstore.html
浏览文件 @
320543a6
...
@@ -469,9 +469,8 @@ This is work in progress. To try it out, append
...
@@ -469,9 +469,8 @@ This is work in progress. To try it out, append
to the database URL. In general, functionality and performance should be
to the database URL. In general, functionality and performance should be
similar than the current default storage engine (the page store).
similar than the current default storage engine (the page store).
There are a few features that have not been implemented yet or are not complete,
There are a few features that have not been implemented yet or are not complete,
for example there is still a file named
<code>
.h2.db
</code>
,
for example the
<code>
.lock.db
</code>
file is still used to lock a database
and the
<code>
.lock.db
</code>
file is still used to lock a database
(the plan is to no longer use this file by default).
(long term, the plan is to no longer use those files).
</p>
</p>
<h2
id=
"differences"
>
Similar Projects and Differences to Other Storage Engines
</h2>
<h2
id=
"differences"
>
Similar Projects and Differences to Other Storage Engines
</h2>
...
...
h2/src/main/org/h2/command/dml/BackupCommand.java
浏览文件 @
320543a6
...
@@ -72,7 +72,7 @@ public class BackupCommand extends Prepared {
...
@@ -72,7 +72,7 @@ public class BackupCommand extends Prepared {
backupPageStore
(
out
,
fn
,
db
.
getPageStore
());
backupPageStore
(
out
,
fn
,
db
.
getPageStore
());
// synchronize on the database, to avoid concurrent temp file
// synchronize on the database, to avoid concurrent temp file
// creation / deletion / backup
// creation / deletion / backup
String
base
=
FileUtils
.
getParent
(
fn
);
String
base
=
FileUtils
.
getParent
(
db
.
getName
()
);
synchronized
(
db
.
getLobSyncObject
())
{
synchronized
(
db
.
getLobSyncObject
())
{
String
prefix
=
db
.
getDatabasePath
();
String
prefix
=
db
.
getDatabasePath
();
String
dir
=
FileUtils
.
getParent
(
prefix
);
String
dir
=
FileUtils
.
getParent
(
prefix
);
...
@@ -103,6 +103,9 @@ public class BackupCommand extends Prepared {
...
@@ -103,6 +103,9 @@ public class BackupCommand extends Prepared {
}
}
private
void
backupPageStore
(
ZipOutputStream
out
,
String
fileName
,
PageStore
store
)
throws
IOException
{
private
void
backupPageStore
(
ZipOutputStream
out
,
String
fileName
,
PageStore
store
)
throws
IOException
{
if
(
store
==
null
)
{
return
;
}
Database
db
=
session
.
getDatabase
();
Database
db
=
session
.
getDatabase
();
fileName
=
FileUtils
.
getName
(
fileName
);
fileName
=
FileUtils
.
getName
(
fileName
);
out
.
putNextEntry
(
new
ZipEntry
(
fileName
));
out
.
putNextEntry
(
new
ZipEntry
(
fileName
));
...
...
h2/src/main/org/h2/command/dml/Explain.java
浏览文件 @
320543a6
...
@@ -64,6 +64,8 @@ public class Explain extends Prepared {
...
@@ -64,6 +64,8 @@ public class Explain extends Prepared {
if
(
maxrows
>=
0
)
{
if
(
maxrows
>=
0
)
{
String
plan
;
String
plan
;
if
(
executeCommand
)
{
if
(
executeCommand
)
{
;
// TODO to the same for the MVStore
PageStore
store
=
db
.
isPersistent
()
?
db
.
getPageStore
()
:
null
;
PageStore
store
=
db
.
isPersistent
()
?
db
.
getPageStore
()
:
null
;
if
(
store
!=
null
)
{
if
(
store
!=
null
)
{
store
.
statisticsStart
();
store
.
statisticsStart
();
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
320543a6
...
@@ -467,7 +467,10 @@ public class Database implements DataHandler {
...
@@ -467,7 +467,10 @@ public class Database implements DataHandler {
* @return true if one exists
* @return true if one exists
*/
*/
static
boolean
exists
(
String
name
)
{
static
boolean
exists
(
String
name
)
{
return
FileUtils
.
exists
(
name
+
Constants
.
SUFFIX_PAGE_FILE
);
if
(
FileUtils
.
exists
(
name
+
Constants
.
SUFFIX_PAGE_FILE
))
{
return
true
;
}
return
FileUtils
.
exists
(
name
+
Constants
.
SUFFIX_MV_FILE
);
}
}
/**
/**
...
@@ -531,14 +534,19 @@ public class Database implements DataHandler {
...
@@ -531,14 +534,19 @@ public class Database implements DataHandler {
String
dataFileName
=
databaseName
+
".data.db"
;
String
dataFileName
=
databaseName
+
".data.db"
;
boolean
existsData
=
FileUtils
.
exists
(
dataFileName
);
boolean
existsData
=
FileUtils
.
exists
(
dataFileName
);
String
pageFileName
=
databaseName
+
Constants
.
SUFFIX_PAGE_FILE
;
String
pageFileName
=
databaseName
+
Constants
.
SUFFIX_PAGE_FILE
;
String
mvFileName
=
databaseName
+
Constants
.
SUFFIX_MV_FILE
;
boolean
existsPage
=
FileUtils
.
exists
(
pageFileName
);
boolean
existsPage
=
FileUtils
.
exists
(
pageFileName
);
if
(
existsData
&&
!
existsPage
)
{
boolean
existsMv
=
FileUtils
.
exists
(
mvFileName
);
if
(
existsData
&&
(!
existsPage
&&
!
existsMv
))
{
throw
DbException
.
get
(
ErrorCode
.
FILE_VERSION_ERROR_1
,
throw
DbException
.
get
(
ErrorCode
.
FILE_VERSION_ERROR_1
,
"Old database: "
+
dataFileName
+
" - please convert the database to a SQL script and re-create it."
);
"Old database: "
+
dataFileName
+
" - please convert the database to a SQL script and re-create it."
);
}
}
if
(
existsPage
&&
!
FileUtils
.
canWrite
(
pageFileName
))
{
if
(
existsPage
&&
!
FileUtils
.
canWrite
(
pageFileName
))
{
readOnly
=
true
;
readOnly
=
true
;
}
}
if
(
existsMv
&&
!
FileUtils
.
canWrite
(
mvFileName
))
{
readOnly
=
true
;
}
if
(
readOnly
)
{
if
(
readOnly
)
{
if
(
traceLevelFile
>=
TraceSystem
.
DEBUG
)
{
if
(
traceLevelFile
>=
TraceSystem
.
DEBUG
)
{
String
traceFile
=
Utils
.
getProperty
(
"java.io.tmpdir"
,
"."
)
+
"/"
+
"h2_"
+
System
.
currentTimeMillis
();
String
traceFile
=
Utils
.
getProperty
(
"java.io.tmpdir"
,
"."
)
+
"/"
+
"h2_"
+
System
.
currentTimeMillis
();
...
@@ -1837,8 +1845,10 @@ public class Database implements DataHandler {
...
@@ -1837,8 +1845,10 @@ public class Database implements DataHandler {
mvStore
.
prepareCommit
(
session
,
transaction
);
mvStore
.
prepareCommit
(
session
,
transaction
);
return
;
return
;
}
}
pageStore
.
flushLog
();
if
(
pageStore
!=
null
)
{
pageStore
.
prepareCommit
(
session
,
transaction
);
pageStore
.
flushLog
();
pageStore
.
prepareCommit
(
session
,
transaction
);
}
}
}
/**
/**
...
@@ -2262,8 +2272,11 @@ public class Database implements DataHandler {
...
@@ -2262,8 +2272,11 @@ public class Database implements DataHandler {
}
}
public
PageStore
getPageStore
()
{
public
PageStore
getPageStore
()
{
if
(
dbSettings
.
mvStore
&&
mvStore
==
null
)
{
if
(
dbSettings
.
mvStore
)
{
mvStore
=
MVTableEngine
.
init
(
this
);
if
(
mvStore
==
null
)
{
mvStore
=
MVTableEngine
.
init
(
this
);
}
return
null
;
}
}
if
(
pageStore
==
null
)
{
if
(
pageStore
==
null
)
{
pageStore
=
new
PageStore
(
this
,
databaseName
+
Constants
.
SUFFIX_PAGE_FILE
,
accessModeData
,
cacheSize
);
pageStore
=
new
PageStore
(
this
,
databaseName
+
Constants
.
SUFFIX_PAGE_FILE
,
accessModeData
,
cacheSize
);
...
@@ -2520,12 +2533,18 @@ public class Database implements DataHandler {
...
@@ -2520,12 +2533,18 @@ public class Database implements DataHandler {
this
.
logMode
=
log
;
this
.
logMode
=
log
;
pageStore
.
setLogMode
(
log
);
pageStore
.
setLogMode
(
log
);
}
}
if
(
mvStore
!=
null
)
{
this
.
logMode
=
log
;
}
}
}
public
int
getLogMode
()
{
public
int
getLogMode
()
{
if
(
pageStore
!=
null
)
{
if
(
pageStore
!=
null
)
{
return
pageStore
.
getLogMode
();
return
pageStore
.
getLogMode
();
}
}
if
(
mvStore
!=
null
)
{
return
logMode
;
}
return
PageStore
.
LOG_MODE_OFF
;
return
PageStore
.
LOG_MODE_OFF
;
}
}
...
...
h2/src/main/org/h2/jmx/DatabaseInfo.java
浏览文件 @
320543a6
...
@@ -20,6 +20,7 @@ import org.h2.engine.ConnectionInfo;
...
@@ -20,6 +20,7 @@ import org.h2.engine.ConnectionInfo;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Database
;
import
org.h2.engine.Database
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.store.PageStore
;
import
org.h2.table.Table
;
import
org.h2.table.Table
;
import
org.h2.util.New
;
import
org.h2.util.New
;
...
@@ -139,40 +140,83 @@ public class DatabaseInfo implements DatabaseInfoMBean {
...
@@ -139,40 +140,83 @@ public class DatabaseInfo implements DatabaseInfoMBean {
@Override
@Override
public
long
getFileWriteCountTotal
()
{
public
long
getFileWriteCountTotal
()
{
return
database
.
isPersistent
()
?
database
.
getPageStore
().
getWriteCountTotal
()
:
0L
;
if
(!
database
.
isPersistent
())
{
return
0
;
}
PageStore
p
=
database
.
getPageStore
();
if
(
p
!=
null
)
{
return
p
.
getWriteCountTotal
();
}
// TODO remove this method when removing the page store
// (the MVStore doesn't support it)
return
0
;
}
}
@Override
@Override
public
long
getFileWriteCount
()
{
public
long
getFileWriteCount
()
{
return
database
.
isPersistent
()
?
database
.
getPageStore
().
getWriteCount
()
:
0L
;
if
(!
database
.
isPersistent
())
{
return
0
;
}
PageStore
p
=
database
.
getPageStore
();
if
(
p
!=
null
)
{
return
p
.
getWriteCount
();
}
return
database
.
getMvStore
().
getStore
().
getFileStore
().
getReadCount
();
}
}
@Override
@Override
public
long
getFileReadCount
()
{
public
long
getFileReadCount
()
{
return
database
.
isPersistent
()
?
database
.
getPageStore
().
getReadCount
()
:
0L
;
if
(!
database
.
isPersistent
())
{
return
0
;
}
PageStore
p
=
database
.
getPageStore
();
if
(
p
!=
null
)
{
return
p
.
getReadCount
();
}
return
database
.
getMvStore
().
getStore
().
getFileStore
().
getReadCount
();
}
}
@Override
@Override
public
long
getFileSize
()
{
public
long
getFileSize
()
{
return
database
.
isPersistent
()
?
if
(!
database
.
isPersistent
())
{
(
database
.
getPageStore
().
getPageCount
()
*
database
.
getPageStore
().
getPageSize
()
/
1024
)
:
0
;
return
0
;
}
PageStore
p
=
database
.
getPageStore
();
if
(
p
!=
null
)
{
return
p
.
getPageCount
()
*
p
.
getPageSize
()
/
1024
;
}
return
database
.
getMvStore
().
getStore
().
getFileStore
().
size
();
}
}
@Override
@Override
public
int
getCacheSizeMax
()
{
public
int
getCacheSizeMax
()
{
return
database
.
isPersistent
()
?
database
.
getPageStore
().
getCache
().
getMaxMemory
()
:
0
;
if
(!
database
.
isPersistent
())
{
return
0
;
}
PageStore
p
=
database
.
getPageStore
();
if
(
p
!=
null
)
{
return
p
.
getCache
().
getMaxMemory
();
}
return
database
.
getMvStore
().
getStore
().
getCacheSize
()
*
1024
;
}
}
@Override
@Override
public
void
setCacheSizeMax
(
int
kb
)
{
public
void
setCacheSizeMax
(
int
kb
)
{
if
(
database
.
isPersistent
())
{
if
(
database
.
isPersistent
())
{
database
.
getPageStore
().
getCache
().
setMaxMemory
(
kb
);
database
.
setCacheSize
(
kb
);
}
}
}
}
@Override
@Override
public
int
getCacheSize
()
{
public
int
getCacheSize
()
{
return
database
.
isPersistent
()
?
database
.
getPageStore
().
getCache
().
getMemory
()
:
0
;
if
(!
database
.
isPersistent
())
{
return
0
;
}
PageStore
p
=
database
.
getPageStore
();
if
(
p
!=
null
)
{
return
p
.
getCache
().
getMemory
();
}
return
database
.
getMvStore
().
getStore
().
getCacheSizeUsed
()
*
1024
;
}
}
@Override
@Override
...
...
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
320543a6
...
@@ -1432,9 +1432,7 @@ public class MVStore {
...
@@ -1432,9 +1432,7 @@ public class MVStore {
"Negative position {0}"
,
filePos
);
"Negative position {0}"
,
filePos
);
}
}
p
=
Page
.
read
(
fileStore
,
map
,
pos
,
filePos
,
fileStore
.
size
());
p
=
Page
.
read
(
fileStore
,
map
,
pos
,
filePos
,
fileStore
.
size
());
if
(
cache
!=
null
)
{
cachePage
(
pos
,
p
,
p
.
getMemory
());
cache
.
put
(
pos
,
p
,
p
.
getMemory
());
}
}
}
return
p
;
return
p
;
}
}
...
@@ -2012,6 +2010,43 @@ public class MVStore {
...
@@ -2012,6 +2010,43 @@ public class MVStore {
public
int
getUnsavedPageCount
()
{
public
int
getUnsavedPageCount
()
{
return
unsavedPageCount
;
return
unsavedPageCount
;
}
}
/**
* Put the page in the cache.
*
* @param pos the page position
* @param page the page
* @param memory the memory used
*/
void
cachePage
(
long
pos
,
Page
page
,
int
memory
)
{
if
(
cache
!=
null
)
{
cache
.
put
(
pos
,
page
,
memory
);
}
}
/**
* Get the amount of memory used for caching, in MB.
*
* @return the amount of memory used for caching
*/
public
int
getCacheSizeUsed
()
{
if
(
cache
==
null
)
{
return
0
;
}
return
(
int
)
(
cache
.
getUsedMemory
()
/
1024
/
1024
);
}
/**
* Get the maximum cache size, in MB.
*
* @return the cache size
*/
public
int
getCacheSize
()
{
if
(
cache
==
null
)
{
return
0
;
}
return
(
int
)
(
cache
.
getMaxMemory
()
/
1024
/
1024
);
}
/**
/**
* A background writer thread to automatically store changes from time to time.
* A background writer thread to automatically store changes from time to time.
...
...
h2/src/main/org/h2/mvstore/Page.java
浏览文件 @
320543a6
...
@@ -819,7 +819,8 @@ public class Page {
...
@@ -819,7 +819,8 @@ public class Page {
valueType
.
write
(
buff
,
values
[
i
]);
valueType
.
write
(
buff
,
values
[
i
]);
}
}
}
}
if
(
map
.
getStore
().
getCompress
())
{
MVStore
store
=
map
.
getStore
();
if
(
store
.
getCompress
())
{
Compressor
compressor
=
map
.
getStore
().
getCompressor
();
Compressor
compressor
=
map
.
getStore
().
getCompressor
();
int
expLen
=
buff
.
position
()
-
compressStart
;
int
expLen
=
buff
.
position
()
-
compressStart
;
byte
[]
exp
=
new
byte
[
expLen
];
byte
[]
exp
=
new
byte
[
expLen
];
...
@@ -846,6 +847,7 @@ public class Page {
...
@@ -846,6 +847,7 @@ public class Page {
DataUtils
.
ERROR_INTERNAL
,
"Page already stored"
);
DataUtils
.
ERROR_INTERNAL
,
"Page already stored"
);
}
}
pos
=
DataUtils
.
getPagePos
(
chunkId
,
start
,
pageLength
,
type
);
pos
=
DataUtils
.
getPagePos
(
chunkId
,
start
,
pageLength
,
type
);
store
.
cachePage
(
pos
,
this
,
getMemory
());
long
max
=
DataUtils
.
getPageMaxLength
(
pos
);
long
max
=
DataUtils
.
getPageMaxLength
(
pos
);
chunk
.
maxLength
+=
max
;
chunk
.
maxLength
+=
max
;
chunk
.
maxLengthLive
+=
max
;
chunk
.
maxLengthLive
+=
max
;
...
...
h2/src/main/org/h2/mvstore/db/MVTable.java
浏览文件 @
320543a6
...
@@ -625,6 +625,7 @@ public class MVTable extends TableBase {
...
@@ -625,6 +625,7 @@ public class MVTable extends TableBase {
database
.
getLobStorage
().
removeAllForTable
(
getId
());
database
.
getLobStorage
().
removeAllForTable
(
getId
());
database
.
lockMeta
(
session
);
database
.
lockMeta
(
session
);
}
}
database
.
getMvStore
().
removeTable
(
this
);
super
.
removeChildrenAndResources
(
session
);
super
.
removeChildrenAndResources
(
session
);
// go backwards because database.removeIndex will call table.removeIndex
// go backwards because database.removeIndex will call table.removeIndex
while
(
indexes
.
size
()
>
1
)
{
while
(
indexes
.
size
()
>
1
)
{
...
@@ -643,7 +644,6 @@ public class MVTable extends TableBase {
...
@@ -643,7 +644,6 @@ public class MVTable extends TableBase {
}
}
primaryIndex
.
remove
(
session
);
primaryIndex
.
remove
(
session
);
database
.
removeMeta
(
session
,
getId
());
database
.
removeMeta
(
session
,
getId
());
database
.
getMvStore
().
removeTable
(
this
);
primaryIndex
=
null
;
primaryIndex
=
null
;
close
(
session
);
close
(
session
);
invalidate
();
invalidate
();
...
...
h2/src/main/org/h2/schema/Schema.java
浏览文件 @
320543a6
...
@@ -570,7 +570,7 @@ public class Schema extends DbObjectBase {
...
@@ -570,7 +570,7 @@ public class Schema extends DbObjectBase {
}
}
data
.
schema
=
this
;
data
.
schema
=
this
;
if
(
data
.
tableEngine
==
null
)
{
if
(
data
.
tableEngine
==
null
)
{
if
(
database
.
getSettings
().
mvStore
)
{
if
(
database
.
getSettings
().
mvStore
&&
database
.
isPersistent
()
)
{
data
.
tableEngine
=
MVTableEngine
.
class
.
getName
();
data
.
tableEngine
=
MVTableEngine
.
class
.
getName
();
}
}
}
}
...
...
h2/src/main/org/h2/server/TcpServerThread.java
浏览文件 @
320543a6
...
@@ -135,8 +135,6 @@ public class TcpServerThread implements Runnable {
...
@@ -135,8 +135,6 @@ public class TcpServerThread implements Runnable {
if
(
server
.
getIfExists
())
{
if
(
server
.
getIfExists
())
{
ci
.
setProperty
(
"IFEXISTS"
,
"TRUE"
);
ci
.
setProperty
(
"IFEXISTS"
,
"TRUE"
);
}
}
session
=
Engine
.
getInstance
().
createSession
(
ci
);
transfer
.
setSession
(
session
);
transfer
.
writeInt
(
SessionRemote
.
STATUS_OK
);
transfer
.
writeInt
(
SessionRemote
.
STATUS_OK
);
transfer
.
writeInt
(
clientVersion
);
transfer
.
writeInt
(
clientVersion
);
transfer
.
flush
();
transfer
.
flush
();
...
@@ -145,6 +143,8 @@ public class TcpServerThread implements Runnable {
...
@@ -145,6 +143,8 @@ public class TcpServerThread implements Runnable {
ci
.
setFileEncryptionKey
(
transfer
.
readBytes
());
ci
.
setFileEncryptionKey
(
transfer
.
readBytes
());
}
}
}
}
session
=
Engine
.
getInstance
().
createSession
(
ci
);
transfer
.
setSession
(
session
);
server
.
addConnection
(
threadId
,
originalURL
,
ci
.
getUserName
());
server
.
addConnection
(
threadId
,
originalURL
,
ci
.
getUserName
());
trace
(
"Connected"
);
trace
(
"Connected"
);
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
...
...
h2/src/main/org/h2/store/RecoverTester.java
浏览文件 @
320543a6
...
@@ -68,7 +68,8 @@ public class RecoverTester implements Recorder {
...
@@ -68,7 +68,8 @@ public class RecoverTester implements Recorder {
if
(
op
!=
Recorder
.
WRITE
&&
op
!=
Recorder
.
TRUNCATE
)
{
if
(
op
!=
Recorder
.
WRITE
&&
op
!=
Recorder
.
TRUNCATE
)
{
return
;
return
;
}
}
if
(!
fileName
.
endsWith
(
Constants
.
SUFFIX_PAGE_FILE
))
{
if
(!
fileName
.
endsWith
(
Constants
.
SUFFIX_PAGE_FILE
)
&&
!
fileName
.
endsWith
(
Constants
.
SUFFIX_MV_FILE
))
{
return
;
return
;
}
}
writeCount
++;
writeCount
++;
...
...
h2/src/main/org/h2/table/MetaTable.java
浏览文件 @
320543a6
...
@@ -40,6 +40,8 @@ import org.h2.index.IndexType;
...
@@ -40,6 +40,8 @@ import org.h2.index.IndexType;
import
org.h2.index.MetaIndex
;
import
org.h2.index.MetaIndex
;
import
org.h2.index.MultiVersionIndex
;
import
org.h2.index.MultiVersionIndex
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.mvstore.FileStore
;
import
org.h2.mvstore.db.MVTableEngine.Store
;
import
org.h2.result.Row
;
import
org.h2.result.Row
;
import
org.h2.result.SearchRow
;
import
org.h2.result.SearchRow
;
import
org.h2.result.SortOrder
;
import
org.h2.result.SortOrder
;
...
@@ -919,13 +921,23 @@ public class MetaTable extends Table {
...
@@ -919,13 +921,23 @@ public class MetaTable extends Table {
}
}
if
(
database
.
isPersistent
())
{
if
(
database
.
isPersistent
())
{
PageStore
store
=
database
.
getPageStore
();
PageStore
store
=
database
.
getPageStore
();
add
(
rows
,
"info.FILE_WRITE_TOTAL"
,
""
+
store
.
getWriteCountTotal
());
if
(
store
!=
null
)
{
add
(
rows
,
"info.FILE_WRITE"
,
""
+
store
.
getWriteCount
());
add
(
rows
,
"info.FILE_WRITE_TOTAL"
,
""
+
store
.
getWriteCountTotal
());
add
(
rows
,
"info.FILE_READ"
,
""
+
store
.
getReadCount
());
add
(
rows
,
"info.FILE_WRITE"
,
""
+
store
.
getWriteCount
());
add
(
rows
,
"info.PAGE_COUNT"
,
""
+
store
.
getPageCount
());
add
(
rows
,
"info.FILE_READ"
,
""
+
store
.
getReadCount
());
add
(
rows
,
"info.PAGE_SIZE"
,
""
+
store
.
getPageSize
());
add
(
rows
,
"info.PAGE_COUNT"
,
""
+
store
.
getPageCount
());
add
(
rows
,
"info.CACHE_MAX_SIZE"
,
""
+
store
.
getCache
().
getMaxMemory
());
add
(
rows
,
"info.PAGE_SIZE"
,
""
+
store
.
getPageSize
());
add
(
rows
,
"info.CACHE_SIZE"
,
""
+
store
.
getCache
().
getMemory
());
add
(
rows
,
"info.CACHE_MAX_SIZE"
,
""
+
store
.
getCache
().
getMaxMemory
());
add
(
rows
,
"info.CACHE_SIZE"
,
""
+
store
.
getCache
().
getMemory
());
}
Store
mvStore
=
database
.
getMvStore
();
if
(
mvStore
!=
null
)
{
FileStore
fs
=
mvStore
.
getStore
().
getFileStore
();
add
(
rows
,
"info.FILE_WRITE"
,
""
+
fs
.
getWriteCount
());
add
(
rows
,
"info.FILE_READ"
,
""
+
fs
.
getReadCount
());
add
(
rows
,
"info.CACHE_MAX_SIZE"
,
""
+
mvStore
.
getStore
().
getCacheSize
());
add
(
rows
,
"info.CACHE_SIZE"
,
""
+
mvStore
.
getStore
().
getCacheSizeUsed
());
}
}
}
break
;
break
;
}
}
...
...
h2/src/main/org/h2/tools/Backup.java
浏览文件 @
320543a6
...
@@ -130,7 +130,9 @@ public class Backup extends Tool {
...
@@ -130,7 +130,9 @@ public class Backup extends Tool {
ZipOutputStream
zipOut
=
new
ZipOutputStream
(
fileOut
);
ZipOutputStream
zipOut
=
new
ZipOutputStream
(
fileOut
);
String
base
=
""
;
String
base
=
""
;
for
(
String
fileName
:
list
)
{
for
(
String
fileName
:
list
)
{
if
(
fileName
.
endsWith
(
Constants
.
SUFFIX_PAGE_FILE
)
||
allFiles
)
{
if
(
allFiles
||
fileName
.
endsWith
(
Constants
.
SUFFIX_PAGE_FILE
)
||
fileName
.
endsWith
(
Constants
.
SUFFIX_MV_FILE
))
{
base
=
FileUtils
.
getParent
(
fileName
);
base
=
FileUtils
.
getParent
(
fileName
);
break
;
break
;
}
}
...
...
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
320543a6
...
@@ -91,7 +91,6 @@ public class Recover extends Tool implements DataHandler {
...
@@ -91,7 +91,6 @@ public class Recover extends Tool implements DataHandler {
private
int
pageSize
;
private
int
pageSize
;
private
FileStore
store
;
private
FileStore
store
;
private
int
[]
parents
;
private
int
[]
parents
;
private
String
mvFile
;
private
Stats
stat
;
private
Stats
stat
;
...
@@ -250,16 +249,15 @@ public class Recover extends Tool implements DataHandler {
...
@@ -250,16 +249,15 @@ public class Recover extends Tool implements DataHandler {
}
}
for
(
String
fileName
:
list
)
{
for
(
String
fileName
:
list
)
{
if
(
fileName
.
endsWith
(
Constants
.
SUFFIX_PAGE_FILE
))
{
if
(
fileName
.
endsWith
(
Constants
.
SUFFIX_PAGE_FILE
))
{
String
mvFile
=
fileName
.
substring
(
0
,
fileName
.
length
()
-
Constants
.
SUFFIX_PAGE_FILE
.
length
())
+
Constants
.
SUFFIX_MV_FILE
;
if
(
list
.
contains
(
mvFile
))
{
this
.
mvFile
=
mvFile
;
}
dumpPageStore
(
fileName
);
dumpPageStore
(
fileName
);
}
else
if
(
fileName
.
endsWith
(
Constants
.
SUFFIX_LOB_FILE
))
{
}
else
if
(
fileName
.
endsWith
(
Constants
.
SUFFIX_LOB_FILE
))
{
dumpLob
(
fileName
,
false
);
dumpLob
(
fileName
,
false
);
}
else
if
(
fileName
.
endsWith
(
Constants
.
SUFFIX_MV_FILE
))
{
}
else
if
(
fileName
.
endsWith
(
Constants
.
SUFFIX_MV_FILE
))
{
PrintWriter
writer
=
getWriter
(
fileName
,
".txt"
);
String
f
=
fileName
.
substring
(
0
,
fileName
.
length
()
-
Constants
.
SUFFIX_PAGE_FILE
.
length
());
PrintWriter
writer
=
getWriter
(
f
+
".h2.db"
,
".sql"
);
dumpMVStoreFile
(
writer
,
fileName
);
writer
.
close
();
writer
=
getWriter
(
fileName
,
".txt"
);
MVStoreTool
.
dump
(
fileName
,
writer
);
MVStoreTool
.
dump
(
fileName
,
writer
);
writer
.
close
();
writer
.
close
();
}
}
...
@@ -455,9 +453,6 @@ public class Recover extends Tool implements DataHandler {
...
@@ -455,9 +453,6 @@ public class Recover extends Tool implements DataHandler {
schema
.
clear
();
schema
.
clear
();
objectIdSet
=
New
.
hashSet
();
objectIdSet
=
New
.
hashSet
();
dumpPageStore
(
writer
,
pageCount
);
dumpPageStore
(
writer
,
pageCount
);
if
(
mvFile
!=
null
)
{
dumpMVStoreFile
(
writer
,
mvFile
);
}
writeSchema
(
writer
);
writeSchema
(
writer
);
try
{
try
{
dumpPageLogStream
(
writer
,
logKey
,
logFirstTrunkPage
,
logFirstDataPage
,
pageCount
);
dumpPageLogStream
(
writer
,
logKey
,
logFirstTrunkPage
,
logFirstDataPage
,
pageCount
);
...
@@ -488,6 +483,11 @@ public class Recover extends Tool implements DataHandler {
...
@@ -488,6 +483,11 @@ public class Recover extends Tool implements DataHandler {
private
void
dumpMVStoreFile
(
PrintWriter
writer
,
String
fileName
)
{
private
void
dumpMVStoreFile
(
PrintWriter
writer
,
String
fileName
)
{
writer
.
println
(
"-- mvstore"
);
writer
.
println
(
"-- mvstore"
);
writer
.
println
(
"CREATE ALIAS IF NOT EXISTS READ_BLOB FOR \""
+
this
.
getClass
().
getName
()
+
".readBlob\";"
);
writer
.
println
(
"CREATE ALIAS IF NOT EXISTS READ_CLOB FOR \""
+
this
.
getClass
().
getName
()
+
".readClob\";"
);
writer
.
println
(
"CREATE ALIAS IF NOT EXISTS READ_BLOB_DB FOR \""
+
this
.
getClass
().
getName
()
+
".readBlobDb\";"
);
writer
.
println
(
"CREATE ALIAS IF NOT EXISTS READ_CLOB_DB FOR \""
+
this
.
getClass
().
getName
()
+
".readClobDb\";"
);
resetSchema
();
setDatabaseName
(
fileName
.
substring
(
0
,
fileName
.
length
()
-
Constants
.
SUFFIX_MV_FILE
.
length
()));
setDatabaseName
(
fileName
.
substring
(
0
,
fileName
.
length
()
-
Constants
.
SUFFIX_MV_FILE
.
length
()));
MVStore
mv
=
new
MVStore
.
Builder
().
fileName
(
fileName
).
readOnly
().
open
();
MVStore
mv
=
new
MVStore
.
Builder
().
fileName
(
fileName
).
readOnly
().
open
();
TransactionStore
store
=
new
TransactionStore
(
mv
);
TransactionStore
store
=
new
TransactionStore
(
mv
);
...
@@ -551,6 +551,7 @@ public class Recover extends Tool implements DataHandler {
...
@@ -551,6 +551,7 @@ public class Recover extends Tool implements DataHandler {
}
}
}
}
}
}
writeSchema
(
writer
);
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
writeError
(
writer
,
e
);
writeError
(
writer
,
e
);
}
finally
{
}
finally
{
...
...
h2/src/main/org/h2/tools/Restore.java
浏览文件 @
320543a6
...
@@ -124,6 +124,9 @@ public class Restore extends Tool {
...
@@ -124,6 +124,9 @@ public class Restore extends Tool {
if
(
fileName
.
endsWith
(
Constants
.
SUFFIX_PAGE_FILE
))
{
if
(
fileName
.
endsWith
(
Constants
.
SUFFIX_PAGE_FILE
))
{
return
fileName
.
substring
(
0
,
fileName
.
length
()
-
Constants
.
SUFFIX_PAGE_FILE
.
length
());
return
fileName
.
substring
(
0
,
fileName
.
length
()
-
Constants
.
SUFFIX_PAGE_FILE
.
length
());
}
}
if
(
fileName
.
endsWith
(
Constants
.
SUFFIX_MV_FILE
))
{
return
fileName
.
substring
(
0
,
fileName
.
length
()
-
Constants
.
SUFFIX_MV_FILE
.
length
());
}
return
null
;
return
null
;
}
}
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
320543a6
...
@@ -730,7 +730,6 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
...
@@ -730,7 +730,6 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
// synth
// synth
new
TestBtreeIndex
().
runTest
(
this
);
new
TestBtreeIndex
().
runTest
(
this
);
new
TestDiskFull
().
runTest
(
this
);
new
TestDiskFull
().
runTest
(
this
);
new
TestCrashAPI
().
runTest
(
this
);
new
TestCrashAPI
().
runTest
(
this
);
new
TestFuzzOptimizations
().
runTest
(
this
);
new
TestFuzzOptimizations
().
runTest
(
this
);
...
...
h2/src/test/org/h2/test/db/TestOpenClose.java
浏览文件 @
320543a6
...
@@ -15,6 +15,7 @@ import java.sql.SQLException;
...
@@ -15,6 +15,7 @@ import java.sql.SQLException;
import
java.sql.Statement
;
import
java.sql.Statement
;
import
org.h2.api.DatabaseEventListener
;
import
org.h2.api.DatabaseEventListener
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.ErrorCode
;
import
org.h2.engine.Constants
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.tools.Restore
;
import
org.h2.tools.Restore
;
...
@@ -63,17 +64,29 @@ public class TestOpenClose extends TestBase {
...
@@ -63,17 +64,29 @@ public class TestOpenClose extends TestBase {
if
(
config
.
memory
||
config
.
reopen
)
{
if
(
config
.
memory
||
config
.
reopen
)
{
return
;
return
;
}
}
FileUtils
.
delete
(
"split:"
+
getBaseDir
()
+
"/openClose2.h2.db"
);
String
fn
=
getBaseDir
()
+
"/openClose2"
;
if
(
config
.
mvStore
)
{
fn
+=
Constants
.
SUFFIX_MV_FILE
;
}
else
{
fn
+=
Constants
.
SUFFIX_PAGE_FILE
;
}
FileUtils
.
delete
(
"split:"
+
fn
);
Connection
conn
;
Connection
conn
;
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:split:18:"
+
getBaseDir
()
+
"/openClose2"
);
String
url
=
"jdbc:h2:split:18:"
+
getBaseDir
()
+
"/openClose2"
;
url
=
getURL
(
url
,
true
);
conn
=
DriverManager
.
getConnection
(
url
);
conn
.
createStatement
().
execute
(
"create table test(id int, name varchar) as select 1, space(1000000)"
);
conn
.
createStatement
().
execute
(
"create table test(id int, name varchar) as select 1, space(1000000)"
);
conn
.
close
();
conn
.
close
();
FileChannel
c
=
FileUtils
.
open
(
getBaseDir
()
+
"/openClose2.h2.db
.1.part"
,
"rw"
);
FileChannel
c
=
FileUtils
.
open
(
fn
+
"
.1.part"
,
"rw"
);
c
.
position
(
c
.
size
()
*
2
-
1
);
c
.
position
(
c
.
size
()
*
2
-
1
);
c
.
write
(
ByteBuffer
.
wrap
(
new
byte
[
1
]));
c
.
write
(
ByteBuffer
.
wrap
(
new
byte
[
1
]));
c
.
close
();
c
.
close
();
assertThrows
(
ErrorCode
.
IO_EXCEPTION_2
,
this
).
getConnection
(
"jdbc:h2:split:18:"
+
getBaseDir
()
+
"/openClose2"
);
if
(
config
.
mvStore
)
{
FileUtils
.
delete
(
"split:"
+
getBaseDir
()
+
"/openClose2.h2.db"
);
assertThrows
(
ErrorCode
.
FILE_CORRUPTED_1
,
this
).
getConnection
(
url
);
}
else
{
assertThrows
(
ErrorCode
.
IO_EXCEPTION_2
,
this
).
getConnection
(
url
);
}
FileUtils
.
delete
(
"split:"
+
fn
);
}
}
private
void
testCloseDelay
()
throws
Exception
{
private
void
testCloseDelay
()
throws
Exception
{
...
...
h2/src/test/org/h2/test/db/TestTempTables.java
浏览文件 @
320543a6
...
@@ -160,6 +160,9 @@ public class TestTempTables extends TestBase {
...
@@ -160,6 +160,9 @@ public class TestTempTables extends TestBase {
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
return
;
}
}
if
(
config
.
mvStore
)
{
return
;
}
deleteDb
(
"tempTables"
);
deleteDb
(
"tempTables"
);
Connection
conn
=
getConnection
(
"tempTables"
);
Connection
conn
=
getConnection
(
"tempTables"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
...
...
h2/src/test/org/h2/test/server/TestWeb.java
浏览文件 @
320543a6
...
@@ -37,6 +37,7 @@ import javax.servlet.ServletContext;
...
@@ -37,6 +37,7 @@ import javax.servlet.ServletContext;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Constants
;
import
org.h2.server.web.WebServlet
;
import
org.h2.server.web.WebServlet
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
...
@@ -178,10 +179,16 @@ public class TestWeb extends TestBase {
...
@@ -178,10 +179,16 @@ public class TestWeb extends TestBase {
assertTrue
(
FileUtils
.
exists
(
getBaseDir
()
+
"/backup.zip"
));
assertTrue
(
FileUtils
.
exists
(
getBaseDir
()
+
"/backup.zip"
));
result
=
client
.
get
(
url
,
"tools.do?tool=DeleteDbFiles&args=-dir,"
+
result
=
client
.
get
(
url
,
"tools.do?tool=DeleteDbFiles&args=-dir,"
+
getBaseDir
()
+
",-db,web"
);
getBaseDir
()
+
",-db,web"
);
assertFalse
(
FileUtils
.
exists
(
getBaseDir
()
+
"/web.h2.db"
));
String
fn
=
getBaseDir
()
+
"/web"
;
if
(
config
.
mvStore
)
{
fn
+=
Constants
.
SUFFIX_MV_FILE
;
}
else
{
fn
+=
Constants
.
SUFFIX_PAGE_FILE
;
}
assertFalse
(
FileUtils
.
exists
(
fn
));
result
=
client
.
get
(
url
,
"tools.do?tool=Restore&args=-dir,"
+
result
=
client
.
get
(
url
,
"tools.do?tool=Restore&args=-dir,"
+
getBaseDir
()
+
",-db,web,-file,"
+
getBaseDir
()
+
"/backup.zip"
);
getBaseDir
()
+
",-db,web,-file,"
+
getBaseDir
()
+
"/backup.zip"
);
assertTrue
(
FileUtils
.
exists
(
getBaseDir
()
+
"/web.h2.db"
));
assertTrue
(
FileUtils
.
exists
(
fn
));
FileUtils
.
delete
(
getBaseDir
()
+
"/web.h2.sql"
);
FileUtils
.
delete
(
getBaseDir
()
+
"/web.h2.sql"
);
FileUtils
.
delete
(
getBaseDir
()
+
"/backup.zip"
);
FileUtils
.
delete
(
getBaseDir
()
+
"/backup.zip"
);
result
=
client
.
get
(
url
,
"tools.do?tool=Recover&args=-dir,"
+
result
=
client
.
get
(
url
,
"tools.do?tool=Recover&args=-dir,"
+
...
@@ -192,7 +199,7 @@ public class TestWeb extends TestBase {
...
@@ -192,7 +199,7 @@ public class TestWeb extends TestBase {
getBaseDir
()
+
"/web.h2.sql,-url,"
+
getURL
(
"web"
,
true
)
+
getBaseDir
()
+
"/web.h2.sql,-url,"
+
getURL
(
"web"
,
true
)
+
",-user,"
+
getUser
()
+
",-password,"
+
getPassword
());
",-user,"
+
getUser
()
+
",-password,"
+
getPassword
());
FileUtils
.
delete
(
getBaseDir
()
+
"/web.h2.sql"
);
FileUtils
.
delete
(
getBaseDir
()
+
"/web.h2.sql"
);
assertTrue
(
FileUtils
.
exists
(
getBaseDir
()
+
"/web.h2.db"
));
assertTrue
(
FileUtils
.
exists
(
fn
));
deleteDb
(
"web"
);
deleteDb
(
"web"
);
}
finally
{
}
finally
{
server
.
shutdown
();
server
.
shutdown
();
...
...
h2/src/test/org/h2/test/store/TestMVStore.java
浏览文件 @
320543a6
...
@@ -48,6 +48,7 @@ public class TestMVStore extends TestBase {
...
@@ -48,6 +48,7 @@ public class TestMVStore extends TestBase {
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
FileUtils
.
deleteRecursive
(
getBaseDir
(),
true
);
FileUtils
.
deleteRecursive
(
getBaseDir
(),
true
);
FileUtils
.
createDirectories
(
getBaseDir
());
FileUtils
.
createDirectories
(
getBaseDir
());
testCacheInfo
();
testRollback
();
testRollback
();
testVersionsToKeep
();
testVersionsToKeep
();
testRemoveMap
();
testRemoveMap
();
...
@@ -98,6 +99,29 @@ public class TestMVStore extends TestBase {
...
@@ -98,6 +99,29 @@ public class TestMVStore extends TestBase {
// longer running tests
// longer running tests
testLargerThan2G
();
testLargerThan2G
();
}
}
private
void
testCacheInfo
()
{
String
fileName
=
getBaseDir
()
+
"/testCloseMap.h3"
;
MVStore
s
=
new
MVStore
.
Builder
().
fileName
(
fileName
).
cacheSize
(
2
).
open
();
assertEquals
(
2
,
s
.
getCacheSize
());
MVMap
<
Integer
,
byte
[]>
map
;
map
=
s
.
openMap
(
"data"
);
byte
[]
data
=
new
byte
[
100
*
1024
];
for
(
int
i
=
0
;
i
<
30
;
i
++)
{
map
.
put
(
i
,
data
);
s
.
commit
();
if
(
i
<
10
)
{
assertEquals
(
0
,
s
.
getCacheSizeUsed
());
}
else
if
(
i
>
20
)
{
assertEquals
(
1
,
s
.
getCacheSizeUsed
());
}
}
s
.
close
();
s
=
new
MVStore
.
Builder
().
open
();
assertEquals
(
0
,
s
.
getCacheSize
());
assertEquals
(
0
,
s
.
getCacheSizeUsed
());
s
.
close
();
}
private
void
testVersionsToKeep
()
throws
Exception
{
private
void
testVersionsToKeep
()
throws
Exception
{
MVStore
s
=
new
MVStore
.
Builder
().
open
();
MVStore
s
=
new
MVStore
.
Builder
().
open
();
...
@@ -576,9 +600,11 @@ public class TestMVStore extends TestBase {
...
@@ -576,9 +600,11 @@ public class TestMVStore extends TestBase {
3406
,
2590
,
1924
,
1440
,
1102
,
956
,
918
3406
,
2590
,
1924
,
1440
,
1102
,
956
,
918
};
};
for
(
int
cacheSize
=
0
;
cacheSize
<=
6
;
cacheSize
+=
4
)
{
for
(
int
cacheSize
=
0
;
cacheSize
<=
6
;
cacheSize
+=
4
)
{
int
cacheMB
=
1
+
3
*
cacheSize
;
s
=
new
MVStore
.
Builder
().
s
=
new
MVStore
.
Builder
().
fileName
(
fileName
).
fileName
(
fileName
).
cacheSize
(
1
+
3
*
cacheSize
).
open
();
cacheSize
(
cacheMB
).
open
();
assertEquals
(
cacheMB
,
s
.
getCacheSize
());
map
=
s
.
openMap
(
"test"
);
map
=
s
.
openMap
(
"test"
);
for
(
int
i
=
0
;
i
<
1024
;
i
+=
128
)
{
for
(
int
i
=
0
;
i
<
1024
;
i
+=
128
)
{
for
(
int
j
=
0
;
j
<
i
;
j
++)
{
for
(
int
j
=
0
;
j
<
i
;
j
++)
{
...
...
h2/src/test/org/h2/test/store/TestMVTableEngine.java
浏览文件 @
320543a6
...
@@ -534,7 +534,7 @@ public class TestMVTableEngine extends TestBase {
...
@@ -534,7 +534,7 @@ public class TestMVTableEngine extends TestBase {
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id int)"
);
stat
.
execute
(
"create table test(id int)"
);
conn
.
close
();
conn
.
close
();
FileUtils
.
setReadOnly
(
getBaseDir
()
+
"/mvstore
.h2.db"
);
FileUtils
.
setReadOnly
(
getBaseDir
()
+
"/mvstore
"
+
Constants
.
SUFFIX_MV_FILE
);
conn
=
getConnection
(
dbName
);
conn
=
getConnection
(
dbName
);
Database
db
=
(
Database
)
((
JdbcConnection
)
conn
).
getSession
().
getDataHandler
();
Database
db
=
(
Database
)
((
JdbcConnection
)
conn
).
getSession
().
getDataHandler
();
assertTrue
(
db
.
getMvStore
().
getStore
().
getFileStore
().
isReadOnly
());
assertTrue
(
db
.
getMvStore
().
getStore
().
getFileStore
().
isReadOnly
());
...
...
h2/src/test/org/h2/test/unit/TestClearReferences.java
浏览文件 @
320543a6
...
@@ -105,6 +105,9 @@ public class TestClearReferences extends TestBase {
...
@@ -105,6 +105,9 @@ public class TestClearReferences extends TestBase {
if
(!
name
.
endsWith
(
".class"
))
{
if
(!
name
.
endsWith
(
".class"
))
{
return
;
return
;
}
}
if
(
name
.
indexOf
(
'$'
)
>=
0
)
{
return
;
}
String
className
=
file
.
getAbsolutePath
().
replace
(
'\\'
,
'/'
);
String
className
=
file
.
getAbsolutePath
().
replace
(
'\\'
,
'/'
);
className
=
className
.
substring
(
className
.
lastIndexOf
(
"org/h2"
));
className
=
className
.
substring
(
className
.
lastIndexOf
(
"org/h2"
));
String
packageName
=
className
.
substring
(
0
,
className
.
lastIndexOf
(
'/'
));
String
packageName
=
className
.
substring
(
0
,
className
.
lastIndexOf
(
'/'
));
...
...
h2/src/test/org/h2/test/unit/TestJmx.java
浏览文件 @
320543a6
...
@@ -101,6 +101,8 @@ public class TestJmx extends TestBase {
...
@@ -101,6 +101,8 @@ public class TestJmx extends TestBase {
conn
.
close
();
conn
.
close
();
conn
=
getConnection
(
"jmx;jmx=true"
);
conn
.
close
();
conn
=
getConnection
(
"jmx;jmx=true"
);
conn
=
getConnection
(
"jmx;jmx=true"
);
name
=
new
ObjectName
(
"org.h2:name=JMX,*"
);
name
=
new
ObjectName
(
"org.h2:name=JMX,*"
);
...
@@ -110,12 +112,20 @@ public class TestJmx extends TestBase {
...
@@ -110,12 +112,20 @@ public class TestJmx extends TestBase {
assertEquals
(
"16384"
,
mbeanServer
.
getAttribute
(
name
,
"CacheSizeMax"
).
toString
());
assertEquals
(
"16384"
,
mbeanServer
.
getAttribute
(
name
,
"CacheSizeMax"
).
toString
());
mbeanServer
.
setAttribute
(
name
,
new
Attribute
(
"CacheSizeMax"
,
1
));
mbeanServer
.
setAttribute
(
name
,
new
Attribute
(
"CacheSizeMax"
,
1
));
assertEquals
(
"1"
,
mbeanServer
.
getAttribute
(
name
,
"CacheSizeMax"
).
toString
());
if
(
config
.
mvStore
)
{
assertTrue
(
0
<
(
Integer
)
mbeanServer
.
getAttribute
(
name
,
"CacheSize"
));
assertEquals
(
"1024"
,
mbeanServer
.
getAttribute
(
name
,
"CacheSizeMax"
).
toString
());
assertTrue
(
0
<
(
Long
)
mbeanServer
.
getAttribute
(
name
,
"FileSize"
));
assertEquals
(
"0"
,
mbeanServer
.
getAttribute
(
name
,
"CacheSize"
).
toString
());
assertTrue
(
0
<
(
Long
)
mbeanServer
.
getAttribute
(
name
,
"FileReadCount"
));
assertTrue
(
0
<
(
Long
)
mbeanServer
.
getAttribute
(
name
,
"FileReadCount"
));
assertTrue
(
0
<
(
Long
)
mbeanServer
.
getAttribute
(
name
,
"FileWriteCount"
));
assertTrue
(
0
<
(
Long
)
mbeanServer
.
getAttribute
(
name
,
"FileWriteCount"
));
assertTrue
(
0
<
(
Long
)
mbeanServer
.
getAttribute
(
name
,
"FileWriteCountTotal"
));
assertEquals
(
"0"
,
mbeanServer
.
getAttribute
(
name
,
"FileWriteCountTotal"
).
toString
());
}
else
{
assertEquals
(
"1"
,
mbeanServer
.
getAttribute
(
name
,
"CacheSizeMax"
).
toString
());
assertTrue
(
0
<
(
Integer
)
mbeanServer
.
getAttribute
(
name
,
"CacheSize"
));
assertTrue
(
0
<
(
Long
)
mbeanServer
.
getAttribute
(
name
,
"FileSize"
));
assertTrue
(
0
<
(
Long
)
mbeanServer
.
getAttribute
(
name
,
"FileReadCount"
));
assertTrue
(
0
<
(
Long
)
mbeanServer
.
getAttribute
(
name
,
"FileWriteCount"
));
assertTrue
(
0
<
(
Long
)
mbeanServer
.
getAttribute
(
name
,
"FileWriteCountTotal"
));
}
mbeanServer
.
setAttribute
(
name
,
new
Attribute
(
"LogMode"
,
0
));
mbeanServer
.
setAttribute
(
name
,
new
Attribute
(
"LogMode"
,
0
));
assertEquals
(
"0"
,
mbeanServer
.
getAttribute
(
name
,
"LogMode"
).
toString
());
assertEquals
(
"0"
,
mbeanServer
.
getAttribute
(
name
,
"LogMode"
).
toString
());
...
...
h2/src/tools/org/h2/android/H2Database.java
浏览文件 @
320543a6
...
@@ -247,8 +247,7 @@ public class H2Database {
...
@@ -247,8 +247,7 @@ public class H2Database {
* @return the page size
* @return the page size
*/
*/
public
long
getPageSize
()
{
public
long
getPageSize
()
{
PageStore
store
=
session
.
getDatabase
().
getPageStore
();
return
0
;
return
store
==
null
?
0
:
store
.
getPageSize
();
}
}
/**
/**
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论