Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
dc9a0ee7
提交
dc9a0ee7
authored
1月 09, 2018
作者:
perhuss
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'upstream/master'
上级
e41fad44
fde86985
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
135 行增加
和
23 行删除
+135
-23
FakeFileChannel.java
h2/src/main/org/h2/store/fs/FakeFileChannel.java
+104
-0
FilePathMem.java
h2/src/main/org/h2/store/fs/FilePathMem.java
+1
-2
FilePathNioMem.java
h2/src/main/org/h2/store/fs/FilePathNioMem.java
+1
-2
FilePathZip.java
h2/src/main/org/h2/store/fs/FilePathZip.java
+1
-2
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+10
-0
degrees.sql
...rc/test/org/h2/test/scripts/functions/numeric/degrees.sql
+8
-7
radians.sql
...rc/test/org/h2/test/scripts/functions/numeric/radians.sql
+8
-7
FilePathZip2.java
h2/src/tools/org/h2/dev/fs/FilePathZip2.java
+2
-3
没有找到文件。
h2/src/main/org/h2/store/fs/FakeFileChannel.java
0 → 100644
浏览文件 @
dc9a0ee7
/*
* Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
store
.
fs
;
import
java.io.IOException
;
import
java.nio.ByteBuffer
;
import
java.nio.MappedByteBuffer
;
import
java.nio.channels.FileChannel
;
import
java.nio.channels.FileLock
;
import
java.nio.channels.ReadableByteChannel
;
import
java.nio.channels.WritableByteChannel
;
/**
* Fake file channel to use by in-memory and ZIP file systems.
*/
public
class
FakeFileChannel
extends
FileChannel
{
@Override
protected
void
implCloseChannel
()
throws
IOException
{
throw
new
IOException
();
}
@Override
public
FileLock
lock
(
long
position
,
long
size
,
boolean
shared
)
throws
IOException
{
throw
new
IOException
();
}
@Override
public
MappedByteBuffer
map
(
MapMode
mode
,
long
position
,
long
size
)
throws
IOException
{
throw
new
IOException
();
}
@Override
public
long
position
()
throws
IOException
{
throw
new
IOException
();
}
@Override
public
FileChannel
position
(
long
newPosition
)
throws
IOException
{
throw
new
IOException
();
}
@Override
public
int
read
(
ByteBuffer
dst
)
throws
IOException
{
throw
new
IOException
();
}
@Override
public
int
read
(
ByteBuffer
dst
,
long
position
)
throws
IOException
{
throw
new
IOException
();
}
@Override
public
long
read
(
ByteBuffer
[]
dsts
,
int
offset
,
int
length
)
throws
IOException
{
throw
new
IOException
();
}
@Override
public
long
size
()
throws
IOException
{
throw
new
IOException
();
}
@Override
public
long
transferFrom
(
ReadableByteChannel
src
,
long
position
,
long
count
)
throws
IOException
{
throw
new
IOException
();
}
@Override
public
long
transferTo
(
long
position
,
long
count
,
WritableByteChannel
target
)
throws
IOException
{
throw
new
IOException
();
}
@Override
public
FileChannel
truncate
(
long
size
)
throws
IOException
{
throw
new
IOException
();
}
@Override
public
FileLock
tryLock
(
long
position
,
long
size
,
boolean
shared
)
throws
IOException
{
throw
new
IOException
();
}
@Override
public
int
write
(
ByteBuffer
src
)
throws
IOException
{
throw
new
IOException
();
}
@Override
public
int
write
(
ByteBuffer
src
,
long
position
)
throws
IOException
{
throw
new
IOException
();
}
@Override
public
long
write
(
ByteBuffer
[]
srcs
,
int
offset
,
int
len
)
throws
IOException
{
throw
new
IOException
();
}
@Override
public
void
force
(
boolean
metaData
)
throws
IOException
{
throw
new
IOException
();
}
}
\ No newline at end of file
h2/src/main/org/h2/store/fs/FilePathMem.java
浏览文件 @
dc9a0ee7
...
@@ -392,8 +392,7 @@ class FileMem extends FileBase {
...
@@ -392,8 +392,7 @@ class FileMem extends FileBase {
}
}
}
}
// cast to FileChannel to avoid JDK 1.7 ambiguity
FileLock
lock
=
new
FileLock
(
new
FakeFileChannel
(),
position
,
size
,
shared
)
{
FileLock
lock
=
new
FileLock
((
FileChannel
)
null
,
position
,
size
,
shared
)
{
@Override
@Override
public
boolean
isValid
()
{
public
boolean
isValid
()
{
...
...
h2/src/main/org/h2/store/fs/FilePathNioMem.java
浏览文件 @
dc9a0ee7
...
@@ -386,8 +386,7 @@ class FileNioMem extends FileBase {
...
@@ -386,8 +386,7 @@ class FileNioMem extends FileBase {
}
}
}
}
// cast to FileChannel to avoid JDK 1.7 ambiguity
FileLock
lock
=
new
FileLock
(
new
FakeFileChannel
(),
position
,
size
,
shared
)
{
FileLock
lock
=
new
FileLock
((
FileChannel
)
null
,
position
,
size
,
shared
)
{
@Override
@Override
public
boolean
isValid
()
{
public
boolean
isValid
()
{
...
...
h2/src/main/org/h2/store/fs/FilePathZip.java
浏览文件 @
dc9a0ee7
...
@@ -354,8 +354,7 @@ class FileZip extends FileBase {
...
@@ -354,8 +354,7 @@ class FileZip extends FileBase {
public
synchronized
FileLock
tryLock
(
long
position
,
long
size
,
public
synchronized
FileLock
tryLock
(
long
position
,
long
size
,
boolean
shared
)
throws
IOException
{
boolean
shared
)
throws
IOException
{
if
(
shared
)
{
if
(
shared
)
{
// cast to FileChannel to avoid JDK 1.7 ambiguity
return
new
FileLock
(
new
FakeFileChannel
(),
position
,
size
,
shared
)
{
return
new
FileLock
((
FileChannel
)
null
,
position
,
size
,
shared
)
{
@Override
@Override
public
boolean
isValid
()
{
public
boolean
isValid
()
{
...
...
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
dc9a0ee7
...
@@ -1498,6 +1498,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -1498,6 +1498,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
assertResult
(
"1979-11-12 08:12:34.56"
,
stat
,
"SELECT X FROM T"
);
assertResult
(
"1979-11-12 08:12:34.56"
,
stat
,
"SELECT X FROM T"
);
assertResult
(
"-100-01-15 14:04:02.12"
,
stat
,
"SELECT X FROM U"
);
assertResult
(
"-100-01-15 14:04:02.12"
,
stat
,
"SELECT X FROM U"
);
String
expected
=
String
.
format
(
"%tb"
,
timestamp1979
).
toUpperCase
();
String
expected
=
String
.
format
(
"%tb"
,
timestamp1979
).
toUpperCase
();
expected
=
stripTrailingPeriod
(
expected
);
assertResult
(
"12-"
+
expected
+
"-79 08.12.34.560000 AM"
,
stat
,
assertResult
(
"12-"
+
expected
+
"-79 08.12.34.560000 AM"
,
stat
,
"SELECT TO_CHAR(X) FROM T"
);
"SELECT TO_CHAR(X) FROM T"
);
assertResult
(
"- / , . ; : text - /"
,
stat
,
assertResult
(
"- / , . ; : text - /"
,
stat
,
...
@@ -1618,6 +1619,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -1618,6 +1619,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
assertResult
(
"11"
,
stat
,
"SELECT TO_CHAR(X, 'mM') FROM T"
);
assertResult
(
"11"
,
stat
,
"SELECT TO_CHAR(X, 'mM') FROM T"
);
assertResult
(
"11"
,
stat
,
"SELECT TO_CHAR(X, 'mm') FROM T"
);
assertResult
(
"11"
,
stat
,
"SELECT TO_CHAR(X, 'mm') FROM T"
);
expected
=
String
.
format
(
"%1$tb"
,
timestamp1979
);
expected
=
String
.
format
(
"%1$tb"
,
timestamp1979
);
expected
=
stripTrailingPeriod
(
expected
);
expected
=
expected
.
substring
(
0
,
1
).
toUpperCase
()
+
expected
.
substring
(
1
);
expected
=
expected
.
substring
(
0
,
1
).
toUpperCase
()
+
expected
.
substring
(
1
);
assertResult
(
expected
.
toUpperCase
(),
stat
,
assertResult
(
expected
.
toUpperCase
(),
stat
,
"SELECT TO_CHAR(X, 'MON') FROM T"
);
"SELECT TO_CHAR(X, 'MON') FROM T"
);
...
@@ -1672,6 +1674,14 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -1672,6 +1674,14 @@ public class TestFunctions extends TestBase implements AggregateFunction {
conn
.
close
();
conn
.
close
();
}
}
String
stripTrailingPeriod
(
String
expected
)
{
// CLDR provider appends period on some locales
int
l
=
expected
.
length
()
-
1
;
if
(
expected
.
charAt
(
l
)
==
'.'
)
expected
=
expected
.
substring
(
0
,
l
);
return
expected
;
}
private
void
testIfNull
()
throws
SQLException
{
private
void
testIfNull
()
throws
SQLException
{
deleteDb
(
"functions"
);
deleteDb
(
"functions"
);
Connection
conn
=
getConnection
(
"functions"
);
Connection
conn
=
getConnection
(
"functions"
);
...
...
h2/src/test/org/h2/test/scripts/functions/numeric/degrees.sql
浏览文件 @
dc9a0ee7
...
@@ -9,11 +9,12 @@ create memory table test(id int primary key, name varchar(255));
...
@@ -9,11 +9,12 @@ create memory table test(id int primary key, name varchar(255));
insert
into
test
values
(
1
,
'Hello'
);
insert
into
test
values
(
1
,
'Hello'
);
>
update
count
:
1
>
update
count
:
1
select
degrees
(
null
)
vn
,
degrees
(
1
)
v1
,
degrees
(
1
.
1
)
v2
,
degrees
(
-
1
.
1
)
v3
,
degrees
(
1
.
9
)
v4
,
degrees
(
-
1
.
9
)
v5
from
test
;
-- Truncate least significant digits because implementations returns slightly
-- different results depending on Java version
select
degrees
(
null
)
vn
,
truncate
(
degrees
(
1
),
10
)
v1
,
truncate
(
degrees
(
1
.
1
),
10
)
v2
,
truncate
(
degrees
(
-
1
.
1
),
10
)
v3
,
truncate
(
degrees
(
1
.
9
),
10
)
v4
,
truncate
(
degrees
(
-
1
.
9
),
10
)
v5
from
test
;
>
VN
V1
V2
V3
V4
V5
>
VN
V1
V2
V3
V4
V5
>
---- ------------
----- ----------------- ------------------ ------------------ ----
---------------
>
---- ------------
------------- -------------- --------------
---------------
>
null
57
.
295779513
08232
63
.
02535746439057
-
63
.
02535746439057
108
.
86198107485642
-
108
.
86198107485642
>
null
57
.
295779513
63
.
0253574643
-
63
.
0253574643
108
.
8619810748
-
108
.
8619810748
>
rows
:
1
>
rows
:
1
h2/src/test/org/h2/test/scripts/functions/numeric/radians.sql
浏览文件 @
dc9a0ee7
...
@@ -9,11 +9,12 @@ create memory table test(id int primary key, name varchar(255));
...
@@ -9,11 +9,12 @@ create memory table test(id int primary key, name varchar(255));
insert
into
test
values
(
1
,
'Hello'
);
insert
into
test
values
(
1
,
'Hello'
);
>
update
count
:
1
>
update
count
:
1
select
radians
(
null
)
vn
,
radians
(
1
)
v1
,
radians
(
1
.
1
)
v2
,
radians
(
-
1
.
1
)
v3
,
radians
(
1
.
9
)
v4
,
radians
(
-
1
.
9
)
v5
from
test
;
-- Truncate least significant digits because implementations returns slightly
-- different results depending on Java version
select
radians
(
null
)
vn
,
truncate
(
radians
(
1
),
10
)
v1
,
truncate
(
radians
(
1
.
1
),
10
)
v2
,
truncate
(
radians
(
-
1
.
1
),
10
)
v3
,
truncate
(
radians
(
1
.
9
),
10
)
v4
,
truncate
(
radians
(
-
1
.
9
),
10
)
v5
from
test
;
>
VN
V1
V2
V3
V4
V5
>
VN
V1
V2
V3
V4
V5
>
---- ------------
-------- -------------------- --------------------- ------------------- -------
-------------
>
---- ------------
------------ ------------- ------------
-------------
>
null
0
.
0174532925
19943295
0
.
019198621771937624
-
0
.
019198621771937624
0
.
03316125578789226
-
0
.
03316125578789226
>
null
0
.
0174532925
0
.
0191986217
-
0
.
0191986217
0
.
0331612557
-
0
.
0331612557
>
rows
:
1
>
rows
:
1
h2/src/tools/org/h2/dev/fs/FilePathZip2.java
浏览文件 @
dc9a0ee7
...
@@ -17,6 +17,7 @@ import java.util.zip.ZipEntry;
...
@@ -17,6 +17,7 @@ import java.util.zip.ZipEntry;
import
java.util.zip.ZipInputStream
;
import
java.util.zip.ZipInputStream
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.store.fs.FakeFileChannel
;
import
org.h2.store.fs.FileBase
;
import
org.h2.store.fs.FileBase
;
import
org.h2.store.fs.FileChannelInputStream
;
import
org.h2.store.fs.FileChannelInputStream
;
import
org.h2.store.fs.FilePath
;
import
org.h2.store.fs.FilePath
;
...
@@ -426,9 +427,7 @@ class FileZip2 extends FileBase {
...
@@ -426,9 +427,7 @@ class FileZip2 extends FileBase {
public
synchronized
FileLock
tryLock
(
long
position
,
long
size
,
public
synchronized
FileLock
tryLock
(
long
position
,
long
size
,
boolean
shared
)
throws
IOException
{
boolean
shared
)
throws
IOException
{
if
(
shared
)
{
if
(
shared
)
{
return
new
FileLock
(
new
FakeFileChannel
(),
position
,
size
,
shared
)
{
// cast to FileChannel to avoid JDK 1.7 ambiguity
return
new
FileLock
((
FileChannel
)
null
,
position
,
size
,
shared
)
{
@Override
@Override
public
boolean
isValid
()
{
public
boolean
isValid
()
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论