Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
fb08a1fa
Unverified
提交
fb08a1fa
authored
6 年前
作者:
Evgenij Ryazanov
提交者:
GitHub
6 年前
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1150 from katzyn/check2
Get rid of SysProperties.CHECK2
上级
9ce14802
8fe90f7a
master
version-1.4.198
无相关合并请求
显示空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
58 行增加
和
66 行删除
+58
-66
roadmap.html
h2/src/docsrc/html/roadmap.html
+1
-1
Database.java
h2/src/main/org/h2/engine/Database.java
+30
-10
Session.java
h2/src/main/org/h2/engine/Session.java
+1
-6
SysProperties.java
h2/src/main/org/h2/engine/SysProperties.java
+1
-8
PageDataLeaf.java
h2/src/main/org/h2/index/PageDataLeaf.java
+1
-5
PageDataNode.java
h2/src/main/org/h2/index/PageDataNode.java
+1
-5
Data.java
h2/src/main/org/h2/store/Data.java
+2
-7
FileStore.java
h2/src/main/org/h2/store/FileStore.java
+19
-10
LobStorageBackend.java
h2/src/main/org/h2/store/LobStorageBackend.java
+2
-10
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+0
-2
TestTempTableCrash.java
h2/src/test/org/h2/test/todo/TestTempTableCrash.java
+0
-1
TestPageStore.java
h2/src/test/org/h2/test/unit/TestPageStore.java
+0
-1
没有找到文件。
h2/src/docsrc/html/roadmap.html
浏览文件 @
fb08a1fa
...
...
@@ -83,7 +83,7 @@ See also <a href="build.html#providing_patches">Providing Patches</a>.
</li><li>
Find a tool to view large text file (larger than 100 MB), with find, page up and down (like less), truncate before / after.
</li><li>
Implement, test, document XAConnection and so on.
</li><li>
Pluggable data type (for streaming, hashing, compression, validation, conversion, encryption).
</li><li>
CHECK: find out what makes CHECK=TRUE slow, move to
CHECK2
.
</li><li>
CHECK: find out what makes CHECK=TRUE slow, move to
assertions
.
</li><li>
Drop with invalidate views (so that source code is not lost). Check what other databases do exactly.
</li><li>
Index usage for (ID, NAME)=(1, 'Hi'); document.
</li><li>
Set a connection read only (Connection.setReadOnly) or using a connection parameter.
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Database.java
浏览文件 @
fb08a1fa
...
...
@@ -91,9 +91,27 @@ public class Database implements DataHandler {
private
static
int
initialPowerOffCount
;
private
static
final
ThreadLocal
<
Session
>
META_LOCK_DEBUGGING
=
new
ThreadLocal
<>();
private
static
final
ThreadLocal
<
Database
>
META_LOCK_DEBUGGING_DB
=
new
ThreadLocal
<>();
private
static
final
ThreadLocal
<
Throwable
>
META_LOCK_DEBUGGING_STACK
=
new
ThreadLocal
<>();
private
static
final
boolean
ASSERT
;
private
static
final
ThreadLocal
<
Session
>
META_LOCK_DEBUGGING
;
private
static
final
ThreadLocal
<
Database
>
META_LOCK_DEBUGGING_DB
;
private
static
final
ThreadLocal
<
Throwable
>
META_LOCK_DEBUGGING_STACK
;
static
{
boolean
a
=
false
;
// Intentional side-effect
assert
a
=
true
;
ASSERT
=
a
;
if
(
a
)
{
META_LOCK_DEBUGGING
=
new
ThreadLocal
<>();
META_LOCK_DEBUGGING_DB
=
new
ThreadLocal
<>();
META_LOCK_DEBUGGING_STACK
=
new
ThreadLocal
<>();
}
else
{
META_LOCK_DEBUGGING
=
null
;
META_LOCK_DEBUGGING_DB
=
null
;
META_LOCK_DEBUGGING_STACK
=
null
;
}
}
/**
* The default name of the system user. This name is only used as long as
...
...
@@ -208,9 +226,11 @@ public class Database implements DataHandler {
private
RowFactory
rowFactory
=
RowFactory
.
DEFAULT
;
public
Database
(
ConnectionInfo
ci
,
String
cipher
)
{
if
(
ASSERT
)
{
META_LOCK_DEBUGGING
.
set
(
null
);
META_LOCK_DEBUGGING_DB
.
set
(
null
);
META_LOCK_DEBUGGING_STACK
.
set
(
null
);
}
String
name
=
ci
.
getName
();
this
.
dbSettings
=
ci
.
getDbSettings
();
this
.
reconnectCheckDelayNs
=
TimeUnit
.
MILLISECONDS
.
toNanos
(
dbSettings
.
reconnectCheckDelay
);
...
...
@@ -919,7 +939,7 @@ public class Database implements DataHandler {
if
(
meta
==
null
)
{
return
true
;
}
if
(
SysProperties
.
CHECK2
)
{
if
(
ASSERT
)
{
// If we are locking two different databases in the same stack, just ignore it.
// This only happens in TestLinkedTable where we connect to another h2 DB in the
// same process.
...
...
@@ -961,7 +981,7 @@ public class Database implements DataHandler {
* @param session the session
*/
public
void
unlockMetaDebug
(
Session
session
)
{
if
(
SysProperties
.
CHECK2
)
{
if
(
ASSERT
)
{
if
(
META_LOCK_DEBUGGING
.
get
()
==
session
)
{
META_LOCK_DEBUGGING
.
set
(
null
);
META_LOCK_DEBUGGING_DB
.
set
(
null
);
...
...
@@ -1405,7 +1425,7 @@ public class Database implements DataHandler {
unlockMeta
(
pageStore
.
getPageStoreSession
());
}
}
catch
(
DbException
e
)
{
if
(
SysProperties
.
CHECK2
)
{
if
(
ASSERT
)
{
int
code
=
e
.
getErrorCode
();
if
(
code
!=
ErrorCode
.
DATABASE_IS_CLOSED
&&
code
!=
ErrorCode
.
LOCK_TIMEOUT_1
&&
...
...
@@ -1415,7 +1435,7 @@ public class Database implements DataHandler {
}
trace
.
error
(
e
,
"close"
);
}
catch
(
Throwable
t
)
{
if
(
SysProperties
.
CHECK2
)
{
if
(
ASSERT
)
{
t
.
printStackTrace
();
}
trace
.
error
(
t
,
"close"
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Session.java
浏览文件 @
fb08a1fa
...
...
@@ -722,12 +722,7 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
}
private
void
removeTemporaryLobs
(
boolean
onTimeout
)
{
if
(
SysProperties
.
CHECK2
)
{
if
(
this
==
getDatabase
().
getLobSession
()
&&
!
Thread
.
holdsLock
(
this
)
&&
!
Thread
.
holdsLock
(
getDatabase
()))
{
throw
DbException
.
throwInternalError
();
}
}
assert
this
!=
getDatabase
().
getLobSession
()
||
Thread
.
holdsLock
(
this
)
||
Thread
.
holdsLock
(
getDatabase
());
if
(
temporaryLobs
!=
null
)
{
for
(
Value
v
:
temporaryLobs
)
{
if
(!
v
.
isLinkedToTable
())
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/SysProperties.java
浏览文件 @
fb08a1fa
...
...
@@ -95,18 +95,11 @@ public class SysProperties {
/**
* System property <code>h2.check</code>
* (default: true for JDK/JRE, false for Android).<br />
*
Assertion
s in the database engine.
*
Optional additional check
s in the database engine.
*/
public
static
final
boolean
CHECK
=
Utils
.
getProperty
(
"h2.check"
,
!
"0.9"
.
equals
(
Utils
.
getProperty
(
"java.specification.version"
,
null
)));
/**
* System property <code>h2.check2</code> (default: false).<br />
* Additional assertions in the database engine.
*/
public
static
final
boolean
CHECK2
=
Utils
.
getProperty
(
"h2.check2"
,
false
);
/**
* System property <code>h2.clientTraceDirectory</code> (default:
* trace.db/).<br />
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/PageDataLeaf.java
浏览文件 @
fb08a1fa
...
...
@@ -491,11 +491,7 @@ public class PageDataLeaf extends PageData {
}
data
.
writeByte
((
byte
)
type
);
data
.
writeShortInt
(
0
);
if
(
SysProperties
.
CHECK2
)
{
if
(
data
.
length
()
!=
START_PARENT
)
{
DbException
.
throwInternalError
();
}
}
assert
data
.
length
()
==
START_PARENT
;
data
.
writeInt
(
parentPageId
);
data
.
writeVarInt
(
index
.
getId
());
data
.
writeVarInt
(
columnCount
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/PageDataNode.java
浏览文件 @
fb08a1fa
...
...
@@ -351,11 +351,7 @@ public class PageDataNode extends PageData {
data
.
reset
();
data
.
writeByte
((
byte
)
Page
.
TYPE_DATA_NODE
);
data
.
writeShortInt
(
0
);
if
(
SysProperties
.
CHECK2
)
{
if
(
data
.
length
()
!=
START_PARENT
)
{
DbException
.
throwInternalError
();
}
}
assert
data
.
length
()
==
START_PARENT
;
data
.
writeInt
(
parentPageId
);
data
.
writeVarInt
(
index
.
getId
());
data
.
writeInt
(
rowCountStored
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/Data.java
浏览文件 @
fb08a1fa
...
...
@@ -705,13 +705,8 @@ public class Data {
}
DbException
.
throwInternalError
(
"type="
+
v
.
getType
());
}
if
(
SysProperties
.
CHECK2
)
{
if
(
pos
-
start
!=
getValueLen
(
v
,
handler
))
{
throw
DbException
.
throwInternalError
(
"value size error: got "
+
(
pos
-
start
)
+
" expected "
+
getValueLen
(
v
,
handler
));
}
}
assert
pos
-
start
==
getValueLen
(
v
,
handler
)
:
"value size error: got "
+
(
pos
-
start
)
+
" expected "
+
getValueLen
(
v
,
handler
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/FileStore.java
浏览文件 @
fb08a1fa
...
...
@@ -36,6 +36,15 @@ public class FileStore {
private
static
final
String
HEADER
=
"-- H2 0.5/B -- "
.
substring
(
0
,
Constants
.
FILE_BLOCK_SIZE
-
1
)
+
"\n"
;
private
static
final
boolean
ASSERT
;
static
{
boolean
a
=
false
;
// Intentional side-effect
assert
a
=
true
;
ASSERT
=
a
;
}
/**
* The file name.
*/
...
...
@@ -371,14 +380,13 @@ public class FileStore {
public
long
length
()
{
try
{
long
len
=
fileLength
;
if
(
SysProperties
.
CHECK2
)
{
if
(
ASSERT
)
{
len
=
file
.
size
();
if
(
len
!=
fileLength
)
{
DbException
.
throwInternalError
(
"file "
+
name
+
" length "
+
len
+
" expected "
+
fileLength
);
}
}
if
(
SysProperties
.
CHECK2
&&
len
%
Constants
.
FILE_BLOCK_SIZE
!=
0
)
{
if
(
len
%
Constants
.
FILE_BLOCK_SIZE
!=
0
)
{
long
newLength
=
len
+
Constants
.
FILE_BLOCK_SIZE
-
(
len
%
Constants
.
FILE_BLOCK_SIZE
);
file
.
truncate
(
newLength
);
...
...
@@ -386,6 +394,7 @@ public class FileStore {
DbException
.
throwInternalError
(
"unaligned file length "
+
name
+
" len "
+
len
);
}
}
return
len
;
}
catch
(
IOException
e
)
{
throw
DbException
.
convertIOException
(
e
,
name
);
...
...
@@ -398,7 +407,7 @@ public class FileStore {
* @return the location
*/
public
long
getFilePointer
()
{
if
(
SysProperties
.
CHECK2
)
{
if
(
ASSERT
)
{
try
{
if
(
file
.
position
()
!=
filePos
)
{
DbException
.
throwInternalError
(
file
.
position
()
+
" "
+
filePos
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/LobStorageBackend.java
浏览文件 @
fb08a1fa
...
...
@@ -249,11 +249,7 @@ public class LobStorageBackend implements LobStorageInterface {
* @return the prepared statement
*/
PreparedStatement
prepare
(
String
sql
)
throws
SQLException
{
if
(
SysProperties
.
CHECK2
)
{
if
(!
Thread
.
holdsLock
(
database
))
{
throw
DbException
.
throwInternalError
();
}
}
assert
Thread
.
holdsLock
(
database
);
PreparedStatement
prep
=
prepared
.
remove
(
sql
);
if
(
prep
==
null
)
{
prep
=
conn
.
prepareStatement
(
sql
);
...
...
@@ -268,11 +264,7 @@ public class LobStorageBackend implements LobStorageInterface {
* @param prep the prepared statement
*/
void
reuse
(
String
sql
,
PreparedStatement
prep
)
{
if
(
SysProperties
.
CHECK2
)
{
if
(!
Thread
.
holdsLock
(
database
))
{
throw
DbException
.
throwInternalError
();
}
}
assert
Thread
.
holdsLock
(
database
);
prepared
.
put
(
sql
,
prep
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
fb08a1fa
...
...
@@ -465,7 +465,6 @@ java org.h2.test.TestAll timer
System
.
setProperty
(
"h2.maxMemoryRows"
,
"100"
);
System
.
setProperty
(
"h2.check2"
,
"true"
);
System
.
setProperty
(
"h2.delayWrongPasswordMin"
,
"0"
);
System
.
setProperty
(
"h2.delayWrongPasswordMax"
,
"0"
);
System
.
setProperty
(
"h2.useThreadContextClassLoader"
,
"true"
);
...
...
@@ -513,7 +512,6 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
test
.
testAll
();
}
else
if
(
"reopen"
.
equals
(
args
[
0
]))
{
System
.
setProperty
(
"h2.delayWrongPasswordMin"
,
"0"
);
System
.
setProperty
(
"h2.check2"
,
"false"
);
System
.
setProperty
(
"h2.analyzeAuto"
,
"100"
);
System
.
setProperty
(
"h2.pageSize"
,
"64"
);
System
.
setProperty
(
"h2.reopenShift"
,
"5"
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/todo/TestTempTableCrash.java
浏览文件 @
fb08a1fa
...
...
@@ -34,7 +34,6 @@ public class TestTempTableCrash {
Statement
stat
;
System
.
setProperty
(
"h2.delayWrongPasswordMin"
,
"0"
);
System
.
setProperty
(
"h2.check2"
,
"false"
);
FilePathRec
.
register
();
System
.
setProperty
(
"reopenShift"
,
"4"
);
TestReopen
reopen
=
new
TestReopen
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/unit/TestPageStore.java
浏览文件 @
fb08a1fa
...
...
@@ -45,7 +45,6 @@ public class TestPageStore extends TestBase {
* @param a ignored
*/
public
static
void
main
(
String
...
a
)
throws
Exception
{
System
.
setProperty
(
"h2.check2"
,
"true"
);
TestBase
.
createCaller
().
init
().
test
();
}
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论