Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
74d34875
提交
74d34875
authored
10月 07, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Page store: more internal checks
上级
00a4016d
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
39 行增加
和
42 行删除
+39
-42
PageData.java
h2/src/main/org/h2/index/PageData.java
+5
-2
PageDataIndex.java
h2/src/main/org/h2/index/PageDataIndex.java
+10
-14
PageDataLeaf.java
h2/src/main/org/h2/index/PageDataLeaf.java
+2
-3
PageDataNode.java
h2/src/main/org/h2/index/PageDataNode.java
+3
-3
Recover.java
h2/src/main/org/h2/tools/Recover.java
+17
-20
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+2
-0
没有找到文件。
h2/src/main/org/h2/index/PageData.java
浏览文件 @
74d34875
...
@@ -148,9 +148,10 @@ abstract class PageData extends Page {
...
@@ -148,9 +148,10 @@ abstract class PageData extends Page {
* @param id the new page id
* @param id the new page id
*/
*/
void
setPageId
(
int
id
)
throws
SQLException
{
void
setPageId
(
int
id
)
throws
SQLException
{
int
old
=
getPos
();
index
.
getPageStore
().
removeRecord
(
getPos
());
index
.
getPageStore
().
removeRecord
(
getPos
());
setPos
(
id
);
setPos
(
id
);
remapChildren
();
remapChildren
(
old
);
}
}
/**
/**
...
@@ -182,8 +183,10 @@ abstract class PageData extends Page {
...
@@ -182,8 +183,10 @@ abstract class PageData extends Page {
/**
/**
* Update the parent id of all children.
* Update the parent id of all children.
*
* @param old the previous position
*/
*/
abstract
void
remapChildren
()
throws
SQLException
;
abstract
void
remapChildren
(
int
old
)
throws
SQLException
;
/**
/**
* Remove a row.
* Remove a row.
...
...
h2/src/main/org/h2/index/PageDataIndex.java
浏览文件 @
74d34875
...
@@ -49,6 +49,7 @@ public class PageDataIndex extends PageIndex implements RowIndex {
...
@@ -49,6 +49,7 @@ public class PageDataIndex extends PageIndex implements RowIndex {
public
PageDataIndex
(
TableData
table
,
int
id
,
IndexColumn
[]
columns
,
IndexType
indexType
,
int
headPos
,
Session
session
)
throws
SQLException
{
public
PageDataIndex
(
TableData
table
,
int
id
,
IndexColumn
[]
columns
,
IndexType
indexType
,
int
headPos
,
Session
session
)
throws
SQLException
{
initBaseIndex
(
table
,
id
,
table
.
getName
()
+
"_TABLE_SCAN"
,
columns
,
indexType
);
initBaseIndex
(
table
,
id
,
table
.
getName
()
+
"_TABLE_SCAN"
,
columns
,
indexType
);
// trace = database.getTrace(Trace.PAGE_STORE + "_di");
// trace.setLevel(TraceSystem.DEBUG);
// trace.setLevel(TraceSystem.DEBUG);
if
(
database
.
isMultiVersion
())
{
if
(
database
.
isMultiVersion
())
{
sessionRowCount
=
New
.
hashMap
();
sessionRowCount
=
New
.
hashMap
();
...
@@ -73,7 +74,7 @@ public class PageDataIndex extends PageIndex implements RowIndex {
...
@@ -73,7 +74,7 @@ public class PageDataIndex extends PageIndex implements RowIndex {
rowCount
=
root
.
getRowCount
();
rowCount
=
root
.
getRowCount
();
}
}
if
(
trace
.
isDebugEnabled
())
{
if
(
trace
.
isDebugEnabled
())
{
trace
.
debug
(
"opened "
+
getName
()
+
"
rows:"
+
rowCount
);
trace
.
debug
(
this
+
" opened
rows:"
+
rowCount
);
}
}
table
.
setRowCount
(
rowCount
);
table
.
setRowCount
(
rowCount
);
fastDuplicateKeyException
=
super
.
getDuplicateKeyException
();
fastDuplicateKeyException
=
super
.
getDuplicateKeyException
();
...
@@ -99,9 +100,6 @@ public class PageDataIndex extends PageIndex implements RowIndex {
...
@@ -99,9 +100,6 @@ public class PageDataIndex extends PageIndex implements RowIndex {
retry
=
true
;
retry
=
true
;
}
}
}
}
if
(
trace
.
isDebugEnabled
())
{
trace
.
debug
(
"add table:"
+
table
.
getId
()
+
" "
+
row
);
}
if
(
tableData
.
getContainsLargeObject
())
{
if
(
tableData
.
getContainsLargeObject
())
{
for
(
int
i
=
0
;
i
<
row
.
getColumnCount
();
i
++)
{
for
(
int
i
=
0
;
i
<
row
.
getColumnCount
();
i
++)
{
Value
v
=
row
.
getValue
(
i
);
Value
v
=
row
.
getValue
(
i
);
...
@@ -149,7 +147,7 @@ public class PageDataIndex extends PageIndex implements RowIndex {
...
@@ -149,7 +147,7 @@ public class PageDataIndex extends PageIndex implements RowIndex {
break
;
break
;
}
}
if
(
trace
.
isDebugEnabled
())
{
if
(
trace
.
isDebugEnabled
())
{
trace
.
debug
(
"split "
+
splitPoint
);
trace
.
debug
(
this
+
" split"
);
}
}
long
pivot
=
splitPoint
==
0
?
row
.
getKey
()
:
root
.
getKey
(
splitPoint
-
1
);
long
pivot
=
splitPoint
==
0
?
row
.
getKey
()
:
root
.
getKey
(
splitPoint
-
1
);
PageData
page1
=
root
;
PageData
page1
=
root
;
...
@@ -208,9 +206,6 @@ public class PageDataIndex extends PageIndex implements RowIndex {
...
@@ -208,9 +206,6 @@ public class PageDataIndex extends PageIndex implements RowIndex {
store
.
update
(
empty
);
store
.
update
(
empty
);
return
empty
;
return
empty
;
}
}
if
(
p
.
index
.
rootPageId
!=
rootPageId
)
{
throw
Message
.
throwInternalError
(
"Wrong index: "
+
p
.
index
.
getName
()
+
":"
+
p
.
index
.
rootPageId
+
" "
+
getName
()
+
":"
+
rootPageId
);
}
if
(
parent
!=
-
1
)
{
if
(
parent
!=
-
1
)
{
if
(
p
.
getParentPageId
()
!=
parent
)
{
if
(
p
.
getParentPageId
()
!=
parent
)
{
throw
Message
.
throwInternalError
(
p
+
" parent "
+
p
.
getParentPageId
()
+
" expected "
+
parent
);
throw
Message
.
throwInternalError
(
p
+
" parent "
+
p
.
getParentPageId
()
+
" expected "
+
parent
);
...
@@ -280,9 +275,6 @@ public class PageDataIndex extends PageIndex implements RowIndex {
...
@@ -280,9 +275,6 @@ public class PageDataIndex extends PageIndex implements RowIndex {
}
}
public
void
remove
(
Session
session
,
Row
row
)
throws
SQLException
{
public
void
remove
(
Session
session
,
Row
row
)
throws
SQLException
{
if
(
trace
.
isDebugEnabled
())
{
trace
.
debug
(
"remove "
+
row
.
getKey
());
}
if
(
tableData
.
getContainsLargeObject
())
{
if
(
tableData
.
getContainsLargeObject
())
{
for
(
int
i
=
0
;
i
<
row
.
getColumnCount
();
i
++)
{
for
(
int
i
=
0
;
i
<
row
.
getColumnCount
();
i
++)
{
Value
v
=
row
.
getValue
(
i
);
Value
v
=
row
.
getValue
(
i
);
...
@@ -322,7 +314,7 @@ public class PageDataIndex extends PageIndex implements RowIndex {
...
@@ -322,7 +314,7 @@ public class PageDataIndex extends PageIndex implements RowIndex {
public
void
remove
(
Session
session
)
throws
SQLException
{
public
void
remove
(
Session
session
)
throws
SQLException
{
if
(
trace
.
isDebugEnabled
())
{
if
(
trace
.
isDebugEnabled
())
{
trace
.
debug
(
"
remove"
);
trace
.
debug
(
this
+
"
remove"
);
}
}
removeAllRows
();
removeAllRows
();
store
.
free
(
rootPageId
,
true
);
store
.
free
(
rootPageId
,
true
);
...
@@ -331,7 +323,7 @@ public class PageDataIndex extends PageIndex implements RowIndex {
...
@@ -331,7 +323,7 @@ public class PageDataIndex extends PageIndex implements RowIndex {
public
void
truncate
(
Session
session
)
throws
SQLException
{
public
void
truncate
(
Session
session
)
throws
SQLException
{
if
(
trace
.
isDebugEnabled
())
{
if
(
trace
.
isDebugEnabled
())
{
trace
.
debug
(
"
truncate"
);
trace
.
debug
(
this
+
"
truncate"
);
}
}
store
.
logTruncate
(
session
,
tableData
.
getId
());
store
.
logTruncate
(
session
,
tableData
.
getId
());
removeAllRows
();
removeAllRows
();
...
@@ -421,7 +413,7 @@ public class PageDataIndex extends PageIndex implements RowIndex {
...
@@ -421,7 +413,7 @@ public class PageDataIndex extends PageIndex implements RowIndex {
public
void
close
(
Session
session
)
throws
SQLException
{
public
void
close
(
Session
session
)
throws
SQLException
{
if
(
trace
.
isDebugEnabled
())
{
if
(
trace
.
isDebugEnabled
())
{
trace
.
debug
(
"
close"
);
trace
.
debug
(
this
+
"
close"
);
}
}
if
(
delta
!=
null
)
{
if
(
delta
!=
null
)
{
delta
.
clear
();
delta
.
clear
();
...
@@ -488,4 +480,8 @@ public class PageDataIndex extends PageIndex implements RowIndex {
...
@@ -488,4 +480,8 @@ public class PageDataIndex extends PageIndex implements RowIndex {
return
memorySizePerPage
;
return
memorySizePerPage
;
}
}
public
String
toString
()
{
return
getName
();
}
}
}
h2/src/main/org/h2/index/PageDataLeaf.java
浏览文件 @
74d34875
...
@@ -368,7 +368,7 @@ public class PageDataLeaf extends PageData {
...
@@ -368,7 +368,7 @@ public class PageDataLeaf extends PageData {
return
this
;
return
this
;
}
}
protected
void
remapChildren
()
throws
SQLException
{
protected
void
remapChildren
(
int
old
)
throws
SQLException
{
if
(
firstOverflowPageId
==
0
)
{
if
(
firstOverflowPageId
==
0
)
{
return
;
return
;
}
}
...
@@ -503,9 +503,8 @@ public class PageDataLeaf extends PageData {
...
@@ -503,9 +503,8 @@ public class PageDataLeaf extends PageData {
}
}
p2
.
entryCount
=
entryCount
;
p2
.
entryCount
=
entryCount
;
p2
.
offsets
=
offsets
;
p2
.
offsets
=
offsets
;
p2
.
parentPageId
=
parentPageId
;
p2
.
start
=
start
;
p2
.
start
=
start
;
p2
.
remapChildren
();
p2
.
remapChildren
(
getPos
()
);
p2
.
write
();
p2
.
write
();
p2
.
data
.
truncate
(
index
.
getPageStore
().
getPageSize
());
p2
.
data
.
truncate
(
index
.
getPageStore
().
getPageSize
());
store
.
update
(
p2
);
store
.
update
(
p2
);
...
...
h2/src/main/org/h2/index/PageDataNode.java
浏览文件 @
74d34875
...
@@ -190,13 +190,13 @@ public class PageDataNode extends PageData {
...
@@ -190,13 +190,13 @@ public class PageDataNode extends PageData {
removeChild
(
splitPoint
-
1
);
removeChild
(
splitPoint
-
1
);
childPageIds
[
splitPoint
-
1
]
=
lastChild
;
childPageIds
[
splitPoint
-
1
]
=
lastChild
;
p2
.
childPageIds
[
0
]
=
firstChild
;
p2
.
childPageIds
[
0
]
=
firstChild
;
p2
.
remapChildren
();
p2
.
remapChildren
(
getPos
()
);
return
p2
;
return
p2
;
}
}
protected
void
remapChildren
()
throws
SQLException
{
protected
void
remapChildren
(
int
old
)
throws
SQLException
{
for
(
int
child
:
childPageIds
)
{
for
(
int
child
:
childPageIds
)
{
PageData
p
=
index
.
getPage
(
child
,
-
1
);
PageData
p
=
index
.
getPage
(
child
,
old
);
p
.
setParentPageId
(
getPos
());
p
.
setParentPageId
(
getPos
());
index
.
getPageStore
().
update
(
p
);
index
.
getPageStore
().
update
(
p
);
}
}
...
...
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
74d34875
...
@@ -873,7 +873,7 @@ public class Recover extends Tool implements DataHandler {
...
@@ -873,7 +873,7 @@ public class Recover extends Tool implements DataHandler {
boolean
last
=
(
type
&
Page
.
FLAG_LAST
)
!=
0
;
boolean
last
=
(
type
&
Page
.
FLAG_LAST
)
!=
0
;
type
&=
~
Page
.
FLAG_LAST
;
type
&=
~
Page
.
FLAG_LAST
;
if
(!
PageStore
.
checksumTest
(
s
.
getBytes
(),
page
,
pageSize
))
{
if
(!
PageStore
.
checksumTest
(
s
.
getBytes
(),
page
,
pageSize
))
{
writer
.
println
(
"-- ERROR: page "
+
page
+
" checksum mismatch
"
);
writer
.
println
(
"-- ERROR: page "
+
page
+
" checksum mismatch
type: "
+
type
);
}
}
s
.
readShortInt
();
s
.
readShortInt
();
switch
(
type
)
{
switch
(
type
)
{
...
@@ -1166,12 +1166,12 @@ public class Recover extends Tool implements DataHandler {
...
@@ -1166,12 +1166,12 @@ public class Recover extends Tool implements DataHandler {
store
.
seek
((
long
)
nextPage
*
pageSize
);
store
.
seek
((
long
)
nextPage
*
pageSize
);
store
.
readFully
(
page
.
getBytes
(),
0
,
pageSize
);
store
.
readFully
(
page
.
getBytes
(),
0
,
pageSize
);
page
.
reset
();
page
.
reset
();
if
(!
PageStore
.
checksumTest
(
page
.
getBytes
(),
nextPage
,
pageSize
))
{
int
t
=
page
.
readByte
();
if
(
t
!=
0
&&
!
PageStore
.
checksumTest
(
page
.
getBytes
(),
nextPage
,
pageSize
))
{
writer
.
println
(
"-- ERROR: checksum mismatch page: "
+
nextPage
);
writer
.
println
(
"-- ERROR: checksum mismatch page: "
+
nextPage
);
endOfFile
=
true
;
endOfFile
=
true
;
return
;
return
;
}
}
int
t
=
page
.
readByte
();
page
.
readShortInt
();
page
.
readShortInt
();
int
p
=
page
.
readInt
();
int
p
=
page
.
readInt
();
int
k
=
page
.
readInt
();
int
k
=
page
.
readInt
();
...
@@ -1199,14 +1199,12 @@ public class Recover extends Tool implements DataHandler {
...
@@ -1199,14 +1199,12 @@ public class Recover extends Tool implements DataHandler {
int
entryCount
=
s
.
readShortInt
();
int
entryCount
=
s
.
readShortInt
();
int
[]
children
=
new
int
[
entryCount
+
1
];
int
[]
children
=
new
int
[
entryCount
+
1
];
int
[]
offsets
=
new
int
[
entryCount
];
int
[]
offsets
=
new
int
[
entryCount
];
int
rightmost
=
s
.
readInt
();
children
[
entryCount
]
=
s
.
readInt
();
checkParent
(
writer
,
pageId
,
rightmost
);
checkParent
(
writer
,
pageId
,
children
,
entryCount
);
children
[
entryCount
]
=
rightmost
;
int
empty
=
Integer
.
MAX_VALUE
;
int
empty
=
Integer
.
MAX_VALUE
;
for
(
int
i
=
0
;
i
<
entryCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
entryCount
;
i
++)
{
int
child
=
s
.
readInt
();
children
[
i
]
=
s
.
readInt
();
checkParent
(
writer
,
pageId
,
child
);
checkParent
(
writer
,
pageId
,
children
,
i
);
children
[
i
]
=
child
;
int
off
=
s
.
readShortInt
();
int
off
=
s
.
readShortInt
();
empty
=
Math
.
min
(
off
,
empty
);
empty
=
Math
.
min
(
off
,
empty
);
offsets
[
i
]
=
off
;
offsets
[
i
]
=
off
;
...
@@ -1292,24 +1290,23 @@ public class Recover extends Tool implements DataHandler {
...
@@ -1292,24 +1290,23 @@ public class Recover extends Tool implements DataHandler {
}
}
}
}
private
void
checkParent
(
PrintWriter
writer
,
long
pageId
,
long
child
)
{
private
void
checkParent
(
PrintWriter
writer
,
long
pageId
,
int
[]
children
,
int
index
)
{
int
child
=
children
[
index
];
if
(
child
<
0
||
child
>=
parents
.
length
)
{
if
(
child
<
0
||
child
>=
parents
.
length
)
{
writer
.
println
(
"-- ERROR ["
+
pageId
+
"] child
: "
+
child
+
"
page count: "
+
parents
.
length
);
writer
.
println
(
"-- ERROR ["
+
pageId
+
"] child
["
+
index
+
"]: "
+
child
+
" >=
page count: "
+
parents
.
length
);
}
else
if
(
parents
[
(
int
)
child
]
!=
pageId
)
{
}
else
if
(
parents
[
child
]
!=
pageId
)
{
writer
.
println
(
"-- ERROR ["
+
pageId
+
"]
expected child: "
+
child
+
" got: "
+
parents
[(
int
)
child
]);
writer
.
println
(
"-- ERROR ["
+
pageId
+
"]
child["
+
index
+
"]: "
+
child
+
" parent: "
+
parents
[
child
]);
}
}
}
}
private
void
dumpPageDataNode
(
PrintWriter
writer
,
Data
s
,
long
pageId
,
int
entryCount
)
{
private
void
dumpPageDataNode
(
PrintWriter
writer
,
Data
s
,
long
pageId
,
int
entryCount
)
{
int
[]
children
=
new
int
[
entryCount
+
1
];
int
[]
children
=
new
int
[
entryCount
+
1
];
long
[]
keys
=
new
long
[
entryCount
];
long
[]
keys
=
new
long
[
entryCount
];
int
child
=
s
.
readInt
();
children
[
entryCount
]
=
s
.
readInt
();
children
[
entryCount
]
=
child
;
checkParent
(
writer
,
pageId
,
children
,
entryCount
);
checkParent
(
writer
,
pageId
,
child
);
for
(
int
i
=
0
;
i
<
entryCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
entryCount
;
i
++)
{
child
=
s
.
readInt
();
children
[
i
]
=
s
.
readInt
();
children
[
i
]
=
child
;
checkParent
(
writer
,
pageId
,
children
,
i
);
checkParent
(
writer
,
pageId
,
child
);
keys
[
i
]
=
s
.
readVarLong
();
keys
[
i
]
=
s
.
readVarLong
();
}
}
if
(!
trace
)
{
if
(!
trace
)
{
...
@@ -1347,7 +1344,7 @@ public class Recover extends Tool implements DataHandler {
...
@@ -1347,7 +1344,7 @@ public class Recover extends Tool implements DataHandler {
s
.
setPos
(
pageSize
);
s
.
setPos
(
pageSize
);
long
parent
=
pageId
;
long
parent
=
pageId
;
while
(
true
)
{
while
(
true
)
{
checkParent
(
writer
,
parent
,
ne
xt
);
checkParent
(
writer
,
parent
,
ne
w
int
[]{(
int
)
next
},
0
);
parent
=
next
;
parent
=
next
;
store
.
seek
(
pageSize
*
next
);
store
.
seek
(
pageSize
*
next
);
store
.
readFully
(
s2
.
getBytes
(),
0
,
pageSize
);
store
.
readFully
(
s2
.
getBytes
(),
0
,
pageSize
);
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
74d34875
...
@@ -297,6 +297,8 @@ java org.h2.test.TestAll timer
...
@@ -297,6 +297,8 @@ java org.h2.test.TestAll timer
/*
/*
check freelist undo recursion
mvcc merge problem
mvcc merge problem
System.setProperty("h2.optimizeInList", "true");
System.setProperty("h2.optimizeInList", "true");
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论