Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
bbb45884
Unverified
提交
bbb45884
authored
1月 15, 2018
作者:
Prashant Bhat
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make use of try-with-resources statement
上级
969f44a9
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
16 行增加
和
47 行删除
+16
-47
RunScript.java
h2/src/main/org/h2/tools/RunScript.java
+1
-4
ValueLobDb.java
h2/src/main/org/h2/value/ValueLobDb.java
+1
-4
TestMergeUsing.java
h2/src/test/org/h2/test/db/TestMergeUsing.java
+5
-11
TestSpatial.java
h2/src/test/org/h2/test/db/TestSpatial.java
+2
-5
TestBtreeIndex.java
h2/src/test/org/h2/test/synth/TestBtreeIndex.java
+1
-4
TestValue.java
h2/src/test/org/h2/test/unit/TestValue.java
+2
-6
SwitchSource.java
h2/src/tools/org/h2/build/code/SwitchSource.java
+1
-4
PropertiesToUTF8.java
h2/src/tools/org/h2/build/i18n/PropertiesToUTF8.java
+2
-5
ArchiveToolStore.java
h2/src/tools/org/h2/dev/fs/ArchiveToolStore.java
+1
-4
没有找到文件。
h2/src/main/org/h2/tools/RunScript.java
浏览文件 @
bbb45884
...
@@ -322,14 +322,11 @@ public class RunScript extends Tool {
...
@@ -322,14 +322,11 @@ public class RunScript extends Tool {
boolean
continueOnError
)
throws
SQLException
{
boolean
continueOnError
)
throws
SQLException
{
try
{
try
{
org
.
h2
.
Driver
.
load
();
org
.
h2
.
Driver
.
load
();
Connection
conn
=
DriverManager
.
getConnection
(
url
,
user
,
password
);
if
(
charset
==
null
)
{
if
(
charset
==
null
)
{
charset
=
StandardCharsets
.
UTF_8
;
charset
=
StandardCharsets
.
UTF_8
;
}
}
try
{
try
(
Connection
conn
=
DriverManager
.
getConnection
(
url
,
user
,
password
))
{
process
(
conn
,
fileName
,
continueOnError
,
charset
);
process
(
conn
,
fileName
,
continueOnError
,
charset
);
}
finally
{
conn
.
close
();
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
DbException
.
convertIOException
(
e
,
fileName
);
throw
DbException
.
convertIOException
(
e
,
fileName
);
...
...
h2/src/main/org/h2/value/ValueLobDb.java
浏览文件 @
bbb45884
...
@@ -133,10 +133,9 @@ public class ValueLobDb extends Value implements Value.ValueClob,
...
@@ -133,10 +133,9 @@ public class ValueLobDb extends Value implements Value.ValueClob,
this
.
fileName
=
createTempLobFileName
(
handler
);
this
.
fileName
=
createTempLobFileName
(
handler
);
this
.
tempFile
=
this
.
handler
.
openFile
(
fileName
,
"rw"
,
false
);
this
.
tempFile
=
this
.
handler
.
openFile
(
fileName
,
"rw"
,
false
);
this
.
tempFile
.
autoDelete
();
this
.
tempFile
.
autoDelete
();
FileStoreOutputStream
out
=
new
FileStoreOutputStream
(
tempFile
,
null
,
null
);
long
tmpPrecision
=
0
;
long
tmpPrecision
=
0
;
boolean
compress
=
this
.
handler
.
getLobCompressionAlgorithm
(
Value
.
BLOB
)
!=
null
;
boolean
compress
=
this
.
handler
.
getLobCompressionAlgorithm
(
Value
.
BLOB
)
!=
null
;
try
{
try
(
FileStoreOutputStream
out
=
new
FileStoreOutputStream
(
tempFile
,
null
,
null
))
{
while
(
true
)
{
while
(
true
)
{
tmpPrecision
+=
len
;
tmpPrecision
+=
len
;
out
.
write
(
buff
,
0
,
len
);
out
.
write
(
buff
,
0
,
len
);
...
@@ -150,8 +149,6 @@ public class ValueLobDb extends Value implements Value.ValueClob,
...
@@ -150,8 +149,6 @@ public class ValueLobDb extends Value implements Value.ValueClob,
break
;
break
;
}
}
}
}
}
finally
{
out
.
close
();
}
}
this
.
precision
=
tmpPrecision
;
this
.
precision
=
tmpPrecision
;
this
.
tableId
=
0
;
this
.
tableId
=
0
;
...
...
h2/src/test/org/h2/test/db/TestMergeUsing.java
浏览文件 @
bbb45884
...
@@ -286,22 +286,17 @@ public class TestMergeUsing extends TestBase implements Trigger {
...
@@ -286,22 +286,17 @@ public class TestMergeUsing extends TestBase implements Trigger {
String
gatherResultsSQL
,
String
expectedResultsSQL
,
String
gatherResultsSQL
,
String
expectedResultsSQL
,
int
expectedRowUpdateCount
)
throws
Exception
{
int
expectedRowUpdateCount
)
throws
Exception
{
deleteDb
(
"mergeUsingQueries"
);
deleteDb
(
"mergeUsingQueries"
);
Connection
conn
=
getConnection
(
"mergeUsingQueries"
);
Statement
stat
;
PreparedStatement
prep
;
ResultSet
rs
;
int
rowCountUpdate
;
try
{
try
(
Connection
conn
=
getConnection
(
"mergeUsingQueries"
))
{
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
setupSQL
);
stat
.
execute
(
setupSQL
);
prep
=
conn
.
prepareStatement
(
statementUnderTest
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
statementUnderTest
);
rowCountUpdate
=
prep
.
executeUpdate
();
int
rowCountUpdate
=
prep
.
executeUpdate
();
// compare actual results from SQL result set with expected results
// compare actual results from SQL result set with expected results
// - by diffing (aka set MINUS operation)
// - by diffing (aka set MINUS operation)
rs
=
stat
.
executeQuery
(
"( "
+
gatherResultsSQL
+
" ) MINUS ( "
ResultSet
rs
=
stat
.
executeQuery
(
"( "
+
gatherResultsSQL
+
" ) MINUS ( "
+
expectedResultsSQL
+
" )"
);
+
expectedResultsSQL
+
" )"
);
int
rowCount
=
0
;
int
rowCount
=
0
;
...
@@ -319,7 +314,6 @@ public class TestMergeUsing extends TestBase implements Trigger {
...
@@ -319,7 +314,6 @@ public class TestMergeUsing extends TestBase implements Trigger {
assertEquals
(
"Expected update counts differ"
,
assertEquals
(
"Expected update counts differ"
,
expectedRowUpdateCount
,
rowCountUpdate
);
expectedRowUpdateCount
,
rowCountUpdate
);
}
finally
{
}
finally
{
conn
.
close
();
deleteDb
(
"mergeUsingQueries"
);
deleteDb
(
"mergeUsingQueries"
);
}
}
}
}
...
...
h2/src/test/org/h2/test/db/TestSpatial.java
浏览文件 @
bbb45884
...
@@ -877,15 +877,12 @@ public class TestSpatial extends TestBase {
...
@@ -877,15 +877,12 @@ public class TestSpatial extends TestBase {
"SELECT null, CONCAT('POINT(',A.X,' ',B.X,')')::geometry the_geom "
+
"SELECT null, CONCAT('POINT(',A.X,' ',B.X,')')::geometry the_geom "
+
"from system_range(0,120) A,system_range(0,10) B;"
);
"from system_range(0,120) A,system_range(0,10) B;"
);
stat
.
execute
(
"create spatial index on pt_cloud(the_geom);"
);
stat
.
execute
(
"create spatial index on pt_cloud(the_geom);"
);
ResultSet
rs
=
stat
.
executeQuery
(
try
(
ResultSet
rs
=
stat
.
executeQuery
(
"explain select * from PT_CLOUD "
+
"explain select * from PT_CLOUD "
+
"where the_geom && 'POINT(1 1)'"
);
"where the_geom && 'POINT(1 1)'"
))
{
try
{
assertTrue
(
rs
.
next
());
assertTrue
(
rs
.
next
());
assertFalse
(
"H2 should use spatial index got this explain:\n"
+
assertFalse
(
"H2 should use spatial index got this explain:\n"
+
rs
.
getString
(
1
),
rs
.
getString
(
1
).
contains
(
"tableScan"
));
rs
.
getString
(
1
),
rs
.
getString
(
1
).
contains
(
"tableScan"
));
}
finally
{
rs
.
close
();
}
}
}
}
deleteDb
(
"spatial"
);
deleteDb
(
"spatial"
);
...
...
h2/src/test/org/h2/test/synth/TestBtreeIndex.java
浏览文件 @
bbb45884
...
@@ -102,8 +102,7 @@ public class TestBtreeIndex extends TestBase {
...
@@ -102,8 +102,7 @@ public class TestBtreeIndex extends TestBase {
}
}
String
prefix
=
buff
.
toString
().
substring
(
0
,
prefixLength
);
String
prefix
=
buff
.
toString
().
substring
(
0
,
prefixLength
);
DeleteDbFiles
.
execute
(
getBaseDir
()
+
"/"
+
getTestName
(),
null
,
true
);
DeleteDbFiles
.
execute
(
getBaseDir
()
+
"/"
+
getTestName
(),
null
,
true
);
Connection
conn
=
getConnection
(
getTestName
());
try
(
Connection
conn
=
getConnection
(
getTestName
()))
{
try
{
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TABLE a(text VARCHAR PRIMARY KEY)"
);
stat
.
execute
(
"CREATE TABLE a(text VARCHAR PRIMARY KEY)"
);
PreparedStatement
prepInsert
=
conn
.
prepareStatement
(
PreparedStatement
prepInsert
=
conn
.
prepareStatement
(
...
@@ -189,8 +188,6 @@ public class TestBtreeIndex extends TestBase {
...
@@ -189,8 +188,6 @@ public class TestBtreeIndex extends TestBase {
if
(
rs
.
next
())
{
if
(
rs
.
next
())
{
printError
(
seed
,
"testCount:"
+
testCount
+
" "
+
rs
.
getString
(
1
));
printError
(
seed
,
"testCount:"
+
testCount
+
" "
+
rs
.
getString
(
1
));
}
}
}
finally
{
conn
.
close
();
}
}
deleteDb
(
getTestName
());
deleteDb
(
getTestName
());
}
}
...
...
h2/src/test/org/h2/test/unit/TestValue.java
浏览文件 @
bbb45884
...
@@ -121,8 +121,7 @@ public class TestValue extends TestBase {
...
@@ -121,8 +121,7 @@ public class TestValue extends TestBase {
}
}
private
void
testBinaryAndUuid
()
throws
SQLException
{
private
void
testBinaryAndUuid
()
throws
SQLException
{
Connection
conn
=
getConnection
(
"binaryAndUuid"
);
try
(
Connection
conn
=
getConnection
(
"binaryAndUuid"
))
{
try
{
UUID
uuid
=
UUID
.
randomUUID
();
UUID
uuid
=
UUID
.
randomUUID
();
PreparedStatement
prep
;
PreparedStatement
prep
;
ResultSet
rs
;
ResultSet
rs
;
...
@@ -139,7 +138,6 @@ public class TestValue extends TestBase {
...
@@ -139,7 +138,6 @@ public class TestValue extends TestBase {
rs
.
next
();
rs
.
next
();
assertEquals
(
uuid
,
rs
.
getObject
(
1
));
assertEquals
(
uuid
,
rs
.
getObject
(
1
));
}
finally
{
}
finally
{
conn
.
close
();
deleteDb
(
"binaryAndUuid"
);
deleteDb
(
"binaryAndUuid"
);
}
}
}
}
...
@@ -356,13 +354,11 @@ public class TestValue extends TestBase {
...
@@ -356,13 +354,11 @@ public class TestValue extends TestBase {
}
}
private
void
testModulusOperator
()
throws
SQLException
{
private
void
testModulusOperator
()
throws
SQLException
{
Connection
conn
=
getConnection
(
"modulus"
);
try
(
Connection
conn
=
getConnection
(
"modulus"
))
{
try
{
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"CALL 12 % 10"
);
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"CALL 12 % 10"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
2
,
rs
.
getInt
(
1
));
assertEquals
(
2
,
rs
.
getInt
(
1
));
}
finally
{
}
finally
{
conn
.
close
();
deleteDb
(
"modulus"
);
deleteDb
(
"modulus"
);
}
}
}
}
...
...
h2/src/tools/org/h2/build/code/SwitchSource.java
浏览文件 @
bbb45884
...
@@ -100,17 +100,14 @@ public class SwitchSource {
...
@@ -100,17 +100,14 @@ public class SwitchSource {
}
}
private
void
processFile
(
File
f
)
throws
IOException
{
private
void
processFile
(
File
f
)
throws
IOException
{
RandomAccessFile
read
=
new
RandomAccessFile
(
f
,
"r"
);
byte
[]
buffer
;
byte
[]
buffer
;
try
{
try
(
RandomAccessFile
read
=
new
RandomAccessFile
(
f
,
"r"
))
{
long
len
=
read
.
length
();
long
len
=
read
.
length
();
if
(
len
>=
Integer
.
MAX_VALUE
)
{
if
(
len
>=
Integer
.
MAX_VALUE
)
{
throw
new
IOException
(
"Files bigger than Integer.MAX_VALUE are not supported"
);
throw
new
IOException
(
"Files bigger than Integer.MAX_VALUE are not supported"
);
}
}
buffer
=
new
byte
[(
int
)
len
];
buffer
=
new
byte
[(
int
)
len
];
read
.
readFully
(
buffer
);
read
.
readFully
(
buffer
);
}
finally
{
read
.
close
();
}
}
boolean
found
=
false
;
boolean
found
=
false
;
// check for ## without creating a string
// check for ## without creating a string
...
...
h2/src/tools/org/h2/build/i18n/PropertiesToUTF8.java
浏览文件 @
bbb45884
...
@@ -79,9 +79,8 @@ public class PropertiesToUTF8 {
...
@@ -79,9 +79,8 @@ public class PropertiesToUTF8 {
if
(!
new
File
(
source
).
exists
())
{
if
(!
new
File
(
source
).
exists
())
{
return
;
return
;
}
}
LineNumberReader
reader
=
new
LineNumberReader
(
new
InputStreamReader
(
try
(
LineNumberReader
reader
=
new
LineNumberReader
(
new
InputStreamReader
(
new
FileInputStream
(
source
),
StandardCharsets
.
UTF_8
));
new
FileInputStream
(
source
),
StandardCharsets
.
UTF_8
)))
{
try
{
SortedProperties
prop
=
new
SortedProperties
();
SortedProperties
prop
=
new
SortedProperties
();
StringBuilder
buff
=
new
StringBuilder
();
StringBuilder
buff
=
new
StringBuilder
();
String
key
=
null
;
String
key
=
null
;
...
@@ -113,8 +112,6 @@ public class PropertiesToUTF8 {
...
@@ -113,8 +112,6 @@ public class PropertiesToUTF8 {
prop
.
setProperty
(
key
,
buff
.
toString
());
prop
.
setProperty
(
key
,
buff
.
toString
());
}
}
prop
.
store
(
target
);
prop
.
store
(
target
);
}
finally
{
reader
.
close
();
}
}
}
}
...
...
h2/src/tools/org/h2/dev/fs/ArchiveToolStore.java
浏览文件 @
bbb45884
...
@@ -101,8 +101,7 @@ public class ArchiveToolStore {
...
@@ -101,8 +101,7 @@ public class ArchiveToolStore {
buff
.
clear
();
buff
.
clear
();
buff
.
flip
();
buff
.
flip
();
ArrayList
<
Integer
>
posList
=
new
ArrayList
<>();
ArrayList
<
Integer
>
posList
=
new
ArrayList
<>();
FileChannel
fc
=
FileUtils
.
open
(
s
,
"r"
);
try
(
FileChannel
fc
=
FileUtils
.
open
(
s
,
"r"
))
{
try
{
boolean
eof
=
false
;
boolean
eof
=
false
;
while
(
true
)
{
while
(
true
)
{
while
(!
eof
&&
buff
.
remaining
()
<
512
*
1024
)
{
while
(!
eof
&&
buff
.
remaining
()
<
512
*
1024
)
{
...
@@ -153,8 +152,6 @@ public class ArchiveToolStore {
...
@@ -153,8 +152,6 @@ public class ArchiveToolStore {
}
}
printProgress
(
0
,
50
,
currentSize
,
totalSize
);
printProgress
(
0
,
50
,
currentSize
,
totalSize
);
}
}
}
finally
{
fc
.
close
();
}
}
int
[]
posArray
=
new
int
[
posList
.
size
()];
int
[]
posArray
=
new
int
[
posList
.
size
()];
for
(
int
i
=
0
;
i
<
posList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
posList
.
size
();
i
++)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论