Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
caa572bf
提交
caa572bf
authored
6 年前
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Replace remaining usages of SysProperties.CHECK2 with check for assertions
上级
20be82db
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
32 行增加
和
14 行删除
+32
-14
Database.java
h2/src/main/org/h2/engine/Database.java
+13
-4
FileStore.java
h2/src/main/org/h2/store/FileStore.java
+19
-10
没有找到文件。
h2/src/main/org/h2/engine/Database.java
浏览文件 @
caa572bf
...
@@ -91,6 +91,15 @@ public class Database implements DataHandler {
...
@@ -91,6 +91,15 @@ public class Database implements DataHandler {
private
static
int
initialPowerOffCount
;
private
static
int
initialPowerOffCount
;
private
static
final
boolean
ASSERT
;
static
{
boolean
a
=
false
;
// Intentional side-effect
assert
a
=
true
;
ASSERT
=
a
;
}
private
static
final
ThreadLocal
<
Session
>
META_LOCK_DEBUGGING
=
new
ThreadLocal
<>();
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
<
Database
>
META_LOCK_DEBUGGING_DB
=
new
ThreadLocal
<>();
private
static
final
ThreadLocal
<
Throwable
>
META_LOCK_DEBUGGING_STACK
=
new
ThreadLocal
<>();
private
static
final
ThreadLocal
<
Throwable
>
META_LOCK_DEBUGGING_STACK
=
new
ThreadLocal
<>();
...
@@ -919,7 +928,7 @@ public class Database implements DataHandler {
...
@@ -919,7 +928,7 @@ public class Database implements DataHandler {
if
(
meta
==
null
)
{
if
(
meta
==
null
)
{
return
true
;
return
true
;
}
}
if
(
SysProperties
.
CHECK2
)
{
if
(
ASSERT
)
{
// If we are locking two different databases in the same stack, just ignore it.
// 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
// This only happens in TestLinkedTable where we connect to another h2 DB in the
// same process.
// same process.
...
@@ -961,7 +970,7 @@ public class Database implements DataHandler {
...
@@ -961,7 +970,7 @@ public class Database implements DataHandler {
* @param session the session
* @param session the session
*/
*/
public
void
unlockMetaDebug
(
Session
session
)
{
public
void
unlockMetaDebug
(
Session
session
)
{
if
(
SysProperties
.
CHECK2
)
{
if
(
ASSERT
)
{
if
(
META_LOCK_DEBUGGING
.
get
()
==
session
)
{
if
(
META_LOCK_DEBUGGING
.
get
()
==
session
)
{
META_LOCK_DEBUGGING
.
set
(
null
);
META_LOCK_DEBUGGING
.
set
(
null
);
META_LOCK_DEBUGGING_DB
.
set
(
null
);
META_LOCK_DEBUGGING_DB
.
set
(
null
);
...
@@ -1405,7 +1414,7 @@ public class Database implements DataHandler {
...
@@ -1405,7 +1414,7 @@ public class Database implements DataHandler {
unlockMeta
(
pageStore
.
getPageStoreSession
());
unlockMeta
(
pageStore
.
getPageStoreSession
());
}
}
}
catch
(
DbException
e
)
{
}
catch
(
DbException
e
)
{
if
(
SysProperties
.
CHECK2
)
{
if
(
ASSERT
)
{
int
code
=
e
.
getErrorCode
();
int
code
=
e
.
getErrorCode
();
if
(
code
!=
ErrorCode
.
DATABASE_IS_CLOSED
&&
if
(
code
!=
ErrorCode
.
DATABASE_IS_CLOSED
&&
code
!=
ErrorCode
.
LOCK_TIMEOUT_1
&&
code
!=
ErrorCode
.
LOCK_TIMEOUT_1
&&
...
@@ -1415,7 +1424,7 @@ public class Database implements DataHandler {
...
@@ -1415,7 +1424,7 @@ public class Database implements DataHandler {
}
}
trace
.
error
(
e
,
"close"
);
trace
.
error
(
e
,
"close"
);
}
catch
(
Throwable
t
)
{
}
catch
(
Throwable
t
)
{
if
(
SysProperties
.
CHECK2
)
{
if
(
ASSERT
)
{
t
.
printStackTrace
();
t
.
printStackTrace
();
}
}
trace
.
error
(
t
,
"close"
);
trace
.
error
(
t
,
"close"
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/FileStore.java
浏览文件 @
caa572bf
...
@@ -36,6 +36,15 @@ public class FileStore {
...
@@ -36,6 +36,15 @@ public class FileStore {
private
static
final
String
HEADER
=
private
static
final
String
HEADER
=
"-- H2 0.5/B -- "
.
substring
(
0
,
Constants
.
FILE_BLOCK_SIZE
-
1
)
+
"\n"
;
"-- 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.
* The file name.
*/
*/
...
@@ -371,14 +380,13 @@ public class FileStore {
...
@@ -371,14 +380,13 @@ public class FileStore {
public
long
length
()
{
public
long
length
()
{
try
{
try
{
long
len
=
fileLength
;
long
len
=
fileLength
;
if
(
SysProperties
.
CHECK2
)
{
if
(
ASSERT
)
{
len
=
file
.
size
();
len
=
file
.
size
();
if
(
len
!=
fileLength
)
{
if
(
len
!=
fileLength
)
{
DbException
.
throwInternalError
(
DbException
.
throwInternalError
(
"file "
+
name
+
" length "
+
len
+
" expected "
+
fileLength
);
"file "
+
name
+
" length "
+
len
+
" expected "
+
fileLength
);
}
}
}
if
(
len
%
Constants
.
FILE_BLOCK_SIZE
!=
0
)
{
if
(
SysProperties
.
CHECK2
&&
len
%
Constants
.
FILE_BLOCK_SIZE
!=
0
)
{
long
newLength
=
len
+
Constants
.
FILE_BLOCK_SIZE
-
long
newLength
=
len
+
Constants
.
FILE_BLOCK_SIZE
-
(
len
%
Constants
.
FILE_BLOCK_SIZE
);
(
len
%
Constants
.
FILE_BLOCK_SIZE
);
file
.
truncate
(
newLength
);
file
.
truncate
(
newLength
);
...
@@ -386,6 +394,7 @@ public class FileStore {
...
@@ -386,6 +394,7 @@ public class FileStore {
DbException
.
throwInternalError
(
DbException
.
throwInternalError
(
"unaligned file length "
+
name
+
" len "
+
len
);
"unaligned file length "
+
name
+
" len "
+
len
);
}
}
}
return
len
;
return
len
;
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
DbException
.
convertIOException
(
e
,
name
);
throw
DbException
.
convertIOException
(
e
,
name
);
...
@@ -398,7 +407,7 @@ public class FileStore {
...
@@ -398,7 +407,7 @@ public class FileStore {
* @return the location
* @return the location
*/
*/
public
long
getFilePointer
()
{
public
long
getFilePointer
()
{
if
(
SysProperties
.
CHECK2
)
{
if
(
ASSERT
)
{
try
{
try
{
if
(
file
.
position
()
!=
filePos
)
{
if
(
file
.
position
()
!=
filePos
)
{
DbException
.
throwInternalError
(
file
.
position
()
+
" "
+
filePos
);
DbException
.
throwInternalError
(
file
.
position
()
+
" "
+
filePos
);
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论