Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
5b9781f6
提交
5b9781f6
authored
11 年前
作者:
noelgrandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix an issue with storing Unicode surrogate pairs in CLOB columns.
上级
5ed6d648
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
59 行增加
和
2 行删除
+59
-2
changelog.html
h2/src/docsrc/html/changelog.html
+1
-0
ValueLobDb.java
h2/src/main/org/h2/value/ValueLobDb.java
+2
-2
TestLob.java
h2/src/test/org/h2/test/db/TestLob.java
+56
-0
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
5b9781f6
...
@@ -46,6 +46,7 @@ Change Log
...
@@ -46,6 +46,7 @@ Change Log
</li><li>
Issue 532: Javadoc for ErrorCode.ROLES_AND_RIGHT_CANNOT_BE_MIXED looks wrong
</li><li>
Issue 532: Javadoc for ErrorCode.ROLES_AND_RIGHT_CANNOT_BE_MIXED looks wrong
</li><li>
Issue 528: Add Oracle-compatible TO_CHAR function, patch by Daniel Gredler.
</li><li>
Issue 528: Add Oracle-compatible TO_CHAR function, patch by Daniel Gredler.
</li><li>
Issue 534: CREATE ALIAS NOCACHE, Patch by Nicolas Fortin
</li><li>
Issue 534: CREATE ALIAS NOCACHE, Patch by Nicolas Fortin
</li><li>
Fix an issue with storing Unicode surrogate pairs in CLOB columns.
</li></ul>
</li></ul>
<h2>
Version 1.3.174 (2013-10-19)
</h2>
<h2>
Version 1.3.174 (2013-10-19)
</h2>
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueLobDb.java
浏览文件 @
5b9781f6
...
@@ -10,10 +10,10 @@ import java.io.BufferedInputStream;
...
@@ -10,10 +10,10 @@ import java.io.BufferedInputStream;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayInputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.Reader
;
import
java.io.Reader
;
import
java.sql.PreparedStatement
;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
org.h2.constant.SysProperties
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
...
@@ -392,7 +392,7 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
...
@@ -392,7 +392,7 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
@Override
@Override
public
Reader
getReader
()
{
public
Reader
getReader
()
{
return
IOUtils
.
getBufferedReader
(
getInputStream
()
);
return
new
InputStreamReader
(
getInputStream
(),
Constants
.
UTF8
);
}
}
@Override
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/db/TestLob.java
浏览文件 @
5b9781f6
...
@@ -113,6 +113,7 @@ public class TestLob extends TestBase {
...
@@ -113,6 +113,7 @@ public class TestLob extends TestBase {
testLob
(
false
);
testLob
(
false
);
testLob
(
true
);
testLob
(
true
);
testJavaObject
();
testJavaObject
();
testClobWithRandomUnicodeChars
();
deleteDb
(
"lob"
);
deleteDb
(
"lob"
);
FileUtils
.
deleteRecursive
(
TEMP_DIR
,
true
);
FileUtils
.
deleteRecursive
(
TEMP_DIR
,
true
);
}
}
...
@@ -1508,4 +1509,59 @@ public class TestLob extends TestBase {
...
@@ -1508,4 +1509,59 @@ public class TestLob extends TestBase {
conn
.
close
();
conn
.
close
();
}
}
private
void
testClobWithRandomUnicodeChars
()
throws
Exception
{
// This tests an issue we had with storing unicode surrogate pairs, which only
// manifested at the boundaries between blocks i.e. at 4k boundaries
deleteDb
(
"lob"
);
Connection
conn
=
getConnection
(
"lob"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TABLE logs(id int primary key auto_increment, message CLOB)"
);
PreparedStatement
s1
=
conn
.
prepareStatement
(
"INSERT INTO logs (id, message) VALUES(null, ?)"
);
final
Random
rand
=
new
Random
();
for
(
int
i
=
1
;
i
<=
100
;
i
++)
{
String
data
=
randomUnicodeString
(
rand
);
s1
.
setString
(
1
,
data
);
s1
.
executeUpdate
();
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT id, message FROM logs ORDER BY id DESC LIMIT 1"
);
rs
.
next
();
String
read
=
rs
.
getString
(
2
);
assertEquals
(
read
,
data
);
}
conn
.
close
();
}
private
static
String
randomUnicodeString
(
Random
rand
)
{
int
count
=
10000
;
final
char
[]
buffer
=
new
char
[
count
];
while
(
count
--
!=
0
)
{
char
ch
=
(
char
)
rand
.
nextInt
();
if
(
ch
>=
56320
&&
ch
<=
57343
)
{
if
(
count
==
0
)
{
count
++;
}
else
{
// low surrogate, insert high surrogate after putting it
// in
buffer
[
count
]
=
ch
;
count
--;
buffer
[
count
]
=
(
char
)
(
55296
+
rand
.
nextInt
(
128
));
}
}
else
if
(
ch
>=
55296
&&
ch
<=
56191
)
{
if
(
count
==
0
)
{
count
++;
}
else
{
// high surrogate, insert low surrogate before putting
// it in
buffer
[
count
]
=
(
char
)
(
56320
+
rand
.
nextInt
(
128
));
count
--;
buffer
[
count
]
=
ch
;
}
}
else
if
(
ch
>=
56192
&&
ch
<=
56319
)
{
// private high surrogate, no effing clue, so skip it
count
++;
}
else
{
buffer
[
count
]
=
ch
;
}
}
return
new
String
(
buffer
);
}
}
}
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论