Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
e5e6830b
提交
e5e6830b
authored
1月 10, 2007
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
476b0169
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
26 个修改的文件
包含
335 行增加
和
262 行删除
+335
-262
history.html
h2/src/docsrc/html/history.html
+1
-0
Constants.java
h2/src/main/org/h2/engine/Constants.java
+31
-30
Database.java
h2/src/main/org/h2/engine/Database.java
+2
-2
ExpressionColumn.java
h2/src/main/org/h2/expression/ExpressionColumn.java
+4
-1
JdbcDataSource.java
h2/src/main/org/h2/jdbcx/JdbcDataSource.java
+1
-2
Sequence.java
h2/src/main/org/h2/schema/Sequence.java
+1
-1
Recover.java
h2/src/main/org/h2/tools/Recover.java
+8
-3
RunScript.java
h2/src/main/org/h2/tools/RunScript.java
+9
-7
Server.java
h2/src/main/org/h2/tools/Server.java
+10
-9
ByteUtils.java
h2/src/main/org/h2/util/ByteUtils.java
+1
-1
FileUtils.java
h2/src/main/org/h2/util/FileUtils.java
+2
-1
JdbcUtils.java
h2/src/main/org/h2/util/JdbcUtils.java
+11
-0
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+89
-53
TestBase.java
h2/src/test/org/h2/test/TestBase.java
+1
-1
BenchA.java
h2/src/test/org/h2/test/bench/BenchA.java
+2
-2
BenchCThread.java
h2/src/test/org/h2/test/bench/BenchCThread.java
+2
-2
Database.java
h2/src/test/org/h2/test/bench/Database.java
+8
-1
TestPerformance.java
h2/src/test/org/h2/test/bench/TestPerformance.java
+60
-40
TestCloseAtShutdown.java
h2/src/test/org/h2/test/cases/TestCloseAtShutdown.java
+0
-45
Coverage.java
h2/src/test/org/h2/test/coverage/Coverage.java
+1
-2
Profile.java
h2/src/test/org/h2/test/coverage/Profile.java
+55
-36
test.in.txt
h2/src/test/org/h2/test/test.in.txt
+2
-4
testSimple.in.txt
h2/src/test/org/h2/test/testSimple.in.txt
+11
-0
GenerateDoc.java
h2/src/tools/org/h2/tools/doc/GenerateDoc.java
+21
-15
Indexer.java
h2/src/tools/org/h2/tools/indexer/Indexer.java
+1
-1
Page.java
h2/src/tools/org/h2/tools/indexer/Page.java
+1
-3
没有找到文件。
h2/src/docsrc/html/history.html
浏览文件 @
e5e6830b
...
@@ -35,6 +35,7 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
...
@@ -35,6 +35,7 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
<h3>
Version 1.0 (Current)
</h3>
<h3>
Version 1.0 (Current)
</h3>
<h3>
Version 1.0 / TODO
</h3><ul>
<h3>
Version 1.0 / TODO
</h3><ul>
<li>
Selecting a column using the syntax schemaName.tableName.columName did not work in all cases.
<li>
Can now parse timestamps with timezone information (Z or +/-hh:mm) and dates before year 1.
<li>
Can now parse timestamps with timezone information (Z or +/-hh:mm) and dates before year 1.
However dates before year 1 are not formatted correctly (this is a Java problem).
However dates before year 1 are not formatted correctly (this is a Java problem).
<li>
When stopping the TCP server from an application and immediately afterwards staring it again
<li>
When stopping the TCP server from an application and immediately afterwards staring it again
...
...
h2/src/main/org/h2/engine/Constants.java
浏览文件 @
e5e6830b
...
@@ -11,23 +11,24 @@ package org.h2.engine;
...
@@ -11,23 +11,24 @@ package org.h2.engine;
* - System.out > trace messages
* - System.out > trace messages
*
*
* Release checklist
* Release checklist
* - Run FindBugs
* - Update latest version in build.html: http://mirrors.ibiblio.org/pub/mirrors/maven2/com/h2database/h2/
* - Update latest version in build.html: http://mirrors.ibiblio.org/pub/mirrors/maven2/com/h2database/h2/
* - ant jarClient, check jar file size
* - ant jarClient, check jar file size
* -
try c
ompiling with JDK 1.3, 1.4, 1.5 and 1.6
* -
C
ompiling with JDK 1.3, 1.4, 1.5 and 1.6
* set path=C:\Programme\Java\jdk1.6.0\bin;%PATH%
* set path=C:\Programme\Java\jdk1.6.0\bin;%PATH%
* -
c
hange FAQ (next release planned, known bugs)
* -
C
hange FAQ (next release planned, known bugs)
* -
c
heck version, change build number in Constants.java and build.xml
* -
C
heck version, change build number in Constants.java and build.xml
* -
c
heck code coverage
* -
C
heck code coverage
* - No " Message.getInternalError" (must be "throw Message.getInternalError")
* - No " Message.getInternalError" (must be "throw Message.getInternalError")
* - No TODO in the docs
* - No TODO in the docs
* - Run regression test with JDK 1.4 and 1.5
* - Run regression test with JDK 1.4 and 1.5
* - Change version(s) in performance.html; use latest versions of other databases
* - Change version(s) in performance.html; use latest versions of other databases
* - Run 'ant benchmark' (with JDK 1.4 currently)
* - Run 'ant benchmark' (with JDK 1.4 currently)
* -
c
opy the benchmark results and update the performance page and diagram
* -
C
opy the benchmark results and update the performance page and diagram
* (remove rows 2*open/close, 2*executed statement)
* (remove rows 2*open/close, 2*executed statement)
*
*
* -
d
ocumentation: if there are new files, add them to MergeDocs
* -
D
ocumentation: if there are new files, add them to MergeDocs
* -
d
ocumentation: check if all javadoc files are in the index
* -
D
ocumentation: check if all javadoc files are in the index
* - ant docs
* - ant docs
* - PDF (15 min)
* - PDF (15 min)
* - footer
* - footer
...
@@ -35,18 +36,18 @@ package org.h2.engine;
...
@@ -35,18 +36,18 @@ package org.h2.engine;
* - tables (optimal size)
* - tables (optimal size)
* - orphan control, page breaks
* - orphan control, page breaks
* - table of contents
* - table of contents
* -
s
witch off auto-build
* -
S
witch off auto-build
* - ant all
* - ant all
* -
m
ake sure odbc files are the
* -
M
ake sure odbc files are the
* -
m
ake sure the pdf file is there
* -
M
ake sure the pdf file is there
* -
m
ake sure the build files are removed
* -
M
ake sure the build files are removed
* - ant zip
* - ant zip
* -
w
indows installer (nsis)
* -
W
indows installer (nsis)
* -
t
est
* -
T
est
* -
t
est the windows service
* -
T
est the windows service
* - TestSystemExit
* - TestSystemExit
* -
t
est with hibernate
* -
T
est with hibernate
* -
s
can for viruses
* -
S
can for viruses
*
*
* - Send a mail to Google Groups
* - Send a mail to Google Groups
* - newsletter: prepare, send (always send to BCC!!)
* - newsletter: prepare, send (always send to BCC!!)
...
@@ -185,7 +186,7 @@ public class Constants {
...
@@ -185,7 +186,7 @@ public class Constants {
public
static
final
int
ALLOW_LITERALS_ALL
=
2
;
public
static
final
int
ALLOW_LITERALS_ALL
=
2
;
public
static
final
int
DEFAULT_ALLOW_LITERALS
=
ALLOW_LITERALS_ALL
;
public
static
final
int
DEFAULT_ALLOW_LITERALS
=
ALLOW_LITERALS_ALL
;
public
static
boolean
AUTO_CONVERT_LOB_TO_FILES
=
true
;
public
static
final
boolean
AUTO_CONVERT_LOB_TO_FILES
=
true
;
public
static
final
boolean
ALLOW_EMTPY_BTREE_PAGES
=
true
;
public
static
final
boolean
ALLOW_EMTPY_BTREE_PAGES
=
true
;
public
static
final
String
CONN_URL_INTERNAL
=
"jdbc:default:connection"
;
public
static
final
String
CONN_URL_INTERNAL
=
"jdbc:default:connection"
;
public
static
final
String
CONN_URL_COLUMNLIST
=
"jdbc:columnlist:connection"
;
public
static
final
String
CONN_URL_COLUMNLIST
=
"jdbc:columnlist:connection"
;
...
@@ -205,28 +206,28 @@ public class Constants {
...
@@ -205,28 +206,28 @@ public class Constants {
// for testing only
// for testing only
public
static
int
CACHE_MIN_RECORDS
=
16
;
public
static
int
CACHE_MIN_RECORDS
=
16
;
public
static
int
MIN_WRITE_DELAY
=
getIntSetting
(
"h2.minWriteDelay"
,
5
);
public
static
final
int
MIN_WRITE_DELAY
=
getIntSetting
(
"h2.minWriteDelay"
,
5
);
public
static
boolean
CHECK
=
getBooleanSetting
(
"h2.check"
,
true
);
public
static
boolean
CHECK
=
getBooleanSetting
(
"h2.check"
,
true
);
public
static
boolean
CHECK2
=
getBooleanSetting
(
"h2.check2"
,
false
);
public
static
final
boolean
CHECK2
=
getBooleanSetting
(
"h2.check2"
,
false
);
// TODO: also remove DataHandler.allocateObjectId, createTempFile when setting this to true and removing it
// TODO: also remove DataHandler.allocateObjectId, createTempFile when setting this to true and removing it
public
static
boolean
LOB_FILES_IN_DIRECTORIES
=
getBooleanSetting
(
"h2.lobFilesInDirectories"
,
false
);
public
static
final
boolean
LOB_FILES_IN_DIRECTORIES
=
getBooleanSetting
(
"h2.lobFilesInDirectories"
,
false
);
public
static
int
LOB_FILES_PER_DIRECTORY
=
getIntSetting
(
"h2.lobFilesPerDirectory"
,
256
);
public
static
final
int
LOB_FILES_PER_DIRECTORY
=
getIntSetting
(
"h2.lobFilesPerDirectory"
,
256
);
public
static
boolean
MULTI_THREADED_KERNEL
=
getBooleanSetting
(
"h2.multiThreadedKernel"
,
false
);
public
static
boolean
MULTI_THREADED_KERNEL
=
getBooleanSetting
(
"h2.multiThreadedKernel"
,
false
);
public
static
boolean
RUN_FINALIZERS
=
getBooleanSetting
(
"h2.runFinalizers"
,
true
);
public
static
boolean
RUN_FINALIZERS
=
getBooleanSetting
(
"h2.runFinalizers"
,
true
);
public
static
boolean
OPTIMIZE_MIN_MAX
=
getBooleanSetting
(
"h2.optimizeMinMax"
,
true
);
public
static
final
boolean
OPTIMIZE_MIN_MAX
=
getBooleanSetting
(
"h2.optimizeMinMax"
,
true
);
public
static
boolean
OPTIMIZE_IN
=
getBooleanSetting
(
"h2.optimizeIn"
,
true
);
public
static
final
boolean
OPTIMIZE_IN
=
getBooleanSetting
(
"h2.optimizeIn"
,
true
);
public
static
int
REDO_BUFFER_SIZE
=
getIntSetting
(
"h2.redoBufferSize"
,
256
*
1024
);
public
static
final
int
REDO_BUFFER_SIZE
=
getIntSetting
(
"h2.redoBufferSize"
,
256
*
1024
);
public
static
boolean
RECOMPILE_ALWAYS
=
getBooleanSetting
(
"h2.recompileAlways"
,
false
);
public
static
final
boolean
RECOMPILE_ALWAYS
=
getBooleanSetting
(
"h2.recompileAlways"
,
false
);
public
static
boolean
OPTIMIZE_SUBQUERY_CACHE
=
getBooleanSetting
(
"h2.optimizeSubqueryCache"
,
true
);
public
static
final
boolean
OPTIMIZE_SUBQUERY_CACHE
=
getBooleanSetting
(
"h2.optimizeSubqueryCache"
,
true
);
public
static
boolean
OVERFLOW_EXCEPTIONS
=
getBooleanSetting
(
"h2.overflowExceptions"
,
true
);
public
static
final
boolean
OVERFLOW_EXCEPTIONS
=
getBooleanSetting
(
"h2.overflowExceptions"
,
true
);
public
static
boolean
LOG_ALL_ERRORS
=
getBooleanSetting
(
"h2.logAllErrors"
,
false
);
public
static
final
boolean
LOG_ALL_ERRORS
=
getBooleanSetting
(
"h2.logAllErrors"
,
false
);
public
static
String
LOG_ALL_ERRORS_FILE
=
getStringSetting
(
"h2.logAllErrorsFile"
,
"h2errors.txt"
);
public
static
final
String
LOG_ALL_ERRORS_FILE
=
getStringSetting
(
"h2.logAllErrorsFile"
,
"h2errors.txt"
);
public
static
int
SERVER_CACHED_OBJECTS
=
getIntSetting
(
"h2.serverCachedObjects"
,
64
);
public
static
final
int
SERVER_CACHED_OBJECTS
=
getIntSetting
(
"h2.serverCachedObjects"
,
64
);
public
static
final
int
SERVER_SMALL_RESULTSET_SIZE
=
getIntSetting
(
"h2.serverSmallResultSetSize"
,
100
);
public
static
final
int
SERVER_SMALL_RESULTSET_SIZE
=
getIntSetting
(
"h2.serverSmallResultSetSize"
,
100
);
public
static
final
int
EMERGENCY_SPACE_INITIAL
=
getIntSetting
(
"h2.emergencySpaceInitial"
,
1
*
1024
*
1024
);
public
static
final
int
EMERGENCY_SPACE_INITIAL
=
getIntSetting
(
"h2.emergencySpaceInitial"
,
1
*
1024
*
1024
);
public
static
final
int
EMERGENCY_SPACE_MIN
=
getIntSetting
(
"h2.emergencySpaceMin"
,
128
*
1024
);
public
static
final
int
EMERGENCY_SPACE_MIN
=
getIntSetting
(
"h2.emergencySpaceMin"
,
128
*
1024
);
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
e5e6830b
...
@@ -1314,7 +1314,7 @@ public class Database implements DataHandler {
...
@@ -1314,7 +1314,7 @@ public class Database implements DataHandler {
return
lockMode
;
return
lockMode
;
}
}
public
void
setCloseDelay
(
int
value
)
{
public
synchronized
void
setCloseDelay
(
int
value
)
{
this
.
closeDelay
=
value
;
this
.
closeDelay
=
value
;
}
}
...
@@ -1416,7 +1416,7 @@ public class Database implements DataHandler {
...
@@ -1416,7 +1416,7 @@ public class Database implements DataHandler {
return
ignoreCase
;
return
ignoreCase
;
}
}
public
void
setDeleteFilesOnDisconnect
(
boolean
b
)
{
public
synchronized
void
setDeleteFilesOnDisconnect
(
boolean
b
)
{
this
.
deleteFilesOnDisconnect
=
b
;
this
.
deleteFilesOnDisconnect
=
b
;
}
}
...
...
h2/src/main/org/h2/expression/ExpressionColumn.java
浏览文件 @
e5e6830b
...
@@ -9,6 +9,7 @@ import java.util.HashMap;
...
@@ -9,6 +9,7 @@ import java.util.HashMap;
import
org.h2.command.Parser
;
import
org.h2.command.Parser
;
import
org.h2.command.dml.Select
;
import
org.h2.command.dml.Select
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Database
;
import
org.h2.engine.Database
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.message.Message
;
import
org.h2.message.Message
;
...
@@ -44,6 +45,7 @@ public class ExpressionColumn extends Expression {
...
@@ -44,6 +45,7 @@ public class ExpressionColumn extends Expression {
public
ExpressionColumn
(
Database
database
,
Select
select
,
String
schemaName
,
String
tableAlias
,
String
columnName
)
{
public
ExpressionColumn
(
Database
database
,
Select
select
,
String
schemaName
,
String
tableAlias
,
String
columnName
)
{
this
.
database
=
database
;
this
.
database
=
database
;
this
.
select
=
select
;
this
.
select
=
select
;
this
.
schemaName
=
schemaName
;
this
.
tableAlias
=
tableAlias
;
this
.
tableAlias
=
tableAlias
;
this
.
columnName
=
columnName
;
this
.
columnName
=
columnName
;
}
}
...
@@ -58,7 +60,8 @@ public class ExpressionColumn extends Expression {
...
@@ -58,7 +60,8 @@ public class ExpressionColumn extends Expression {
if
(
tableAlias
!=
null
)
{
if
(
tableAlias
!=
null
)
{
sql
=
Parser
.
quoteIdentifier
(
tableAlias
)
+
"."
+
sql
;
sql
=
Parser
.
quoteIdentifier
(
tableAlias
)
+
"."
+
sql
;
}
}
if
(
schemaName
!=
null
)
{
if
(
schemaName
!=
null
&&
!
schemaName
.
equals
(
Constants
.
SCHEMA_MAIN
))
{
int
todoTempSolution
;
sql
=
Parser
.
quoteIdentifier
(
schemaName
)
+
"."
+
sql
;
sql
=
Parser
.
quoteIdentifier
(
schemaName
)
+
"."
+
sql
;
}
}
return
sql
;
return
sql
;
...
...
h2/src/main/org/h2/jdbcx/JdbcDataSource.java
浏览文件 @
e5e6830b
...
@@ -38,7 +38,7 @@ public class JdbcDataSource extends TraceObject implements XADataSource, DataSou
...
@@ -38,7 +38,7 @@ public class JdbcDataSource extends TraceObject implements XADataSource, DataSou
private
static
final
long
serialVersionUID
=
1288136338451857771L
;
private
static
final
long
serialVersionUID
=
1288136338451857771L
;
private
transient
JdbcDataSourceFactory
factory
;
private
transient
JdbcDataSourceFactory
factory
=
new
JdbcDataSourceFactory
()
;
private
transient
PrintWriter
logWriter
;
private
transient
PrintWriter
logWriter
;
private
int
timeout
;
private
int
timeout
;
private
String
user
;
private
String
user
;
...
@@ -46,7 +46,6 @@ public class JdbcDataSource extends TraceObject implements XADataSource, DataSou
...
@@ -46,7 +46,6 @@ public class JdbcDataSource extends TraceObject implements XADataSource, DataSou
private
String
url
;
private
String
url
;
public
JdbcDataSource
()
{
public
JdbcDataSource
()
{
this
.
factory
=
new
JdbcDataSourceFactory
();
int
id
=
getNextId
(
TraceObject
.
DATASOURCE
);
int
id
=
getNextId
(
TraceObject
.
DATASOURCE
);
setTrace
(
factory
.
getTrace
(),
TraceObject
.
DATASOURCE
,
id
);
setTrace
(
factory
.
getTrace
(),
TraceObject
.
DATASOURCE
,
id
);
}
}
...
...
h2/src/main/org/h2/schema/Sequence.java
浏览文件 @
e5e6830b
...
@@ -109,7 +109,7 @@ public class Sequence extends SchemaObject {
...
@@ -109,7 +109,7 @@ public class Sequence extends SchemaObject {
// nothing to do
// nothing to do
}
}
public
long
getCurrentValue
()
{
public
synchronized
long
getCurrentValue
()
{
return
value
-
increment
;
return
value
-
increment
;
}
}
...
...
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
e5e6830b
...
@@ -18,6 +18,8 @@ import java.util.ArrayList;
...
@@ -18,6 +18,8 @@ import java.util.ArrayList;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
org.h2.command.Parser
;
import
org.h2.command.Parser
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
...
@@ -303,13 +305,14 @@ public class Recover implements DataHandler {
...
@@ -303,13 +305,14 @@ public class Recover implements DataHandler {
FileStore
store
=
null
;
FileStore
store
=
null
;
int
size
=
0
;
int
size
=
0
;
String
n
=
fileName
+
(
lobCompression
?
".comp"
:
""
)
+
".txt"
;
String
n
=
fileName
+
(
lobCompression
?
".comp"
:
""
)
+
".txt"
;
InputStream
in
=
null
;
try
{
try
{
out
=
new
FileOutputStream
(
n
);
out
=
new
FileOutputStream
(
n
);
textStorage
=
Database
.
isTextStorage
(
fileName
,
false
);
textStorage
=
Database
.
isTextStorage
(
fileName
,
false
);
byte
[]
magic
=
Database
.
getMagic
(
textStorage
);
byte
[]
magic
=
Database
.
getMagic
(
textStorage
);
store
=
FileStore
.
open
(
null
,
fileName
,
magic
);
store
=
FileStore
.
open
(
null
,
fileName
,
magic
);
store
.
init
();
store
.
init
();
InputStream
in
=
new
BufferedInputStream
(
new
FileStoreInputStream
(
store
,
this
,
lobCompression
));
in
=
new
BufferedInputStream
(
new
FileStoreInputStream
(
store
,
this
,
lobCompression
));
byte
[]
buffer
=
new
byte
[
Constants
.
IO_BUFFER_SIZE
];
byte
[]
buffer
=
new
byte
[
Constants
.
IO_BUFFER_SIZE
];
while
(
true
)
{
while
(
true
)
{
int
l
=
in
.
read
(
buffer
);
int
l
=
in
.
read
(
buffer
);
...
@@ -326,6 +329,7 @@ public class Recover implements DataHandler {
...
@@ -326,6 +329,7 @@ public class Recover implements DataHandler {
}
}
}
finally
{
}
finally
{
IOUtils
.
closeSilently
(
out
);
IOUtils
.
closeSilently
(
out
);
IOUtils
.
closeSilently
(
in
);
closeSilently
(
store
);
closeSilently
(
store
);
}
}
if
(
size
==
0
)
{
if
(
size
==
0
)
{
...
@@ -714,8 +718,9 @@ public class Recover implements DataHandler {
...
@@ -714,8 +718,9 @@ public class Recover implements DataHandler {
writer
.
println
(
m
.
getSQL
()
+
";"
);
writer
.
println
(
m
.
getSQL
()
+
";"
);
}
}
for
(
Iterator
it
=
tableMap
.
keySet
().
iterator
();
it
.
hasNext
();
)
{
for
(
Iterator
it
=
tableMap
.
keySet
().
iterator
();
it
.
hasNext
();
)
{
Integer
objectId
=
(
Integer
)
it
.
next
();
Map
.
Entry
entry
=
(
Entry
)
it
.
next
();
String
name
=
(
String
)
tableMap
.
get
(
objectId
);
Integer
objectId
=
(
Integer
)
entry
.
getKey
();
String
name
=
(
String
)
entry
.
getValue
();
writer
.
println
(
"INSERT INTO "
+
name
+
" SELECT * FROM O_"
+
objectId
+
";"
);
writer
.
println
(
"INSERT INTO "
+
name
+
" SELECT * FROM O_"
+
objectId
+
";"
);
}
}
for
(
Iterator
it
=
objectIdSet
.
iterator
();
it
.
hasNext
();
)
{
for
(
Iterator
it
=
objectIdSet
.
iterator
();
it
.
hasNext
();
)
{
...
...
h2/src/main/org/h2/tools/RunScript.java
浏览文件 @
e5e6830b
...
@@ -21,6 +21,7 @@ import java.util.Iterator;
...
@@ -21,6 +21,7 @@ import java.util.Iterator;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.message.Message
;
import
org.h2.message.Message
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.ScriptReader
;
import
org.h2.util.ScriptReader
;
import
org.h2.util.StringUtils
;
import
org.h2.util.StringUtils
;
...
@@ -215,18 +216,19 @@ public class RunScript {
...
@@ -215,18 +216,19 @@ public class RunScript {
}
}
private
static
void
executeRunscript
(
String
url
,
String
user
,
String
password
,
String
fileName
,
String
options
)
throws
SQLException
{
private
static
void
executeRunscript
(
String
url
,
String
user
,
String
password
,
String
fileName
,
String
options
)
throws
SQLException
{
Connection
conn
=
null
;
Statement
stat
=
null
;
try
{
try
{
org
.
h2
.
Driver
.
load
();
org
.
h2
.
Driver
.
load
();
Connection
conn
=
DriverManager
.
getConnection
(
url
,
user
,
password
);
conn
=
DriverManager
.
getConnection
(
url
,
user
,
password
);
Statement
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
String
sql
=
"RUNSCRIPT FROM '"
+
fileName
+
"' "
+
options
;
String
sql
=
"RUNSCRIPT FROM '"
+
fileName
+
"' "
+
options
;
try
{
stat
.
execute
(
sql
);
stat
.
execute
(
sql
);
}
finally
{
conn
.
close
();
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
Message
.
convert
(
e
);
throw
Message
.
convert
(
e
);
}
finally
{
JdbcUtils
.
closeSilently
(
stat
);
JdbcUtils
.
closeSilently
(
conn
);
}
}
}
}
...
...
h2/src/main/org/h2/tools/Server.java
浏览文件 @
e5e6830b
...
@@ -17,6 +17,7 @@ import org.h2.server.Service;
...
@@ -17,6 +17,7 @@ import org.h2.server.Service;
import
org.h2.server.TcpServer
;
import
org.h2.server.TcpServer
;
import
org.h2.server.ftp.FtpServer
;
import
org.h2.server.ftp.FtpServer
;
import
org.h2.server.web.WebServer
;
import
org.h2.server.web.WebServer
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.StartBrowser
;
import
org.h2.util.StartBrowser
;
...
@@ -230,9 +231,11 @@ public class Server implements Runnable {
...
@@ -230,9 +231,11 @@ public class Server implements Runnable {
throw
Message
.
convert
(
e
);
throw
Message
.
convert
(
e
);
}
}
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
Connection
conn
=
null
;
PreparedStatement
prep
=
null
;
try
{
try
{
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:"
+
url
+
"/"
+
db
,
"sa"
,
password
);
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:"
+
url
+
"/"
+
db
,
"sa"
,
password
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"CALL STOP_SERVER(?, ?, ?)"
);
prep
=
conn
.
prepareStatement
(
"CALL STOP_SERVER(?, ?, ?)"
);
prep
.
setInt
(
1
,
port
);
prep
.
setInt
(
1
,
port
);
prep
.
setString
(
2
,
password
);
prep
.
setString
(
2
,
password
);
prep
.
setInt
(
3
,
force
?
TcpServer
.
SHUTDOWN_FORCE
:
TcpServer
.
SHUTDOWN_NORMAL
);
prep
.
setInt
(
3
,
force
?
TcpServer
.
SHUTDOWN_FORCE
:
TcpServer
.
SHUTDOWN_NORMAL
);
...
@@ -244,18 +247,15 @@ public class Server implements Runnable {
...
@@ -244,18 +247,15 @@ public class Server implements Runnable {
}
else
{
}
else
{
throw
e
;
throw
e
;
}
}
}
finally
{
try
{
conn
.
close
();
}
catch
(
SQLException
e
)
{
// ignore
}
}
}
break
;
break
;
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
if
(
i
==
1
)
{
if
(
i
==
1
)
{
throw
e
;
throw
e
;
}
}
}
finally
{
JdbcUtils
.
closeSilently
(
prep
);
JdbcUtils
.
closeSilently
(
conn
);
}
}
}
}
}
}
...
@@ -338,7 +338,8 @@ public class Server implements Runnable {
...
@@ -338,7 +338,8 @@ public class Server implements Runnable {
private
static
void
wait
(
int
i
)
{
private
static
void
wait
(
int
i
)
{
try
{
try
{
// sleep at most 4096 ms
// sleep at most 4096 ms
Thread
.
sleep
(
i
*
i
);
long
sleep
=
(
long
)
i
*
(
long
)
i
;
Thread
.
sleep
(
sleep
);
}
catch
(
InterruptedException
e
)
{
}
catch
(
InterruptedException
e
)
{
// ignore
// ignore
}
}
...
...
h2/src/main/org/h2/util/ByteUtils.java
浏览文件 @
e5e6830b
...
@@ -48,7 +48,7 @@ public class ByteUtils {
...
@@ -48,7 +48,7 @@ public class ByteUtils {
public
static
byte
[]
convertStringToBytes
(
String
s
)
throws
SQLException
{
public
static
byte
[]
convertStringToBytes
(
String
s
)
throws
SQLException
{
int
len
=
s
.
length
();
int
len
=
s
.
length
();
if
(
len
<
0
||
len
%
2
==
1
)
{
if
(
len
%
2
!=
0
)
{
throw
Message
.
getSQLException
(
Message
.
HEX_STRING_ODD_1
,
s
);
throw
Message
.
getSQLException
(
Message
.
HEX_STRING_ODD_1
,
s
);
}
}
len
/=
2
;
len
/=
2
;
...
...
h2/src/main/org/h2/util/FileUtils.java
浏览文件 @
e5e6830b
...
@@ -233,7 +233,8 @@ public class FileUtils {
...
@@ -233,7 +233,8 @@ public class FileUtils {
}
}
try
{
try
{
// sleep at most 256 ms
// sleep at most 256 ms
Thread
.
sleep
(
i
*
i
);
long
sleep
=
(
long
)
i
*
(
long
)
i
;
Thread
.
sleep
(
sleep
);
}
catch
(
InterruptedException
e
)
{
}
catch
(
InterruptedException
e
)
{
// ignore
// ignore
}
}
...
...
h2/src/main/org/h2/util/JdbcUtils.java
浏览文件 @
e5e6830b
package
org
.
h2
.
util
;
package
org
.
h2
.
util
;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Statement
;
...
@@ -26,4 +27,14 @@ public class JdbcUtils {
...
@@ -26,4 +27,14 @@ public class JdbcUtils {
}
}
}
}
public
static
void
closeSilently
(
ResultSet
rs
)
{
if
(
rs
!=
null
)
{
try
{
rs
.
close
();
}
catch
(
SQLException
e
)
{
// ignore
}
}
}
}
}
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
e5e6830b
差异被折叠。
点击展开。
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
e5e6830b
...
@@ -286,7 +286,7 @@ public abstract class TestBase {
...
@@ -286,7 +286,7 @@ public abstract class TestBase {
for
(
int
i
=
0
;
i
<
a
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
a
.
length
();
i
++)
{
String
s
=
a
.
substring
(
0
,
i
);
String
s
=
a
.
substring
(
0
,
i
);
if
(!
b
.
startsWith
(
s
))
{
if
(!
b
.
startsWith
(
s
))
{
s
=
s
.
substring
(
0
,
i
)
+
"<*>"
+
s
.
substring
(
i
);
a
=
a
.
substring
(
0
,
i
)
+
"<*>"
+
a
.
substring
(
i
);
break
;
break
;
}
}
}
}
...
...
h2/src/test/org/h2/test/bench/BenchA.java
浏览文件 @
e5e6830b
...
@@ -16,8 +16,8 @@ public class BenchA implements Bench {
...
@@ -16,8 +16,8 @@ public class BenchA implements Bench {
private
Database
db
;
private
Database
db
;
private
int
branches
;
private
int
branches
;
private
int
tellers
=
branches
*
20
;
private
int
tellers
;
private
int
accounts
=
branches
*
100
;
private
int
accounts
;
private
int
size
;
private
int
size
;
private
static
final
String
FILLER
=
"abcdefghijklmnopqrstuvwxyz"
;
private
static
final
String
FILLER
=
"abcdefghijklmnopqrstuvwxyz"
;
...
...
h2/src/test/org/h2/test/bench/BenchCThread.java
浏览文件 @
e5e6830b
...
@@ -371,7 +371,7 @@ public class BenchCThread {
...
@@ -371,7 +371,7 @@ public class BenchCThread {
rs
.
next
();
rs
.
next
();
rs
.
getString
(
1
);
// c_first
rs
.
getString
(
1
);
// c_first
rs
.
getString
(
2
);
// c_middle
rs
.
getString
(
2
);
// c_middle
c_last
=
rs
.
getString
(
3
);
rs
.
getString
(
3
);
// c_last
rs
.
getString
(
4
);
// c_street_1
rs
.
getString
(
4
);
// c_street_1
rs
.
getString
(
5
);
// c_street_2
rs
.
getString
(
5
);
// c_street_2
rs
.
getString
(
6
);
// c_city
rs
.
getString
(
6
);
// c_city
...
@@ -499,7 +499,7 @@ public class BenchCThread {
...
@@ -499,7 +499,7 @@ public class BenchCThread {
rs
.
getBigDecimal
(
1
);
// c_balance
rs
.
getBigDecimal
(
1
);
// c_balance
rs
.
getString
(
2
);
// c_first
rs
.
getString
(
2
);
// c_first
rs
.
getString
(
3
);
// c_middle
rs
.
getString
(
3
);
// c_middle
c_last
=
rs
.
getString
(
4
);
rs
.
getString
(
4
);
// c_last
rs
.
close
();
rs
.
close
();
}
}
prep
=
prepare
(
"SELECT MAX(O_ID) "
prep
=
prepare
(
"SELECT MAX(O_ID) "
...
...
h2/src/test/org/h2/test/bench/Database.java
浏览文件 @
e5e6830b
...
@@ -20,6 +20,7 @@ import java.util.StringTokenizer;
...
@@ -20,6 +20,7 @@ import java.util.StringTokenizer;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.tools.Server
;
import
org.h2.tools.Server
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.StringUtils
;
import
org.h2.util.StringUtils
;
class
Database
{
class
Database
{
...
@@ -129,7 +130,13 @@ class Database {
...
@@ -129,7 +130,13 @@ class Database {
Connection
conn
=
DriverManager
.
getConnection
(
url
,
user
,
password
);
Connection
conn
=
DriverManager
.
getConnection
(
url
,
user
,
password
);
if
(
url
.
startsWith
(
"jdbc:derby:"
))
{
if
(
url
.
startsWith
(
"jdbc:derby:"
))
{
// Derby: use higher cache size
// Derby: use higher cache size
conn
.
createStatement
().
execute
(
"CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.storage.pageSize', '8192')"
);
Statement
stat
=
null
;
try
{
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.storage.pageSize', '8192')"
);
}
finally
{
JdbcUtils
.
closeSilently
(
stat
);
}
}
}
return
conn
;
return
conn
;
}
}
...
...
h2/src/test/org/h2/test/bench/TestPerformance.java
浏览文件 @
e5e6830b
...
@@ -10,10 +10,13 @@ import java.sql.Connection;
...
@@ -10,10 +10,13 @@ import java.sql.Connection;
import
java.sql.DriverManager
;
import
java.sql.DriverManager
;
import
java.sql.PreparedStatement
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.ResultSet
;
import
java.sql.Statement
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Properties
;
import
java.util.Properties
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.util.IOUtils
;
import
org.h2.util.JdbcUtils
;
public
class
TestPerformance
{
public
class
TestPerformance
{
...
@@ -29,13 +32,20 @@ public class TestPerformance {
...
@@ -29,13 +32,20 @@ public class TestPerformance {
}
}
private
void
openResults
(
boolean
init
)
throws
Exception
{
private
void
openResults
(
boolean
init
)
throws
Exception
{
Connection
conn
=
getResultConnection
();
Connection
conn
=
null
;
if
(
init
)
{
Statement
stat
=
null
;
conn
.
createStatement
().
execute
(
"DROP TABLE IF EXISTS RESULTS"
);
try
{
conn
=
getResultConnection
();
stat
=
conn
.
createStatement
();
if
(
init
)
{
stat
.
execute
(
"DROP TABLE IF EXISTS RESULTS"
);
}
stat
.
execute
(
"CREATE TABLE IF NOT EXISTS RESULTS(TESTID INT, TEST VARCHAR, "
+
"UNIT VARCHAR, DBID INT, DB VARCHAR, RESULT VARCHAR)"
);
}
finally
{
JdbcUtils
.
closeSilently
(
stat
);
JdbcUtils
.
closeSilently
(
conn
);
}
}
conn
.
createStatement
().
execute
(
"CREATE TABLE IF NOT EXISTS RESULTS(TESTID INT, TEST VARCHAR, "
+
"UNIT VARCHAR, DBID INT, DB VARCHAR, RESULT VARCHAR)"
);
conn
.
close
();
}
}
private
void
test
(
String
[]
args
)
throws
Exception
{
private
void
test
(
String
[]
args
)
throws
Exception
{
...
@@ -84,42 +94,53 @@ public class TestPerformance {
...
@@ -84,42 +94,53 @@ public class TestPerformance {
return
;
return
;
}
}
ArrayList
results
=
((
Database
)
dbs
.
get
(
0
)).
getResults
();
ArrayList
results
=
((
Database
)
dbs
.
get
(
0
)).
getResults
();
Connection
conn
=
getResultConnection
();
Connection
conn
=
null
;
PreparedStatement
prep
=
conn
.
prepareStatement
(
PreparedStatement
prep
=
null
;
"INSERT INTO RESULTS(TESTID, TEST, UNIT, DBID, DB, RESULT) VALUES(?, ?, ?, ?, ?, ?)"
);
Statement
stat
=
null
;
for
(
int
i
=
0
;
i
<
results
.
size
();
i
++)
{
PrintWriter
writer
=
null
;
Object
[]
res
=
(
Object
[])
results
.
get
(
i
);
try
{
prep
.
setInt
(
1
,
i
);
conn
=
getResultConnection
();
prep
.
setString
(
2
,
res
[
0
].
toString
());
stat
=
conn
.
createStatement
();
prep
.
setString
(
3
,
res
[
1
].
toString
());
prep
=
conn
.
prepareStatement
(
for
(
int
j
=
0
;
j
<
dbs
.
size
();
j
++)
{
"INSERT INTO RESULTS(TESTID, TEST, UNIT, DBID, DB, RESULT) VALUES(?, ?, ?, ?, ?, ?)"
);
Database
db
=
(
Database
)
dbs
.
get
(
j
);
for
(
int
i
=
0
;
i
<
results
.
size
();
i
++)
{
prep
.
setInt
(
4
,
db
.
getId
());
Object
[]
res
=
(
Object
[])
results
.
get
(
i
);
prep
.
setString
(
5
,
db
.
getName
());
prep
.
setInt
(
1
,
i
);
ArrayList
r
=
db
.
getResults
();
prep
.
setString
(
2
,
res
[
0
].
toString
());
Object
[]
v
=
(
Object
[])
r
.
get
(
i
);
prep
.
setString
(
3
,
res
[
1
].
toString
());
prep
.
setString
(
6
,
v
[
2
].
toString
());
for
(
int
j
=
0
;
j
<
dbs
.
size
();
j
++)
{
prep
.
execute
();
Database
db
=
(
Database
)
dbs
.
get
(
j
);
prep
.
setInt
(
4
,
db
.
getId
());
prep
.
setString
(
5
,
db
.
getName
());
ArrayList
r
=
db
.
getResults
();
Object
[]
v
=
(
Object
[])
r
.
get
(
i
);
prep
.
setString
(
6
,
v
[
2
].
toString
());
prep
.
execute
();
}
}
}
writer
=
new
PrintWriter
(
new
FileWriter
(
out
));
ResultSet
rs
=
stat
.
executeQuery
(
"CALL '<table><tr><th>Test Case</th><th>Unit</th>' "
+
"|| SELECT GROUP_CONCAT('<th>' || DB || '</th>' ORDER BY DBID SEPARATOR '') FROM "
+
"(SELECT DISTINCT DBID, DB FROM RESULTS)"
+
"|| '</tr>' || CHAR(10) "
+
"|| SELECT GROUP_CONCAT('<tr><td>' || TEST || '</td><td>' || UNIT || '</td>' || ( "
+
"SELECT GROUP_CONCAT('<td>' || RESULT || '</td>' ORDER BY DBID SEPARATOR '') FROM RESULTS R2 WHERE "
+
"R2.TESTID = R1.TESTID) || '</tr>' ORDER BY TESTID SEPARATOR CHAR(10)) FROM "
+
"(SELECT DISTINCT TESTID, TEST, UNIT FROM RESULTS) R1"
+
"|| '</table>'"
);
rs
.
next
();
String
result
=
rs
.
getString
(
1
);
writer
.
println
(
result
);
}
finally
{
JdbcUtils
.
closeSilently
(
prep
);
JdbcUtils
.
closeSilently
(
stat
);
JdbcUtils
.
closeSilently
(
conn
);
IOUtils
.
closeSilently
(
writer
);
}
}
PrintWriter
writer
=
new
PrintWriter
(
new
FileWriter
(
out
));
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"CALL '<table><tr><th>Test Case</th><th>Unit</th>' "
+
"|| SELECT GROUP_CONCAT('<th>' || DB || '</th>' ORDER BY DBID SEPARATOR '') FROM "
+
"(SELECT DISTINCT DBID, DB FROM RESULTS)"
+
"|| '</tr>' || CHAR(10) "
+
"|| SELECT GROUP_CONCAT('<tr><td>' || TEST || '</td><td>' || UNIT || '</td>' || ( "
+
"SELECT GROUP_CONCAT('<td>' || RESULT || '</td>' ORDER BY DBID SEPARATOR '') FROM RESULTS R2 WHERE "
+
"R2.TESTID = R1.TESTID) || '</tr>' ORDER BY TESTID SEPARATOR CHAR(10)) FROM "
+
"(SELECT DISTINCT TESTID, TEST, UNIT FROM RESULTS) R1"
+
"|| '</table>'"
);
rs
.
next
();
String
result
=
rs
.
getString
(
1
);
writer
.
println
(
result
);
conn
.
close
();
// ResultSet rsDbs = conn.createStatement().executeQuery("SELECT DB RESULTS GROUP BY DBID, DB ORDER BY DBID");
// ResultSet rsDbs = conn.createStatement().executeQuery("SELECT DB RESULTS GROUP BY DBID, DB ORDER BY DBID");
// while(rsDbs.next()) {
// while(rsDbs.next()) {
// writer.println("<th>" + rsDbs.getString(1) + "</th>");
// writer.println("<th>" + rsDbs.getString(1) + "</th>");
...
@@ -154,7 +175,6 @@ public class TestPerformance {
...
@@ -154,7 +175,6 @@ public class TestPerformance {
// }
// }
// writer.println("</table>");
// writer.println("</table>");
writer
.
close
();
System
.
out
.
println
(
"Test finished"
);
System
.
out
.
println
(
"Test finished"
);
System
.
exit
(
0
);
System
.
exit
(
0
);
}
}
...
...
h2/src/test/org/h2/test/cases/TestCloseAtShutdown.java
deleted
100644 → 0
浏览文件 @
476b0169
/*
* Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
test
.
cases
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.SQLException
;
import
org.h2.tools.Csv
;
public
class
TestCloseAtShutdown
extends
Thread
{
Connection
conn
;
TestCloseAtShutdown
()
{
Csv
csv
=
null
;
csv
.
setFieldSeparatorWrite
(
";"
);
}
public
void
run
()
{
try
{
Thread
.
sleep
(
100
);
}
catch
(
Exception
e
)
{
// ignore
}
System
.
out
.
println
(
"hook app"
);
try
{
conn
.
getAutoCommit
();
conn
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Class
.
forName
(
"org.h2.Driver"
);
TestCloseAtShutdown
closer
=
new
TestCloseAtShutdown
();
Runtime
.
getRuntime
().
addShutdownHook
(
closer
);
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:test2;TRACE_LEVEL_FILE=3;DB_CLOSE_ON_EXIT=FALSE"
,
"sa"
,
"sa"
);
closer
.
conn
=
conn
;
conn
.
getAutoCommit
();
}
}
h2/src/test/org/h2/test/coverage/Coverage.java
浏览文件 @
e5e6830b
...
@@ -87,6 +87,7 @@ public class Coverage {
...
@@ -87,6 +87,7 @@ public class Coverage {
c
.
processAll
();
c
.
processAll
();
c
.
data
.
close
();
c
.
data
.
close
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
}
...
@@ -154,8 +155,6 @@ public class Coverage {
...
@@ -154,8 +155,6 @@ public class Coverage {
}
}
File
f
=
new
File
(
name
);
File
f
=
new
File
(
name
);
File
fnew
=
new
File
(
name
+
".new"
);
File
fnew
=
new
File
(
name
+
".new"
);
String
key
=
name
;
key
=
key
.
replace
(
'\\'
,
'.'
);
try
{
try
{
writer
=
new
BufferedWriter
(
new
FileWriter
(
fnew
));
writer
=
new
BufferedWriter
(
new
FileWriter
(
fnew
));
Reader
r
=
new
BufferedReader
(
new
FileReader
(
f
));
Reader
r
=
new
BufferedReader
(
new
FileReader
(
f
));
...
...
h2/src/test/org/h2/test/coverage/Profile.java
浏览文件 @
e5e6830b
...
@@ -9,6 +9,8 @@ import java.io.FileReader;
...
@@ -9,6 +9,8 @@ import java.io.FileReader;
import
java.io.FileWriter
;
import
java.io.FileWriter
;
import
java.io.LineNumberReader
;
import
java.io.LineNumberReader
;
import
org.h2.util.IOUtils
;
/**
/**
* The class used at runtime to measure the code usage and performance.
* The class used at runtime to measure the code usage and performance.
*/
*/
...
@@ -16,8 +18,8 @@ public class Profile extends Thread {
...
@@ -16,8 +18,8 @@ public class Profile extends Thread {
public
static
final
boolean
LIST_UNVISITED
=
true
;
public
static
final
boolean
LIST_UNVISITED
=
true
;
public
static
final
boolean
FAST
=
false
;
public
static
final
boolean
FAST
=
false
;
public
static
final
boolean
TRACE
=
false
;
public
static
final
boolean
TRACE
=
false
;
public
static
final
Profile
main
=
new
Profile
();
public
static
int
current
;
public
static
int
current
;
public
static
Profile
main
=
new
Profile
();
private
BufferedWriter
trace
;
private
BufferedWriter
trace
;
public
int
[]
count
;
public
int
[]
count
;
public
int
[]
time
;
public
int
[]
time
;
...
@@ -74,11 +76,12 @@ public class Profile extends Thread {
...
@@ -74,11 +76,12 @@ public class Profile extends Thread {
}
}
Profile
()
{
Profile
()
{
FileReader
reader
=
null
;
try
{
try
{
LineNumberReader
r
=
new
LineNumberReader
(
new
FileReader
(
reader
=
new
FileReader
(
"profile.txt"
);
"profile.txt"
)
);
LineNumberReader
r
=
new
LineNumberReader
(
reader
);
while
(
r
.
readLine
()
!=
null
)
{
while
(
r
.
readLine
()
!=
null
)
{
// nothing
// nothing
- just count lines
}
}
maxIndex
=
r
.
getLineNumber
();
maxIndex
=
r
.
getLineNumber
();
count
=
new
int
[
maxIndex
];
count
=
new
int
[
maxIndex
];
...
@@ -88,6 +91,8 @@ public class Profile extends Thread {
...
@@ -88,6 +91,8 @@ public class Profile extends Thread {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
System
.
exit
(
1
);
System
.
exit
(
1
);
}
finally
{
IOUtils
.
closeSilently
(
reader
);
}
}
}
}
...
@@ -115,28 +120,36 @@ public class Profile extends Thread {
...
@@ -115,28 +120,36 @@ public class Profile extends Thread {
printLine
(
'='
);
printLine
(
'='
);
print
(
"NOT COVERED"
);
print
(
"NOT COVERED"
);
printLine
(
'-'
);
printLine
(
'-'
);
LineNumberReader
r
=
new
LineNumberReader
(
new
FileReader
(
"profile.txt"
));
FileReader
reader
=
null
;
BufferedWriter
writer
=
new
BufferedWriter
(
new
FileWriter
(
"notcovered.txt"
));
FileWriter
fwriter
=
null
;
int
unvisited
=
0
;
try
{
int
unvisitedthrow
=
0
;
reader
=
new
FileReader
(
"profile.txt"
);
for
(
int
i
=
0
;
i
<
maxIndex
;
i
++)
{
LineNumberReader
r
=
new
LineNumberReader
(
reader
);
String
line
=
r
.
readLine
();
fwriter
=
new
FileWriter
(
"notcovered.txt"
);
if
(
count
[
i
]
==
0
)
{
BufferedWriter
writer
=
new
BufferedWriter
(
fwriter
);
if
(!
line
.
endsWith
(
"throw"
))
{
int
unvisited
=
0
;
writer
.
write
(
line
+
"\r\n"
);
int
unvisitedthrow
=
0
;
if
(
LIST_UNVISITED
)
{
for
(
int
i
=
0
;
i
<
maxIndex
;
i
++)
{
print
(
line
+
"\r\n"
);
String
line
=
r
.
readLine
();
if
(
count
[
i
]
==
0
)
{
if
(!
line
.
endsWith
(
"throw"
))
{
writer
.
write
(
line
+
"\r\n"
);
if
(
LIST_UNVISITED
)
{
print
(
line
+
"\r\n"
);
}
unvisited
++;
}
else
{
unvisitedthrow
++;
}
}
unvisited
++;
}
else
{
unvisitedthrow
++;
}
}
}
}
int
percent
=
(
100
*
unvisited
/
maxIndex
);
print
(
"Not covered: "
+
percent
+
" % "
+
" ("
+
unvisited
+
" of "
+
maxIndex
+
"; throw="
+
unvisitedthrow
+
")"
);
}
finally
{
IOUtils
.
closeSilently
(
fwriter
);
IOUtils
.
closeSilently
(
reader
);
}
}
writer
.
close
();
int
percent
=
(
100
*
unvisited
/
maxIndex
);
print
(
"Not covered: "
+
percent
+
" % "
+
" ("
+
unvisited
+
" of "
+
maxIndex
+
"; throw="
+
unvisitedthrow
+
")"
);
}
}
void
listTop
(
String
title
,
int
[]
list
,
int
max
)
throws
Exception
{
void
listTop
(
String
title
,
int
[]
list
,
int
max
)
throws
Exception
{
...
@@ -171,23 +184,29 @@ public class Profile extends Thread {
...
@@ -171,23 +184,29 @@ public class Profile extends Thread {
list
[
bigIndex
]
=
-(
big
+
1
);
list
[
bigIndex
]
=
-(
big
+
1
);
index
[
i
]
=
bigIndex
;
index
[
i
]
=
bigIndex
;
}
}
LineNumberReader
r
=
new
LineNumberReader
(
new
FileReader
(
"profile.txt"
));
FileReader
reader
=
null
;
for
(
int
i
=
0
;
i
<
maxIndex
;
i
++)
{
try
{
String
line
=
r
.
readLine
();
reader
=
new
FileReader
(
"profile.txt"
);
int
k
=
list
[
i
];
LineNumberReader
r
=
new
LineNumberReader
(
reader
);
if
(
k
<
0
)
{
for
(
int
i
=
0
;
i
<
maxIndex
;
i
++)
{
k
=
-(
k
+
1
);
String
line
=
r
.
readLine
();
list
[
i
]
=
k
;
int
k
=
list
[
i
];
for
(
int
j
=
0
;
j
<
max
;
j
++)
{
if
(
k
<
0
)
{
if
(
index
[
j
]
==
i
)
{
k
=
-(
k
+
1
);
int
percent
=
(
100
*
k
/
total
);
list
[
i
]
=
k
;
text
[
j
]
=
k
+
" "
+
percent
+
"%: "
+
line
;
for
(
int
j
=
0
;
j
<
max
;
j
++)
{
if
(
index
[
j
]
==
i
)
{
int
percent
=
(
100
*
k
/
total
);
text
[
j
]
=
k
+
" "
+
percent
+
"%: "
+
line
;
}
}
}
}
}
}
}
}
for
(
int
i
=
0
;
i
<
max
;
i
++)
{
for
(
int
i
=
0
;
i
<
max
;
i
++)
{
print
(
text
[
i
]);
print
(
text
[
i
]);
}
}
finally
{
IOUtils
.
closeSilently
(
reader
);
}
}
}
}
...
...
h2/src/test/org/h2/test/test.in.txt
浏览文件 @
e5e6830b
...
@@ -1725,15 +1725,13 @@ select "PUBLIC".test."ID" from test;
...
@@ -1725,15 +1725,13 @@ select "PUBLIC".test."ID" from test;
> --
> --
> rows: 0
> rows: 0
select
"PUBLIC"
."TEST"."ID" from test;
select
public
."TEST"."ID" from test;
> ID
> ID
> --
> --
> rows: 0
> rows: 0
select "public"."TEST"."ID" from test;
select "public"."TEST"."ID" from test;
> ID
> exception
> --
> rows: 0
drop table test;
drop table test;
> ok
> ok
...
...
h2/src/test/org/h2/test/testSimple.in.txt
浏览文件 @
e5e6830b
create schema a;
create table a.test(id int);
insert into a.test values(1);
create schema b;
create table b.test(id int);
insert into b.test values(2);
select a.test.id + b.test.id from a.test, b.test;
> 3;
drop schema a;
drop schema b;
select date '+0011-01-01';
select date '+0011-01-01';
> 0011-01-01;
> 0011-01-01;
select date'-0010-01-01';
select date'-0010-01-01';
...
...
h2/src/tools/org/h2/tools/doc/GenerateDoc.java
浏览文件 @
e5e6830b
...
@@ -18,6 +18,7 @@ import org.h2.bnf.Bnf;
...
@@ -18,6 +18,7 @@ import org.h2.bnf.Bnf;
import
org.h2.server.web.PageParser
;
import
org.h2.server.web.PageParser
;
import
org.h2.tools.indexer.Indexer
;
import
org.h2.tools.indexer.Indexer
;
import
org.h2.util.IOUtils
;
import
org.h2.util.IOUtils
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.StringUtils
;
import
org.h2.util.StringUtils
;
public
class
GenerateDoc
{
public
class
GenerateDoc
{
...
@@ -80,22 +81,27 @@ public class GenerateDoc {
...
@@ -80,22 +81,27 @@ public class GenerateDoc {
}
}
void
map
(
String
key
,
String
sql
)
throws
Exception
{
void
map
(
String
key
,
String
sql
)
throws
Exception
{
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
sql
);
ResultSet
rs
=
null
;
ArrayList
list
=
new
ArrayList
();
try
{
while
(
rs
.
next
())
{
rs
=
conn
.
createStatement
().
executeQuery
(
sql
);
HashMap
map
=
new
HashMap
();
ArrayList
list
=
new
ArrayList
();
ResultSetMetaData
meta
=
rs
.
getMetaData
();
while
(
rs
.
next
())
{
for
(
int
i
=
0
;
i
<
meta
.
getColumnCount
();
i
++)
{
HashMap
map
=
new
HashMap
();
String
k
=
StringUtils
.
toLowerEnglish
(
meta
.
getColumnLabel
(
i
+
1
));
ResultSetMetaData
meta
=
rs
.
getMetaData
();
String
value
=
rs
.
getString
(
i
+
1
);
for
(
int
i
=
0
;
i
<
meta
.
getColumnCount
();
i
++)
{
map
.
put
(
k
,
PageParser
.
escapeHtml
(
value
));
String
k
=
StringUtils
.
toLowerEnglish
(
meta
.
getColumnLabel
(
i
+
1
));
String
value
=
rs
.
getString
(
i
+
1
);
map
.
put
(
k
,
PageParser
.
escapeHtml
(
value
));
}
String
topic
=
rs
.
getString
(
"TOPIC"
);
String
syntax
=
rs
.
getString
(
"SYNTAX"
);
syntax
=
bnf
.
getSyntax
(
topic
,
syntax
);
map
.
put
(
"syntax"
,
PageParser
.
escapeHtml
(
syntax
));
list
.
add
(
map
);
}
}
String
topic
=
rs
.
getString
(
"TOPIC"
);
session
.
put
(
key
,
list
);
String
syntax
=
rs
.
getString
(
"SYNTAX"
);
}
finally
{
syntax
=
bnf
.
getSyntax
(
topic
,
syntax
);
JdbcUtils
.
closeSilently
(
rs
);
map
.
put
(
"syntax"
,
PageParser
.
escapeHtml
(
syntax
));
list
.
add
(
map
);
}
}
session
.
put
(
key
,
list
);
}
}
}
}
h2/src/tools/org/h2/tools/indexer/Indexer.java
浏览文件 @
e5e6830b
...
@@ -168,7 +168,7 @@ public class Indexer {
...
@@ -168,7 +168,7 @@ public class Indexer {
return
;
return
;
}
}
if
(!
noIndex
.
contains
(
fileName
))
{
if
(!
noIndex
.
contains
(
fileName
))
{
page
=
new
Page
(
pages
.
size
(),
fileName
,
name
);
page
=
new
Page
(
pages
.
size
(),
fileName
);
pages
.
add
(
page
);
pages
.
add
(
page
);
readPage
(
file
);
readPage
(
file
);
}
}
...
...
h2/src/tools/org/h2/tools/indexer/Page.java
浏览文件 @
e5e6830b
...
@@ -8,16 +8,14 @@ package org.h2.tools.indexer;
...
@@ -8,16 +8,14 @@ package org.h2.tools.indexer;
public
class
Page
{
public
class
Page
{
int
id
;
int
id
;
String
fileName
;
String
fileName
;
String
name
;
String
title
;
String
title
;
// TODO page.totalWeight is currently not used
// TODO page.totalWeight is currently not used
int
totalWeight
;
int
totalWeight
;
int
relations
;
int
relations
;
Page
(
int
id
,
String
fileName
,
String
name
)
{
Page
(
int
id
,
String
fileName
)
{
this
.
id
=
id
;
this
.
id
=
id
;
this
.
fileName
=
fileName
;
this
.
fileName
=
fileName
;
this
.
name
=
name
;
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论