Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
271f9943
提交
271f9943
authored
10月 05, 2015
作者:
Thomas Mueller Graf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Temporary CLOB and BLOB objects are now removed while the database is open
上级
735f3467
显示空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
86 行增加
和
109 行删除
+86
-109
changelog.html
h2/src/docsrc/html/changelog.html
+3
-0
CommandRemote.java
h2/src/main/org/h2/command/CommandRemote.java
+1
-1
Session.java
h2/src/main/org/h2/engine/Session.java
+24
-27
Function.java
h2/src/main/org/h2/expression/Function.java
+1
-0
ParameterRemote.java
h2/src/main/org/h2/expression/ParameterRemote.java
+1
-1
PageDataIndex.java
h2/src/main/org/h2/index/PageDataIndex.java
+5
-5
MVPrimaryIndex.java
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
+5
-5
RowList.java
h2/src/main/org/h2/result/RowList.java
+2
-2
Data.java
h2/src/main/org/h2/store/Data.java
+2
-2
Recover.java
h2/src/main/org/h2/tools/Recover.java
+4
-2
DataType.java
h2/src/main/org/h2/value/DataType.java
+15
-0
Value.java
h2/src/main/org/h2/value/Value.java
+7
-17
ValueLob.java
h2/src/main/org/h2/value/ValueLob.java
+4
-23
ValueLobDb.java
h2/src/main/org/h2/value/ValueLobDb.java
+11
-23
ValueResultSet.java
h2/src/main/org/h2/value/ValueResultSet.java
+1
-1
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
271f9943
...
...
@@ -21,6 +21,9 @@ Change Log
<h2>
Next Version (unreleased)
</h2>
<ul>
<li>
Temporary CLOB and BLOB objects are now removed while the database is open
(and not just when closing the database).
</li>
<li>
MVStore CLOB and BLOB larger than about 25 MB: An exception could be thrown
when using the MVStore storage.
</li>
...
...
h2/src/main/org/h2/command/CommandRemote.java
浏览文件 @
271f9943
...
...
@@ -236,7 +236,7 @@ public class CommandRemote implements CommandInterface {
for
(
ParameterInterface
p
:
parameters
)
{
Value
v
=
p
.
getParamValue
();
if
(
v
!=
null
)
{
v
.
clos
e
();
v
.
remov
e
();
}
}
}
catch
(
DbException
e
)
{
...
...
h2/src/main/org/h2/engine/Session.java
浏览文件 @
271f9943
...
...
@@ -86,7 +86,7 @@ public class Session extends SessionWithState {
private
String
currentSchemaName
;
private
String
[]
schemaSearchPath
;
private
Trace
trace
;
private
HashMap
<
String
,
Value
>
unlink
LobMap
;
private
HashMap
<
String
,
Value
>
remove
LobMap
;
private
int
systemIdentifier
;
private
HashMap
<
String
,
Procedure
>
procedures
;
private
boolean
undoLogEnabled
=
true
;
...
...
@@ -173,14 +173,13 @@ public class Session extends SessionWithState {
old
=
variables
.
remove
(
name
);
}
else
{
// link LOB values, to make sure we have our own object
value
=
value
.
link
(
database
,
value
=
value
.
copy
(
database
,
LobStorageFrontend
.
TABLE_ID_SESSION_VARIABLE
);
old
=
variables
.
put
(
name
,
value
);
}
if
(
old
!=
null
)
{
// close the old value (in case it is a lob)
old
.
unlink
(
database
);
old
.
close
();
// remove the old value (in case it is a lob)
old
.
remove
();
}
}
...
...
@@ -547,8 +546,8 @@ public class Session extends SessionWithState {
private
void
removeTemporaryLobs
(
boolean
onTimeout
)
{
if
(
temporaryLobs
!=
null
)
{
for
(
Value
v
:
temporaryLobs
)
{
if
(!
v
.
isLinked
())
{
v
.
clos
e
();
if
(!
v
.
isLinked
ToTable
())
{
v
.
remov
e
();
}
}
temporaryLobs
.
clear
();
...
...
@@ -562,8 +561,8 @@ public class Session extends SessionWithState {
break
;
}
Value
v
=
temporaryResultLobs
.
removeFirst
().
value
;
if
(!
v
.
isLinked
())
{
v
.
clos
e
();
if
(!
v
.
isLinked
ToTable
())
{
v
.
remov
e
();
}
}
}
...
...
@@ -576,17 +575,16 @@ public class Session extends SessionWithState {
}
private
void
endTransaction
()
{
if
(
unlinkLobMap
!=
null
&&
unlink
LobMap
.
size
()
>
0
)
{
if
(
removeLobMap
!=
null
&&
remove
LobMap
.
size
()
>
0
)
{
if
(
database
.
getMvStore
()
==
null
)
{
// need to flush the transaction log, because we can't unlink
// lobs if the commit record is not written
database
.
flush
();
}
for
(
Value
v
:
unlinkLobMap
.
values
())
{
v
.
unlink
(
database
);
v
.
close
();
for
(
Value
v
:
removeLobMap
.
values
())
{
v
.
remove
();
}
unlink
LobMap
=
null
;
remove
LobMap
=
null
;
}
unlockAll
();
}
...
...
@@ -1128,29 +1126,24 @@ public class Session extends SessionWithState {
}
/**
* Remember that the given LOB value must be un-linked (disconnected from
* the table) at commit.
* Remember that the given LOB value must be removed at commit.
*
* @param v the value
*/
public
void
unlink
AtCommit
(
Value
v
)
{
if
(
SysProperties
.
CHECK
&&
!
v
.
isLinked
())
{
public
void
remove
AtCommit
(
Value
v
)
{
if
(
SysProperties
.
CHECK
&&
!
v
.
isLinked
ToTable
())
{
DbException
.
throwInternalError
();
}
if
(
unlinkLobMap
==
null
)
{
unlinkLobMap
=
New
.
hashMap
();
}
unlinkLobMap
.
put
(
v
.
toString
(),
v
);
}
/**
* Do not
unlink
this LOB value at commit any longer.
* Do not
remove
this LOB value at commit any longer.
*
* @param v the value
*/
public
void
unlink
AtCommitStop
(
Value
v
)
{
if
(
unlink
LobMap
!=
null
)
{
unlink
LobMap
.
remove
(
v
.
toString
());
public
void
remove
AtCommitStop
(
Value
v
)
{
if
(
remove
LobMap
!=
null
)
{
remove
LobMap
.
remove
(
v
.
toString
());
}
}
...
...
@@ -1481,7 +1474,11 @@ public class Session extends SessionWithState {
@Override
public
void
addTemporaryLob
(
Value
v
)
{
if
(
v
.
getTableId
()
==
LobStorageFrontend
.
TABLE_RESULT
)
{
if
(
v
.
getType
()
!=
Value
.
CLOB
&&
v
.
getType
()
!=
Value
.
BLOB
)
{
return
;
}
if
(
v
.
getTableId
()
==
LobStorageFrontend
.
TABLE_RESULT
||
v
.
getTableId
()
==
LobStorageFrontend
.
TABLE_TEMP
)
{
if
(
temporaryResultLobs
==
null
)
{
temporaryResultLobs
=
new
LinkedList
<
TimeoutValue
>();
}
...
...
h2/src/main/org/h2/expression/Function.java
浏览文件 @
271f9943
...
...
@@ -1592,6 +1592,7 @@ public class Function extends Expression implements FunctionCall {
}
result
=
database
.
getLobStorage
().
createClob
(
reader
,
-
1
);
}
session
.
addTemporaryLob
(
result
);
}
catch
(
IOException
e
)
{
throw
DbException
.
convertIOException
(
e
,
fileName
);
}
...
...
h2/src/main/org/h2/expression/ParameterRemote.java
浏览文件 @
271f9943
...
...
@@ -32,7 +32,7 @@ public class ParameterRemote implements ParameterInterface {
@Override
public
void
setValue
(
Value
newValue
,
boolean
closeOld
)
{
if
(
closeOld
&&
value
!=
null
)
{
value
.
clos
e
();
value
.
remov
e
();
}
value
=
newValue
;
}
...
...
h2/src/main/org/h2/index/PageDataIndex.java
浏览文件 @
271f9943
...
...
@@ -116,9 +116,9 @@ public class PageDataIndex extends PageIndex {
if
(
tableData
.
getContainsLargeObject
())
{
for
(
int
i
=
0
,
len
=
row
.
getColumnCount
();
i
<
len
;
i
++)
{
Value
v
=
row
.
getValue
(
i
);
Value
v2
=
v
.
link
(
database
,
getId
());
if
(
v2
.
isLinked
())
{
session
.
unlink
AtCommitStop
(
v2
);
Value
v2
=
v
.
copy
(
database
,
getId
());
if
(
v2
.
isLinked
ToTable
())
{
session
.
remove
AtCommitStop
(
v2
);
}
if
(
v
!=
v2
)
{
row
.
setValue
(
i
,
v2
);
...
...
@@ -327,8 +327,8 @@ public class PageDataIndex extends PageIndex {
if
(
tableData
.
getContainsLargeObject
())
{
for
(
int
i
=
0
,
len
=
row
.
getColumnCount
();
i
<
len
;
i
++)
{
Value
v
=
row
.
getValue
(
i
);
if
(
v
.
isLinked
())
{
session
.
unlinkAtCommit
(
v
);
if
(
v
.
isLinked
ToTable
())
{
session
.
removeAtCommitStop
(
v
);
}
}
}
...
...
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
浏览文件 @
271f9943
...
...
@@ -118,9 +118,9 @@ public class MVPrimaryIndex extends BaseIndex {
if
(
mvTable
.
getContainsLargeObject
())
{
for
(
int
i
=
0
,
len
=
row
.
getColumnCount
();
i
<
len
;
i
++)
{
Value
v
=
row
.
getValue
(
i
);
Value
v2
=
v
.
link
(
database
,
getId
());
if
(
v2
.
isLinked
())
{
session
.
unlink
AtCommitStop
(
v2
);
Value
v2
=
v
.
copy
(
database
,
getId
());
if
(
v2
.
isLinked
ToTable
())
{
session
.
remove
AtCommitStop
(
v2
);
}
if
(
v
!=
v2
)
{
row
.
setValue
(
i
,
v2
);
...
...
@@ -153,8 +153,8 @@ public class MVPrimaryIndex extends BaseIndex {
if
(
mvTable
.
getContainsLargeObject
())
{
for
(
int
i
=
0
,
len
=
row
.
getColumnCount
();
i
<
len
;
i
++)
{
Value
v
=
row
.
getValue
(
i
);
if
(
v
.
isLinked
())
{
session
.
unlink
AtCommit
(
v
);
if
(
v
.
isLinked
ToTable
())
{
session
.
remove
AtCommit
(
v
);
}
}
}
...
...
h2/src/main/org/h2/result/RowList.java
浏览文件 @
271f9943
...
...
@@ -181,11 +181,11 @@ public class RowList {
v
=
null
;
}
else
{
v
=
buff
.
readValue
();
if
(
v
.
isLinked
())
{
if
(
v
.
isLinked
ToTable
())
{
// the table id is 0 if it was linked when writing
// a temporary entry
if
(
v
.
getTableId
()
==
0
)
{
session
.
unlink
AtCommit
(
v
);
session
.
remove
AtCommit
(
v
);
}
}
}
...
...
h2/src/main/org/h2/store/Data.java
浏览文件 @
271f9943
...
...
@@ -623,7 +623,7 @@ public class Data {
byte
[]
small
=
lob
.
getSmall
();
if
(
small
==
null
)
{
int
t
=
-
1
;
if
(!
lob
.
isLinked
())
{
if
(!
lob
.
isLinked
ToTable
())
{
t
=
-
2
;
}
writeVarInt
(
t
);
...
...
@@ -1044,7 +1044,7 @@ public class Data {
byte
[]
small
=
lob
.
getSmall
();
if
(
small
==
null
)
{
int
t
=
-
1
;
if
(!
lob
.
isLinked
())
{
if
(!
lob
.
isLinked
ToTable
())
{
t
=
-
2
;
}
len
+=
getVarIntLen
(
t
);
...
...
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
271f9943
...
...
@@ -691,8 +691,7 @@ public class Recover extends Tool implements DataHandler {
MVMap
<
Long
,
byte
[]>
lobData
=
mv
.
openMap
(
"lobData"
);
StreamStore
streamStore
=
new
StreamStore
(
lobData
);
MVMap
<
Long
,
Object
[]>
lobMap
=
mv
.
openMap
(
"lobMap"
);
writer
.
println
(
"-- LOB (lobMap.id=0x"
+
Integer
.
toHexString
(
lobMap
.
getId
())
+
", lobData.id=0x"
+
Integer
.
toHexString
(
lobData
.
getId
())
+
")"
);
writer
.
println
(
"-- LOB"
);
writer
.
println
(
"CREATE TABLE IF NOT EXISTS "
+
"INFORMATION_SCHEMA.LOB_BLOCKS("
+
"LOB_ID BIGINT, SEQ INT, DATA BINARY, "
+
...
...
@@ -722,6 +721,9 @@ public class Recover extends Tool implements DataHandler {
hasErrors
=
true
;
}
}
writer
.
println
(
"-- lobMap.size: "
+
lobMap
.
sizeAsLong
());
writer
.
println
(
"-- lobData.size: "
+
lobData
.
sizeAsLong
());
if
(
hasErrors
)
{
writer
.
println
(
"-- lobMap"
);
for
(
Long
k
:
lobMap
.
keyList
())
{
...
...
h2/src/main/org/h2/value/DataType.java
浏览文件 @
271f9943
...
...
@@ -607,6 +607,9 @@ public class DataType {
createClob
(
new
BufferedReader
(
in
),
-
1
);
}
}
if
(
session
!=
null
)
{
session
.
addTemporaryLob
(
v
);
}
break
;
}
case
Value
.
BLOB
:
{
...
...
@@ -618,6 +621,9 @@ public class DataType {
InputStream
in
=
rs
.
getBinaryStream
(
columnIndex
);
v
=
(
in
==
null
)
?
(
Value
)
ValueNull
.
INSTANCE
:
session
.
getDataHandler
().
getLobStorage
().
createBlob
(
in
,
-
1
);
if
(
session
!=
null
)
{
session
.
addTemporaryLob
(
v
);
}
break
;
}
case
Value
.
JAVA_OBJECT
:
{
...
...
@@ -956,6 +962,15 @@ public class DataType {
*/
public
static
Value
convertToValue
(
SessionInterface
session
,
Object
x
,
int
type
)
{
Value
v
=
convertToValue1
(
session
,
x
,
type
);
if
(
session
!=
null
)
{
session
.
addTemporaryLob
(
v
);
}
return
v
;
}
private
static
Value
convertToValue1
(
SessionInterface
session
,
Object
x
,
int
type
)
{
if
(
x
==
null
)
{
return
ValueNull
.
INSTANCE
;
}
...
...
h2/src/main/org/h2/value/Value.java
浏览文件 @
271f9943
...
...
@@ -1021,14 +1021,14 @@ public abstract class Value {
}
/**
*
Link a large value to a given table. For values that are kept fully in
* memory this method has no effect.
*
Copy a large value, to be used in the given table. For values that are
*
kept fully in
memory this method has no effect.
*
* @param handler the data handler
* @param tableId the table
to link to
* @param tableId the table
where this object is used
* @return the new value or itself
*/
public
Value
link
(
DataHandler
handler
,
int
tableId
)
{
public
Value
copy
(
DataHandler
handler
,
int
tableId
)
{
return
this
;
}
...
...
@@ -1038,25 +1038,15 @@ public abstract class Value {
*
* @return true if it is
*/
public
boolean
isLinked
()
{
public
boolean
isLinked
ToTable
()
{
return
false
;
}
/**
* Mark any underlying resource as 'not linked to any table'. For values
* that are kept fully in memory this method has no effect.
*
* @param handler the data handler
*/
public
void
unlink
(
DataHandler
handler
)
{
// nothing to do
}
/**
* Close the underlying resource, if any. For values that are kept fully in
* Remove the underlying resource, if any. For values that are kept fully in
* memory this method has no effect.
*/
public
void
clos
e
()
{
public
void
remov
e
()
{
// nothing to do
}
...
...
h2/src/main/org/h2/value/ValueLob.java
浏览文件 @
271f9943
...
...
@@ -464,7 +464,7 @@ public class ValueLob extends Value {
}
@Override
public
boolean
isLinked
()
{
public
boolean
isLinked
ToTable
()
{
return
linked
;
}
...
...
@@ -478,7 +478,7 @@ public class ValueLob extends Value {
}
@Override
public
void
clos
e
()
{
public
void
remov
e
()
{
if
(
fileName
!=
null
)
{
if
(
tempFile
!=
null
)
{
tempFile
.
stopAutoDelete
();
...
...
@@ -489,26 +489,7 @@ public class ValueLob extends Value {
}
@Override
public
void
unlink
(
DataHandler
handler
)
{
if
(
linked
&&
fileName
!=
null
)
{
String
temp
;
// synchronize on the database, to avoid concurrent temp file
// creation / deletion / backup
synchronized
(
handler
)
{
temp
=
getFileName
(
handler
,
-
1
,
objectId
);
deleteFile
(
handler
,
temp
);
renameFile
(
handler
,
fileName
,
temp
);
tempFile
=
FileStore
.
open
(
handler
,
temp
,
"rw"
);
tempFile
.
autoDelete
();
tempFile
.
closeSilently
();
fileName
=
temp
;
linked
=
false
;
}
}
}
@Override
public
Value
link
(
DataHandler
h
,
int
tabId
)
{
public
Value
copy
(
DataHandler
h
,
int
tabId
)
{
if
(
fileName
==
null
)
{
this
.
tableId
=
tabId
;
return
this
;
...
...
@@ -747,7 +728,7 @@ public class ValueLob extends Value {
createFromReader
(
new
char
[
len
],
0
,
getReader
(),
Long
.
MAX_VALUE
,
h
);
}
Value
v2
=
link
(
h
,
tabId
);
Value
v2
=
copy
(
h
,
tabId
);
if
(
SysProperties
.
CHECK
&&
v2
!=
this
)
{
DbException
.
throwInternalError
();
}
...
...
h2/src/main/org/h2/value/ValueLobDb.java
浏览文件 @
271f9943
...
...
@@ -13,6 +13,7 @@ import java.io.InputStream;
import
java.io.Reader
;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
import
org.h2.engine.Constants
;
import
org.h2.engine.SysProperties
;
import
org.h2.message.DbException
;
...
...
@@ -205,10 +206,9 @@ public class ValueLobDb extends Value implements Value.ValueClob,
}
@Override
public
boolean
isLinked
()
{
return
tableId
!=
LobStorageFrontend
.
TABLE_ID_SESSION_VARIABLE
&&
tableId
!=
LobStorageFrontend
.
TABLE_RESULT
&&
small
==
null
;
public
boolean
isLinkedToTable
()
{
return
small
==
null
&&
tableId
>=
0
;
}
public
boolean
isStored
()
{
...
...
@@ -216,7 +216,7 @@ public class ValueLobDb extends Value implements Value.ValueClob,
}
@Override
public
void
clos
e
()
{
public
void
remov
e
()
{
if
(
fileName
!=
null
)
{
if
(
tempFile
!=
null
)
{
tempFile
.
stopAutoDelete
();
...
...
@@ -233,24 +233,10 @@ public class ValueLobDb extends Value implements Value.ValueClob,
}
@Override
public
void
unlink
(
DataHandler
database
)
{
if
(
small
==
null
&&
tableId
!=
LobStorageFrontend
.
TABLE_ID_SESSION_VARIABLE
)
{
database
.
getLobStorage
().
setTable
(
this
,
LobStorageFrontend
.
TABLE_ID_SESSION_VARIABLE
);
tableId
=
LobStorageFrontend
.
TABLE_ID_SESSION_VARIABLE
;
}
}
@Override
public
Value
link
(
DataHandler
database
,
int
tabId
)
{
public
Value
copy
(
DataHandler
database
,
int
tableId
)
{
if
(
small
==
null
)
{
if
(
tableId
==
LobStorageFrontend
.
TABLE_TEMP
)
{
database
.
getLobStorage
().
setTable
(
this
,
tabId
);
this
.
tableId
=
tabId
;
}
else
{
return
handler
.
getLobStorage
().
copyLob
(
this
,
tabId
,
getPrecision
());
}
Value
v2
=
handler
.
getLobStorage
().
copyLob
(
this
,
tableId
,
getPrecision
());
return
v2
;
}
else
if
(
small
.
length
>
database
.
getMaxLengthInplaceLob
())
{
LobStorageInterface
s
=
database
.
getLobStorage
();
Value
v
;
...
...
@@ -259,7 +245,9 @@ public class ValueLobDb extends Value implements Value.ValueClob,
}
else
{
v
=
s
.
createClob
(
getReader
(),
getPrecision
());
}
return
v
.
link
(
database
,
tabId
);
Value
v2
=
v
.
copy
(
database
,
tableId
);
v
.
remove
();
return
v2
;
}
return
this
;
}
...
...
h2/src/main/org/h2/value/ValueResultSet.java
浏览文件 @
271f9943
...
...
@@ -104,7 +104,7 @@ public class ValueResultSet extends Value {
for
(
int
j
=
0
;
j
<
columnCount
;
j
++)
{
buff
.
appendExceptFirst
(
", "
);
int
t
=
DataType
.
getValueTypeFromResultSet
(
meta
,
j
+
1
);
Value
v
=
DataType
.
readValue
(
null
,
result
,
j
+
1
,
t
);
Value
v
=
DataType
.
readValue
(
null
,
result
,
j
+
1
,
t
);
buff
.
append
(
v
.
getString
());
}
buff
.
append
(
')'
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论