Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
e91be706
提交
e91be706
authored
10月 01, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Page store bugfixes.
上级
fa1a87b4
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
84 行增加
和
85 行删除
+84
-85
PageBtreeIndex.java
h2/src/main/org/h2/index/PageBtreeIndex.java
+7
-7
PageBtreeLeaf.java
h2/src/main/org/h2/index/PageBtreeLeaf.java
+5
-5
PageBtreeNode.java
h2/src/main/org/h2/index/PageBtreeNode.java
+12
-12
PageDataIndex.java
h2/src/main/org/h2/index/PageDataIndex.java
+7
-7
PageDataLeaf.java
h2/src/main/org/h2/index/PageDataLeaf.java
+8
-8
PageDataNode.java
h2/src/main/org/h2/index/PageDataNode.java
+14
-13
PageDataOverflow.java
h2/src/main/org/h2/index/PageDataOverflow.java
+4
-4
PageFreeList.java
h2/src/main/org/h2/store/PageFreeList.java
+4
-4
PageLog.java
h2/src/main/org/h2/store/PageLog.java
+2
-2
PageStore.java
h2/src/main/org/h2/store/PageStore.java
+13
-20
PageStreamTrunk.java
h2/src/main/org/h2/store/PageStreamTrunk.java
+3
-3
WriterThread.java
h2/src/main/org/h2/store/WriterThread.java
+5
-0
没有找到文件。
h2/src/main/org/h2/index/PageBtreeIndex.java
浏览文件 @
e91be706
...
...
@@ -53,7 +53,7 @@ public class PageBtreeIndex extends PageIndex {
store
.
addMeta
(
this
,
session
);
PageBtreeLeaf
root
=
PageBtreeLeaf
.
create
(
this
,
rootPageId
,
PageBtree
.
ROOT
);
store
.
logUndo
(
root
,
null
);
store
.
update
Record
(
root
);
store
.
update
(
root
);
}
else
{
rootPageId
=
store
.
getRootPageId
(
id
);
PageBtree
root
=
getPage
(
rootPageId
);
...
...
@@ -95,9 +95,9 @@ public class PageBtreeIndex extends PageIndex {
PageBtreeNode
newRoot
=
PageBtreeNode
.
create
(
this
,
rootPageId
,
PageBtree
.
ROOT
);
store
.
logUndo
(
newRoot
,
null
);
newRoot
.
init
(
page1
,
pivot
,
page2
);
store
.
update
Record
(
page1
);
store
.
update
Record
(
page2
);
store
.
update
Record
(
newRoot
);
store
.
update
(
page1
);
store
.
update
(
page2
);
store
.
update
(
newRoot
);
root
=
newRoot
;
}
rowCount
++;
...
...
@@ -131,7 +131,7 @@ public class PageBtreeIndex extends PageIndex {
PageBtreeLeaf
empty
=
PageBtreeLeaf
.
create
(
this
,
id
,
PageBtree
.
ROOT
);
// could have been created before, but never committed
store
.
logUndo
(
empty
,
null
);
store
.
update
Record
(
empty
);
store
.
update
(
empty
);
return
empty
;
}
return
p
;
...
...
@@ -226,7 +226,7 @@ public class PageBtreeIndex extends PageIndex {
trace
.
debug
(
"remove"
);
}
removeAllRows
();
store
.
free
Page
(
rootPageId
,
false
,
null
);
store
.
free
(
rootPageId
,
true
);
store
.
removeMeta
(
this
,
session
);
}
...
...
@@ -247,7 +247,7 @@ public class PageBtreeIndex extends PageIndex {
root
.
freeChildren
();
root
=
PageBtreeLeaf
.
create
(
this
,
rootPageId
,
PageBtree
.
ROOT
);
store
.
removeRecord
(
rootPageId
);
store
.
update
Record
(
root
);
store
.
update
(
root
);
rowCount
=
0
;
}
...
...
h2/src/main/org/h2/index/PageBtreeLeaf.java
浏览文件 @
e91be706
...
...
@@ -147,7 +147,7 @@ public class PageBtreeLeaf extends PageBtree {
newRows
[
x
]
=
row
;
offsets
=
newOffsets
;
rows
=
newRows
;
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
return
-
1
;
}
...
...
@@ -202,13 +202,13 @@ public class PageBtreeLeaf extends PageBtree {
if
(
index
.
compareRows
(
row
,
delete
)
!=
0
||
delete
.
getKey
()
!=
row
.
getKey
())
{
throw
Message
.
getSQLException
(
ErrorCode
.
ROW_NOT_FOUND_WHEN_DELETING_1
,
index
.
getSQL
()
+
": "
+
row
);
}
index
.
getPageStore
().
logUndo
(
this
,
data
);
if
(
entryCount
==
1
)
{
// the page is now empty
return
row
;
}
index
.
getPageStore
().
logUndo
(
this
,
data
);
removeRow
(
at
);
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
if
(
at
==
entryCount
)
{
// the last row changed
return
getRow
(
at
-
1
);
...
...
@@ -327,14 +327,14 @@ public class PageBtreeLeaf extends PageBtree {
p2
.
onlyPosition
=
onlyPosition
;
p2
.
parentPageId
=
parentPageId
;
p2
.
start
=
start
;
store
.
update
Record
(
p2
);
store
.
update
(
p2
);
if
(
parentPageId
==
ROOT
)
{
index
.
setRootPageId
(
session
,
newPos
);
}
else
{
PageBtreeNode
p
=
(
PageBtreeNode
)
store
.
getPage
(
parentPageId
);
p
.
moveChild
(
getPos
(),
newPos
);
}
store
.
free
Page
(
getPos
(),
true
,
data
);
store
.
free
(
getPos
(),
true
);
}
}
h2/src/main/org/h2/index/PageBtreeNode.java
浏览文件 @
e91be706
...
...
@@ -203,9 +203,9 @@ public class PageBtreeNode extends PageBtree {
PageBtree
page2
=
page
.
split
(
splitPoint
);
readAllRows
();
addChild
(
x
,
page2
.
getPos
(),
pivot
);
index
.
getPageStore
().
update
Record
(
page
);
index
.
getPageStore
().
update
Record
(
page2
);
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
page
);
index
.
getPageStore
().
update
(
page2
);
index
.
getPageStore
().
update
(
this
);
}
updateRowCount
(
1
);
written
=
false
;
...
...
@@ -247,7 +247,7 @@ public class PageBtreeNode extends PageBtree {
for
(
int
child
:
childPageIds
)
{
PageBtree
p
=
index
.
getPage
(
child
);
p
.
setParentPageId
(
getPos
());
index
.
getPageStore
().
update
Record
(
p
);
index
.
getPageStore
().
update
(
p
);
}
}
...
...
@@ -311,7 +311,7 @@ public class PageBtreeNode extends PageBtree {
return
null
;
}
else
if
(
last
==
row
)
{
// this child is now empty
index
.
getPageStore
().
free
Page
(
page
.
getPos
(),
true
,
page
.
data
);
index
.
getPageStore
().
free
(
page
.
getPos
(),
true
);
if
(
entryCount
<
1
)
{
// no more children - this page is empty as well
return
row
;
...
...
@@ -323,7 +323,7 @@ public class PageBtreeNode extends PageBtree {
last
=
null
;
}
removeChild
(
at
);
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
return
last
;
}
// the last row is in the last child
...
...
@@ -339,7 +339,7 @@ public class PageBtreeNode extends PageBtree {
int
temp
=
childPageIds
[
at
];
childPageIds
[
at
]
=
childPageIds
[
at
+
1
];
childPageIds
[
at
+
1
]
=
temp
;
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
return
null
;
}
...
...
@@ -408,7 +408,7 @@ public class PageBtreeNode extends PageBtree {
for
(
int
i
=
0
;
i
<=
entryCount
;
i
++)
{
int
childPageId
=
childPageIds
[
i
];
PageBtree
child
=
index
.
getPage
(
childPageId
);
index
.
getPageStore
().
free
Page
(
childPageId
,
false
,
null
);
index
.
getPageStore
().
free
(
childPageId
,
false
);
child
.
freeChildren
();
}
}
...
...
@@ -516,7 +516,7 @@ public class PageBtreeNode extends PageBtree {
p2
.
onlyPosition
=
onlyPosition
;
p2
.
parentPageId
=
parentPageId
;
p2
.
start
=
start
;
store
.
update
Record
(
p2
);
store
.
update
(
p2
);
if
(
parentPageId
==
ROOT
)
{
index
.
setRootPageId
(
session
,
newPos
);
}
else
{
...
...
@@ -526,9 +526,9 @@ public class PageBtreeNode extends PageBtree {
for
(
int
i
=
0
;
i
<
childPageIds
.
length
;
i
++)
{
PageBtree
p
=
(
PageBtree
)
store
.
getPage
(
childPageIds
[
i
]);
p
.
setParentPageId
(
newPos
);
store
.
update
Record
(
p
);
store
.
update
(
p
);
}
store
.
free
Page
(
getPos
(),
true
,
data
);
store
.
free
(
getPos
(),
true
);
}
/**
...
...
@@ -543,7 +543,7 @@ public class PageBtreeNode extends PageBtree {
index
.
getPageStore
().
logUndo
(
this
,
data
);
written
=
false
;
childPageIds
[
i
]
=
newPos
;
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
return
;
}
}
...
...
h2/src/main/org/h2/index/PageDataIndex.java
浏览文件 @
e91be706
...
...
@@ -65,7 +65,7 @@ public class PageDataIndex extends PageIndex implements RowIndex {
rootPageId
=
store
.
allocatePage
();
store
.
addMeta
(
this
,
session
);
PageDataLeaf
root
=
PageDataLeaf
.
create
(
this
,
rootPageId
,
PageData
.
ROOT
);
store
.
update
Record
(
root
);
store
.
update
(
root
);
}
else
{
rootPageId
=
store
.
getRootPageId
(
id
);
PageData
root
=
getPage
(
rootPageId
,
0
);
...
...
@@ -161,9 +161,9 @@ public class PageDataIndex extends PageIndex implements RowIndex {
page2
.
setParentPageId
(
rootPageId
);
PageDataNode
newRoot
=
PageDataNode
.
create
(
this
,
rootPageId
,
PageData
.
ROOT
);
newRoot
.
init
(
page1
,
pivot
,
page2
);
store
.
update
Record
(
page1
);
store
.
update
Record
(
page2
);
store
.
update
Record
(
newRoot
);
store
.
update
(
page1
);
store
.
update
(
page2
);
store
.
update
(
newRoot
);
root
=
newRoot
;
}
row
.
setDeleted
(
false
);
...
...
@@ -205,7 +205,7 @@ public class PageDataIndex extends PageIndex implements RowIndex {
PageDataLeaf
empty
=
PageDataLeaf
.
create
(
this
,
id
,
parent
);
// could have been created before, but never committed
store
.
logUndo
(
empty
,
null
);
store
.
update
Record
(
empty
);
store
.
update
(
empty
);
return
empty
;
}
if
(
p
.
index
.
rootPageId
!=
rootPageId
)
{
...
...
@@ -325,7 +325,7 @@ public class PageDataIndex extends PageIndex implements RowIndex {
trace
.
debug
(
"remove"
);
}
removeAllRows
();
store
.
free
Page
(
rootPageId
,
false
,
null
);
store
.
free
(
rootPageId
,
true
);
store
.
removeMeta
(
this
,
session
);
}
...
...
@@ -349,7 +349,7 @@ public class PageDataIndex extends PageIndex implements RowIndex {
root
.
freeChildren
();
root
=
PageDataLeaf
.
create
(
this
,
rootPageId
,
PageData
.
ROOT
);
store
.
removeRecord
(
rootPageId
);
store
.
update
Record
(
root
);
store
.
update
(
root
);
rowCount
=
0
;
lastKey
=
0
;
}
...
...
h2/src/main/org/h2/index/PageDataLeaf.java
浏览文件 @
e91be706
...
...
@@ -198,7 +198,7 @@ public class PageDataLeaf extends PageData {
offsets
=
newOffsets
;
keys
=
newKeys
;
rows
=
newRows
;
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
if
(
offset
<
start
)
{
if
(
entryCount
>
1
)
{
Message
.
throwInternalError
();
...
...
@@ -234,7 +234,7 @@ public class PageDataLeaf extends PageData {
next
=
index
.
getPageStore
().
allocatePage
();
}
PageDataOverflow
overflow
=
PageDataOverflow
.
create
(
index
.
getPageStore
(),
page
,
type
,
previous
,
next
,
all
,
dataOffset
,
size
);
index
.
getPageStore
().
update
Record
(
overflow
);
index
.
getPageStore
().
update
(
overflow
);
dataOffset
+=
size
;
remaining
-=
size
;
previous
=
page
;
...
...
@@ -365,7 +365,7 @@ public class PageDataLeaf extends PageData {
}
PageDataOverflow
overflow
=
index
.
getPageOverflow
(
firstOverflowPageId
);
overflow
.
setParentPageId
(
getPos
());
index
.
getPageStore
().
update
Record
(
overflow
);
index
.
getPageStore
().
update
(
overflow
);
}
boolean
remove
(
long
key
)
throws
SQLException
{
...
...
@@ -379,7 +379,7 @@ public class PageDataLeaf extends PageData {
return
true
;
}
removeRow
(
i
);
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
return
false
;
}
...
...
@@ -389,7 +389,7 @@ public class PageDataLeaf extends PageData {
int
next
=
firstOverflowPageId
;
do
{
PageDataOverflow
page
=
index
.
getPageOverflow
(
next
);
store
.
free
Page
(
next
,
false
,
null
);
store
.
free
(
next
,
false
);
next
=
page
.
getNextOverflow
();
}
while
(
next
!=
0
);
}
...
...
@@ -499,8 +499,8 @@ public class PageDataLeaf extends PageData {
p2
.
remapChildren
();
p2
.
write
();
p2
.
data
.
truncate
(
index
.
getPageStore
().
getPageSize
());
store
.
update
Record
(
p2
);
store
.
free
Page
(
getPos
(),
true
,
data
);
store
.
update
(
p2
);
store
.
free
(
getPos
(),
true
);
if
(
parentPageId
==
ROOT
)
{
index
.
setRootPageId
(
session
,
newPos
);
}
else
{
...
...
@@ -516,7 +516,7 @@ public class PageDataLeaf extends PageData {
writeHead
();
data
.
writeInt
(
firstOverflowPageId
);
}
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
}
public
int
getMemorySize
()
{
...
...
h2/src/main/org/h2/index/PageDataNode.java
浏览文件 @
e91be706
...
...
@@ -149,10 +149,10 @@ public class PageDataNode extends PageData {
}
long
pivot
=
splitPoint
==
0
?
row
.
getKey
()
:
page
.
getKey
(
splitPoint
-
1
);
PageData
page2
=
page
.
split
(
splitPoint
);
index
.
getPageStore
().
update
Record
(
page
);
index
.
getPageStore
().
update
Record
(
page2
);
index
.
getPageStore
().
update
(
page
);
index
.
getPageStore
().
update
(
page2
);
addChild
(
x
,
page2
.
getPos
(),
pivot
);
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
}
updateRowCount
(
1
);
return
-
1
;
...
...
@@ -168,7 +168,7 @@ public class PageDataNode extends PageData {
if
(
written
)
{
writeHead
();
}
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
}
}
...
...
@@ -198,7 +198,7 @@ public class PageDataNode extends PageData {
for
(
int
child
:
childPageIds
)
{
PageData
p
=
index
.
getPage
(
child
,
-
1
);
p
.
setParentPageId
(
getPos
());
index
.
getPageStore
().
update
Record
(
p
);
index
.
getPageStore
().
update
(
p
);
}
}
...
...
@@ -251,19 +251,20 @@ public class PageDataNode extends PageData {
// TODO maybe implement merge
PageData
page
=
index
.
getPage
(
childPageIds
[
at
],
getPos
());
boolean
empty
=
page
.
remove
(
key
);
index
.
getPageStore
().
logUndo
(
this
,
data
);
updateRowCount
(-
1
);
if
(!
empty
)
{
// the first row didn't change - nothing to do
return
false
;
}
// this child is now empty
index
.
getPageStore
().
free
Page
(
page
.
getPos
(),
true
,
page
.
data
);
index
.
getPageStore
().
free
(
page
.
getPos
(),
true
);
if
(
entryCount
<
1
)
{
// no more children - this page is empty as well
return
true
;
}
removeChild
(
at
);
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
return
false
;
}
...
...
@@ -271,7 +272,7 @@ public class PageDataNode extends PageData {
for
(
int
i
=
0
;
i
<=
entryCount
;
i
++)
{
int
childPageId
=
childPageIds
[
i
];
PageData
child
=
index
.
getPage
(
childPageId
,
getPos
());
index
.
getPageStore
().
free
Page
(
childPageId
,
false
,
null
);
index
.
getPageStore
().
free
(
childPageId
,
false
);
child
.
freeChildren
();
}
}
...
...
@@ -305,7 +306,7 @@ public class PageDataNode extends PageData {
if
(
written
)
{
writeHead
();
}
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
}
}
...
...
@@ -393,7 +394,7 @@ public class PageDataNode extends PageData {
p2
.
keys
=
keys
;
p2
.
entryCount
=
entryCount
;
p2
.
length
=
length
;
store
.
update
Record
(
p2
);
store
.
update
(
p2
);
if
(
parentPageId
==
ROOT
)
{
index
.
setRootPageId
(
session
,
newPos
);
}
else
{
...
...
@@ -403,9 +404,9 @@ public class PageDataNode extends PageData {
for
(
int
i
=
0
;
i
<
childPageIds
.
length
;
i
++)
{
PageData
p
=
(
PageData
)
store
.
getPage
(
childPageIds
[
i
]);
p
.
setParentPageId
(
newPos
);
store
.
update
Record
(
p
);
store
.
update
(
p
);
}
store
.
free
Page
(
getPos
(),
true
,
data
);
store
.
free
(
getPos
(),
true
);
}
/**
...
...
@@ -420,7 +421,7 @@ public class PageDataNode extends PageData {
index
.
getPageStore
().
logUndo
(
this
,
data
);
written
=
false
;
childPageIds
[
i
]
=
newPos
;
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
return
;
}
}
...
...
h2/src/main/org/h2/index/PageDataOverflow.java
浏览文件 @
e91be706
...
...
@@ -216,11 +216,11 @@ public class PageDataOverflow extends Page {
public
void
moveTo
(
Session
session
,
int
newPos
)
throws
SQLException
{
store
.
logUndo
(
this
,
data
);
PageDataOverflow
p2
=
PageDataOverflow
.
create
(
store
,
newPos
,
type
,
parentPageId
,
nextPage
,
data
,
start
,
size
);
store
.
update
Record
(
p2
);
store
.
update
(
p2
);
if
(
nextPage
!=
0
)
{
PageDataOverflow
p3
=
(
PageDataOverflow
)
store
.
getPage
(
nextPage
);
p3
.
setParentPageId
(
newPos
);
store
.
update
Record
(
p3
);
store
.
update
(
p3
);
}
Page
p
=
store
.
getPage
(
parentPageId
);
if
(
p
==
null
)
{
...
...
@@ -233,8 +233,8 @@ public class PageDataOverflow extends Page {
PageDataLeaf
p1
=
(
PageDataLeaf
)
p
;
p1
.
setOverflow
(
newPos
);
}
store
.
update
Record
(
p
);
store
.
free
Page
(
getPos
(),
true
,
data
);
store
.
update
(
p
);
store
.
free
(
getPos
(),
true
);
}
private
void
setNext
(
int
nextPage
)
throws
SQLException
{
...
...
h2/src/main/org/h2/store/PageFreeList.java
浏览文件 @
e91be706
...
...
@@ -88,7 +88,7 @@ public class PageFreeList extends Page {
}
else
{
store
.
logUndo
(
this
,
data
);
used
.
set
(
free
);
store
.
update
Record
(
this
);
store
.
update
(
this
);
return
free
+
getPos
();
}
}
...
...
@@ -121,7 +121,7 @@ public class PageFreeList extends Page {
if
(
idx
>=
0
&&
!
used
.
get
(
idx
))
{
store
.
logUndo
(
this
,
data
);
used
.
set
(
idx
);
store
.
update
Record
(
this
);
store
.
update
(
this
);
}
return
pageId
;
}
...
...
@@ -135,7 +135,7 @@ public class PageFreeList extends Page {
full
=
false
;
store
.
logUndo
(
this
,
data
);
used
.
clear
(
pageId
-
getPos
());
store
.
update
Record
(
this
);
store
.
update
(
this
);
}
/**
...
...
@@ -197,7 +197,7 @@ public class PageFreeList extends Page {
public
void
moveTo
(
Session
session
,
int
newPos
)
throws
SQLException
{
// the old data does not need to be copied, as free-list pages
// at the end of the file are not required
store
.
free
Page
(
getPos
(),
true
,
data
);
store
.
free
(
getPos
(),
false
);
}
public
String
toString
()
{
...
...
h2/src/main/org/h2/store/PageLog.java
浏览文件 @
e91be706
...
...
@@ -198,7 +198,7 @@ public class PageLog {
while
(
firstTrunkPage
!=
0
)
{
PageStreamTrunk
t
=
(
PageStreamTrunk
)
store
.
getPage
(
firstTrunkPage
);
if
(
t
==
null
)
{
store
.
free
Page
(
firstTrunkPage
,
false
,
null
);
store
.
free
(
firstTrunkPage
,
false
);
// EOF
break
;
}
...
...
@@ -352,7 +352,7 @@ public class PageLog {
int
pageId
=
in
.
readVarInt
();
if
(
stage
==
RECOVERY_STAGE_REDO
)
{
if
(!
usedLogPages
.
get
(
pageId
))
{
store
.
free
Page
(
pageId
,
false
,
null
);
store
.
free
(
pageId
,
false
);
}
}
}
...
...
h2/src/main/org/h2/store/PageStore.java
浏览文件 @
e91be706
...
...
@@ -717,27 +717,27 @@ public class PageStore implements CacheWriter {
}
/**
* Update a
record
.
* Update a
page
.
*
* @param
record the record
* @param
page the page
*/
public
void
update
Record
(
Record
record
)
throws
SQLException
{
public
void
update
(
Page
page
)
throws
SQLException
{
synchronized
(
database
)
{
if
(
trace
.
isDebugEnabled
())
{
if
(!
record
.
isChanged
())
{
trace
.
debug
(
"updateRecord "
+
record
.
toString
());
if
(!
page
.
isChanged
())
{
trace
.
debug
(
"updateRecord "
+
page
.
toString
());
}
}
checkOpen
();
database
.
checkWritingAllowed
();
record
.
setChanged
(
true
);
int
pos
=
record
.
getPos
();
page
.
setChanged
(
true
);
int
pos
=
page
.
getPos
();
if
(
SysProperties
.
CHECK
&&
!
recoveryRunning
)
{
// ensure the undo entry is already written
log
.
addUndo
(
pos
,
null
);
}
allocatePage
(
pos
);
cache
.
update
(
pos
,
record
);
cache
.
update
(
pos
,
page
);
}
}
...
...
@@ -854,29 +854,22 @@ public class PageStore implements CacheWriter {
/**
* Add a page to the free list.
*
* @param pageId the page id
* @param logUndo if an undo entry need to be logged
* @param old the old data (if known)
* @param page the page
* @param undo if the undo record must have been written
*/
public
void
free
Page
(
int
pageId
,
boolean
logUndo
,
Data
old
)
throws
SQLException
{
public
void
free
(
int
pageId
,
boolean
undo
)
throws
SQLException
{
if
(
trace
.
isDebugEnabled
())
{
// trace.debug("freePage " + pageId);
}
int
todoRemoveOld
;
synchronized
(
database
)
{
if
(
SysProperties
.
CHECK
&&
!
recoveryRunning
&&
logUndo
)
{
cache
.
remove
(
pageId
);
if
(
SysProperties
.
CHECK
&&
!
recoveryRunning
&&
undo
)
{
// ensure the undo entry is already written
log
.
addUndo
(
pageId
,
null
);
}
cache
.
remove
(
pageId
);
freePage
(
pageId
);
if
(
recoveryRunning
)
{
writePage
(
pageId
,
createData
());
}
else
if
(
logUndo
)
{
if
(
old
==
null
)
{
old
=
readPage
(
pageId
);
}
log
.
addUndo
(
pageId
,
old
);
}
}
}
...
...
h2/src/main/org/h2/store/PageStreamTrunk.java
浏览文件 @
e91be706
...
...
@@ -168,11 +168,11 @@ public class PageStreamTrunk extends Page {
* @return the number of pages freed
*/
int
free
()
throws
SQLException
{
store
.
free
Page
(
getPos
(),
false
,
null
);
store
.
free
(
getPos
(),
false
);
int
freed
=
1
;
for
(
int
i
=
0
;
i
<
pageCount
;
i
++)
{
int
page
=
pageIds
[
i
];
store
.
free
Page
(
page
,
false
,
null
);
store
.
free
(
page
,
false
);
freed
++;
}
return
freed
;
...
...
@@ -201,7 +201,7 @@ public class PageStreamTrunk extends Page {
break
;
}
}
store
.
update
Record
(
this
);
store
.
update
(
this
);
}
public
void
moveTo
(
Session
session
,
int
newPos
)
{
...
...
h2/src/main/org/h2/store/WriterThread.java
浏览文件 @
e91be706
...
...
@@ -141,6 +141,11 @@ public class WriterThread implements Runnable {
if
(
traceSystem
!=
null
)
{
traceSystem
.
getTrace
(
Trace
.
LOG
).
error
(
"flush"
,
e
);
}
}
catch
(
RuntimeException
e
)
{
TraceSystem
traceSystem
=
database
.
getTraceSystem
();
if
(
traceSystem
!=
null
)
{
traceSystem
.
getTrace
(
Trace
.
LOG
).
error
(
"flush"
,
e
);
}
}
// TODO log writer: could also flush the dirty cache when there is
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论