Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
40de3268
提交
40de3268
authored
3月 26, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
New lob storage.
上级
8ffac30c
全部展开
显示空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
479 行增加
和
498 行删除
+479
-498
DropTable.java
h2/src/main/org/h2/command/ddl/DropTable.java
+1
-2
ScriptBase.java
h2/src/main/org/h2/command/dml/ScriptBase.java
+5
-0
SysProperties.java
h2/src/main/org/h2/constant/SysProperties.java
+7
-1
SessionRemote.java
h2/src/main/org/h2/engine/SessionRemote.java
+9
-0
JdbcConnection.java
h2/src/main/org/h2/jdbc/JdbcConnection.java
+16
-7
Data.java
h2/src/main/org/h2/store/Data.java
+83
-50
DataHandler.java
h2/src/main/org/h2/store/DataHandler.java
+13
-0
LobStorage.java
h2/src/main/org/h2/store/LobStorage.java
+120
-60
Recover.java
h2/src/main/org/h2/tools/Recover.java
+7
-0
DataType.java
h2/src/main/org/h2/value/DataType.java
+6
-6
Transfer.java
h2/src/main/org/h2/value/Transfer.java
+3
-4
Value.java
h2/src/main/org/h2/value/Value.java
+1
-0
ValueLob.java
h2/src/main/org/h2/value/ValueLob.java
+0
-3
ValueLob2.java
h2/src/main/org/h2/value/ValueLob2.java
+208
-365
没有找到文件。
h2/src/main/org/h2/command/ddl/DropTable.java
浏览文件 @
40de3268
...
...
@@ -12,7 +12,6 @@ import org.h2.engine.Right;
import
org.h2.engine.Session
;
import
org.h2.message.DbException
;
import
org.h2.schema.Schema
;
import
org.h2.store.LobStorage
;
import
org.h2.table.Table
;
/**
...
...
@@ -83,7 +82,7 @@ public class DropTable extends SchemaCommand {
table
.
setModified
();
Database
db
=
session
.
getDatabase
();
db
.
removeSchemaObject
(
session
,
table
);
LobStorage
.
removeAllForTable
(
db
,
dropTableId
);
db
.
getLobStorage
().
removeAllForTable
(
dropTableId
);
}
if
(
next
!=
null
)
{
next
.
executeDrop
();
...
...
h2/src/main/org/h2/command/dml/ScriptBase.java
浏览文件 @
40de3268
...
...
@@ -11,6 +11,7 @@ import java.io.BufferedOutputStream;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.sql.Connection
;
import
org.h2.command.Prepared
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
...
...
@@ -228,4 +229,8 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
return
null
;
}
public
Connection
getLobConnection
()
{
return
null
;
}
}
h2/src/main/org/h2/constant/SysProperties.java
浏览文件 @
40de3268
...
...
@@ -66,7 +66,7 @@ public class SysProperties {
public
static
final
String
LINE_SEPARATOR
=
getStringSetting
(
"line.separator"
,
"\n"
);
/**
* System property <code>user.home</code> (
default: empty string
).<br />
* System property <code>user.home</code> (
empty string if not set
).<br />
* It is usually set by the system, and used as a replacement for ~ in file
* names.
*/
...
...
@@ -437,6 +437,12 @@ public class SysProperties {
*/
public
static
final
String
PG_DEFAULT_CLIENT_ENCODING
=
getStringSetting
(
"h2.pgClientEncoding"
,
"UTF-8"
);
/**
* System property <code>h2.prefixTempFile</code> (default: h2.temp).<br />
* The prefix for temporary files in the temp directory.
*/
public
static
final
String
PREFIX_TEMP_FILE
=
getStringSetting
(
"h2.prefixTempFile"
,
"h2.temp"
);
/**
* System property <code>h2.recompileAlways</code> (default: false).<br />
* Always recompile prepared statements.
...
...
h2/src/main/org/h2/engine/SessionRemote.java
浏览文件 @
40de3268
...
...
@@ -8,6 +8,7 @@ package org.h2.engine;
import
java.io.IOException
;
import
java.net.Socket
;
import
java.sql.Connection
;
import
java.util.ArrayList
;
import
org.h2.api.DatabaseEventListener
;
import
org.h2.command.CommandInterface
;
...
...
@@ -80,6 +81,7 @@ public class SessionRemote extends SessionWithState implements SessionFactory, D
private
int
lastReconnect
;
private
SessionInterface
embedded
;
private
DatabaseEventListener
eventListener
;
private
LobStorage
lobStorage
;
public
SessionRemote
()
{
// nothing to do
...
...
@@ -620,6 +622,13 @@ public class SessionRemote extends SessionWithState implements SessionFactory, D
}
public
LobStorage
getLobStorage
()
{
if
(
lobStorage
==
null
)
{
lobStorage
=
new
LobStorage
(
this
);
}
return
lobStorage
;
}
public
Connection
getLobConnection
()
{
return
null
;
}
...
...
h2/src/main/org/h2/jdbc/JdbcConnection.java
浏览文件 @
40de3268
...
...
@@ -6,7 +6,9 @@
*/
package
org
.
h2
.
jdbc
;
import
java.io.ByteArrayInputStream
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.Reader
;
import
java.sql.Blob
;
import
java.sql.CallableStatement
;
...
...
@@ -32,7 +34,6 @@ import org.h2.message.DbException;
import
org.h2.message.Trace
;
import
org.h2.message.TraceObject
;
import
org.h2.result.ResultInterface
;
import
org.h2.store.LobStorage
;
import
org.h2.util.Utils
;
import
org.h2.value.CompareMode
;
import
org.h2.value.Value
;
...
...
@@ -1438,7 +1439,9 @@ public class JdbcConnection extends TraceObject implements Connection {
debugCodeAssign
(
"Clob"
,
TraceObject
.
CLOB
,
id
,
"createClob()"
);
checkClosedForWrite
();
try
{
Value
v
=
LobStorage
.
createSmallLob
(
Value
.
CLOB
,
Utils
.
EMPTY_BYTES
);
Value
v
=
session
.
getDataHandler
().
getLobStorage
().
createClob
(
new
InputStreamReader
(
new
ByteArrayInputStream
(
Utils
.
EMPTY_BYTES
)),
0
);
return
new
JdbcClob
(
this
,
v
,
id
);
}
finally
{
afterWriting
();
...
...
@@ -1459,7 +1462,7 @@ public class JdbcConnection extends TraceObject implements Connection {
debugCodeAssign
(
"Blob"
,
TraceObject
.
BLOB
,
id
,
"createClob()"
);
checkClosedForWrite
();
try
{
Value
v
=
LobStorage
.
createSmallLob
(
Value
.
BLOB
,
Utils
.
EMPTY_BYTES
);
Value
v
=
session
.
getDataHandler
().
getLobStorage
().
createBlob
(
new
ByteArrayInputStream
(
Utils
.
EMPTY_BYTES
),
0
);
return
new
JdbcBlob
(
this
,
v
,
id
);
}
finally
{
afterWriting
();
...
...
@@ -1480,8 +1483,14 @@ public class JdbcConnection extends TraceObject implements Connection {
int id = getNextId(TraceObject.CLOB);
debugCodeAssign("NClob", TraceObject.CLOB, id, "createNClob()");
checkClosedForWrite();
Value v = LobStorage.createSmallLob(Value.CLOB, Utils.EMPTY_BYTES);
try {
Value v = session.getDataHandler().getLobStorage().createClob(
new InputStreamReader(
new ByteArrayInputStream(Utils.EMPTY_BYTES)), 0);
return new JdbcClob(this, v, id);
} finally {
afterWriting();
}
} catch (Exception e) {
throw logAndConvert(e);
}
...
...
@@ -1614,7 +1623,7 @@ public class JdbcConnection extends TraceObject implements Connection {
if
(
length
<=
0
)
{
length
=
-
1
;
}
Value
v
=
LobStorage
.
createClob
(
x
,
length
,
session
.
getDataHandler
()
);
Value
v
=
session
.
getDataHandler
().
getLobStorage
().
createClob
(
x
,
length
);
return
v
;
}
...
...
@@ -1633,7 +1642,7 @@ public class JdbcConnection extends TraceObject implements Connection {
if
(
length
<=
0
)
{
length
=
-
1
;
}
Value
v
=
LobStorage
.
createBlob
(
x
,
length
,
session
.
getDataHandler
()
);
Value
v
=
session
.
getDataHandler
().
getLobStorage
().
createBlob
(
x
,
length
);
return
v
;
}
...
...
h2/src/main/org/h2/store/Data.java
浏览文件 @
40de3268
...
...
@@ -32,6 +32,7 @@ import org.h2.value.ValueFloat;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueJavaObject
;
import
org.h2.value.ValueLob
;
import
org.h2.value.ValueLob2
;
import
org.h2.value.ValueLong
;
import
org.h2.value.ValueNull
;
import
org.h2.value.ValueShort
;
...
...
@@ -514,6 +515,7 @@ public class Data {
case
Value
.
BLOB
:
case
Value
.
CLOB
:
{
writeByte
((
byte
)
type
);
if
(
v
instanceof
ValueLob
)
{
ValueLob
lob
=
(
ValueLob
)
v
;
lob
.
convertToFileIfRequired
(
handler
);
byte
[]
small
=
lob
.
getSmall
();
...
...
@@ -534,6 +536,18 @@ public class Data {
writeVarInt
(
small
.
length
);
write
(
small
,
0
,
small
.
length
);
}
}
else
{
ValueLob2
lob
=
(
ValueLob2
)
v
;
byte
[]
small
=
lob
.
getSmall
();
if
(
small
==
null
)
{
writeVarInt
(-
3
);
writeVarLong
(
lob
.
getLobId
());
writeVarLong
(
lob
.
getPrecision
());
}
else
{
writeVarInt
(
small
.
length
);
write
(
small
,
0
,
small
.
length
);
}
}
break
;
}
case
Value
.
ARRAY
:
{
...
...
@@ -654,12 +668,17 @@ public class Data {
byte
[]
small
=
Utils
.
newBytes
(
smallLen
);
read
(
small
,
0
,
smallLen
);
return
LobStorage
.
createSmallLob
(
type
,
small
);
}
}
else
if
(
smallLen
==
-
3
)
{
long
lobId
=
readVarLong
();
long
precision
=
readVarLong
();
LobStorage
lobStorage
=
handler
.
getLobStorage
();
ValueLob2
lob
=
ValueLob2
.
create
(
type
,
lobStorage
,
null
,
lobId
,
precision
);
return
lob
;
}
else
{
int
tableId
=
readVarInt
();
int
objectId
=
readVarInt
();
long
precision
=
0
;
boolean
compression
=
false
;
// TODO simplify
// -1: regular
// -2: regular, but not linked (in this case: including file name)
if
(
smallLen
==
-
1
||
smallLen
==
-
2
)
{
...
...
@@ -672,6 +691,7 @@ public class Data {
}
return
lob
;
}
}
case
Value
.
ARRAY
:
{
int
len
=
readVarInt
();
Value
[]
list
=
new
Value
[
len
];
...
...
@@ -809,6 +829,7 @@ public class Data {
case
Value
.
BLOB
:
case
Value
.
CLOB
:
{
int
len
=
1
;
if
(
v
instanceof
ValueLob
)
{
ValueLob
lob
=
(
ValueLob
)
v
;
lob
.
convertToFileIfRequired
(
handler
);
byte
[]
small
=
lob
.
getSmall
();
...
...
@@ -829,6 +850,18 @@ public class Data {
len
+=
getVarIntLen
(
small
.
length
);
len
+=
small
.
length
;
}
}
else
{
ValueLob2
lob
=
(
ValueLob2
)
v
;
byte
[]
small
=
lob
.
getSmall
();
if
(
small
==
null
)
{
len
+=
getVarIntLen
(-
3
);
len
+=
getVarLongLen
(
lob
.
getLobId
());
len
+=
getVarLongLen
(
lob
.
getPrecision
());
}
else
{
len
+=
getVarIntLen
(
small
.
length
);
len
+=
small
.
length
;
}
}
return
len
;
}
case
Value
.
ARRAY
:
{
...
...
h2/src/main/org/h2/store/DataHandler.java
浏览文件 @
40de3268
...
...
@@ -6,6 +6,7 @@
*/
package
org
.
h2
.
store
;
import
java.sql.Connection
;
import
org.h2.util.SmallLRUCache
;
import
org.h2.util.TempFileDeleter
;
...
...
@@ -91,6 +92,18 @@ public interface DataHandler {
*/
SmallLRUCache
<
String
,
String
[]>
getLobFileListCache
();
/**
* Get the lob storage mechanism to use.
*
* @return the lob storage mechanism
*/
LobStorage
getLobStorage
();
/**
* Get a database connection to be used for LOB access.
*
* @return the connection or null
*/
Connection
getLobConnection
();
}
h2/src/main/org/h2/store/LobStorage.java
浏览文件 @
40de3268
差异被折叠。
点击展开。
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
40de3268
...
...
@@ -1223,4 +1223,11 @@ public class Recover extends Tool implements DataHandler {
return
null
;
}
/**
* INTERNAL
*/
public
Connection
getLobConnection
()
{
return
null
;
}
}
h2/src/main/org/h2/value/DataType.java
浏览文件 @
40de3268
...
...
@@ -546,7 +546,7 @@ public class DataType {
if
(
in
==
null
)
{
v
=
ValueNull
.
INSTANCE
;
}
else
{
v
=
LobStorage
.
createClob
(
new
BufferedReader
(
in
),
-
1
,
session
.
getDataHandler
()
);
v
=
session
.
getDataHandler
().
getLobStorage
().
createClob
(
new
BufferedReader
(
in
),
-
1
);
}
}
break
;
...
...
@@ -556,7 +556,7 @@ public class DataType {
v
=
LobStorage
.
createSmallLob
(
Value
.
BLOB
,
rs
.
getBytes
(
columnIndex
));
}
else
{
InputStream
in
=
rs
.
getBinaryStream
(
columnIndex
);
v
=
(
in
==
null
)
?
(
Value
)
ValueNull
.
INSTANCE
:
LobStorage
.
createBlob
(
in
,
-
1
,
session
.
getDataHandler
()
);
v
=
(
in
==
null
)
?
(
Value
)
ValueNull
.
INSTANCE
:
session
.
getDataHandler
().
getLobStorage
().
createBlob
(
in
,
-
1
);
}
break
;
}
...
...
@@ -864,19 +864,19 @@ public class DataType {
return
ValueTimestamp
.
get
(
new
Timestamp
(((
java
.
util
.
Date
)
x
).
getTime
()));
}
else
if
(
x
instanceof
java
.
io
.
Reader
)
{
Reader
r
=
new
BufferedReader
((
java
.
io
.
Reader
)
x
);
return
LobStorage
.
createClob
(
r
,
-
1
,
session
.
getDataHandler
()
);
return
session
.
getDataHandler
().
getLobStorage
().
createClob
(
r
,
-
1
);
}
else
if
(
x
instanceof
java
.
sql
.
Clob
)
{
try
{
Reader
r
=
new
BufferedReader
(((
java
.
sql
.
Clob
)
x
).
getCharacterStream
());
return
LobStorage
.
createClob
(
r
,
-
1
,
session
.
getDataHandler
()
);
return
session
.
getDataHandler
().
getLobStorage
().
createClob
(
r
,
-
1
);
}
catch
(
SQLException
e
)
{
throw
DbException
.
convert
(
e
);
}
}
else
if
(
x
instanceof
java
.
io
.
InputStream
)
{
return
LobStorage
.
createBlob
((
java
.
io
.
InputStream
)
x
,
-
1
,
session
.
getDataHandler
()
);
return
session
.
getDataHandler
().
getLobStorage
().
createBlob
((
java
.
io
.
InputStream
)
x
,
-
1
);
}
else
if
(
x
instanceof
java
.
sql
.
Blob
)
{
try
{
return
LobStorage
.
createBlob
(((
java
.
sql
.
Blob
)
x
).
getBinaryStream
(),
-
1
,
session
.
getDataHandler
()
);
return
session
.
getDataHandler
().
getLobStorage
().
createBlob
(((
java
.
sql
.
Blob
)
x
).
getBinaryStream
(),
-
1
);
}
catch
(
SQLException
e
)
{
throw
DbException
.
convert
(
e
);
}
...
...
h2/src/main/org/h2/value/Transfer.java
浏览文件 @
40de3268
...
...
@@ -29,13 +29,12 @@ import org.h2.engine.Constants;
import
org.h2.engine.SessionInterface
;
import
org.h2.message.DbException
;
import
org.h2.message.TraceSystem
;
import
org.h2.store.LobStorage
;
import
org.h2.tools.SimpleResultSet
;
import
org.h2.util.Utils
;
import
org.h2.util.ExactUTF8InputStreamReader
;
import
org.h2.util.IOUtils
;
import
org.h2.util.NetUtils
;
import
org.h2.util.StringUtils
;
import
org.h2.util.Utils
;
/**
* The transfer class is used to send and receive Value objects.
...
...
@@ -484,7 +483,7 @@ public class Transfer {
return
ValueStringFixed
.
get
(
readString
());
case
Value
.
BLOB
:
{
long
length
=
readLong
();
Value
v
=
LobStorage
.
createBlob
(
in
,
length
,
session
.
getDataHandler
()
);
Value
v
=
session
.
getDataHandler
().
getLobStorage
().
createBlob
(
in
,
length
);
int
magic
=
readInt
();
if
(
magic
!=
LOB_MAGIC
)
{
throw
DbException
.
get
(
ErrorCode
.
CONNECTION_BROKEN_1
,
"magic="
+
magic
);
...
...
@@ -493,7 +492,7 @@ public class Transfer {
}
case
Value
.
CLOB
:
{
long
length
=
readLong
();
Value
v
=
LobStorage
.
createClob
(
new
ExactUTF8InputStreamReader
(
in
),
length
,
session
.
getDataHandler
()
);
Value
v
=
session
.
getDataHandler
().
getLobStorage
().
createClob
(
new
ExactUTF8InputStreamReader
(
in
),
length
);
int
magic
=
readInt
();
if
(
magic
!=
LOB_MAGIC
)
{
throw
DbException
.
get
(
ErrorCode
.
CONNECTION_BROKEN_1
,
"magic="
+
magic
);
...
...
h2/src/main/org/h2/value/Value.java
浏览文件 @
40de3268
...
...
@@ -706,6 +706,7 @@ public abstract class Value {
case
BLOB:
{
switch
(
getType
())
{
case
BYTES:
return
LobStorage
.
createSmallLob
(
Value
.
BLOB
,
getBytesNoCopy
());
}
break
;
...
...
h2/src/main/org/h2/value/ValueLob.java
浏览文件 @
40de3268
...
...
@@ -44,9 +44,6 @@ import org.h2.util.Utils;
* Data compression is supported.
*/
public
class
ValueLob
extends
Value
{
// TODO lob: concatenate function for blob and clob
// (to create a large blob from pieces)
// and a getpart function (to get it in pieces) and make sure a file is created!
/**
* This counter is used to calculate the next directory to store lobs. It is
...
...
h2/src/main/org/h2/value/ValueLob2.java
浏览文件 @
40de3268
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论