Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
e5e6830b
提交
e5e6830b
authored
18 年前
作者:
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.
<h3>
Version 1.0 (Current)
</h3>
<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.
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
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Constants.java
浏览文件 @
e5e6830b
...
...
@@ -11,23 +11,24 @@ package org.h2.engine;
* - System.out > trace messages
*
* Release checklist
* - Run FindBugs
* - Update latest version in build.html: http://mirrors.ibiblio.org/pub/mirrors/maven2/com/h2database/h2/
* - 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%
* -
c
hange FAQ (next release planned, known bugs)
* -
c
heck version, change build number in Constants.java and build.xml
* -
c
heck code coverage
* -
C
hange FAQ (next release planned, known bugs)
* -
C
heck version, change build number in Constants.java and build.xml
* -
C
heck code coverage
* - No " Message.getInternalError" (must be "throw Message.getInternalError")
* - No TODO in the docs
* - Run regression test with JDK 1.4 and 1.5
* - Change version(s) in performance.html; use latest versions of other databases
* - 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)
*
* -
d
ocumentation: if there are new files, add them to MergeDocs
* -
d
ocumentation: check if all javadoc files are in the index
* -
D
ocumentation: if there are new files, add them to MergeDocs
* -
D
ocumentation: check if all javadoc files are in the index
* - ant docs
* - PDF (15 min)
* - footer
...
...
@@ -35,18 +36,18 @@ package org.h2.engine;
* - tables (optimal size)
* - orphan control, page breaks
* - table of contents
* -
s
witch off auto-build
* -
S
witch off auto-build
* - ant all
* -
m
ake sure odbc files are the
* -
m
ake sure the pdf file is there
* -
m
ake sure the build files are removed
* -
M
ake sure odbc files are the
* -
M
ake sure the pdf file is there
* -
M
ake sure the build files are removed
* - ant zip
* -
w
indows installer (nsis)
* -
t
est
* -
t
est the windows service
* -
W
indows installer (nsis)
* -
T
est
* -
T
est the windows service
* - TestSystemExit
* -
t
est with hibernate
* -
s
can for viruses
* -
T
est with hibernate
* -
S
can for viruses
*
* - Send a mail to Google Groups
* - newsletter: prepare, send (always send to BCC!!)
...
...
@@ -185,7 +186,7 @@ public class Constants {
public
static
final
int
ALLOW_LITERALS_ALL
=
2
;
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
String
CONN_URL_INTERNAL
=
"jdbc:default:connection"
;
public
static
final
String
CONN_URL_COLUMNLIST
=
"jdbc:columnlist:connection"
;
...
...
@@ -205,28 +206,28 @@ public class Constants {
// for testing only
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
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
public
static
boolean
LOB_FILES_IN_DIRECTORIES
=
getBooleanSetting
(
"h2.lobFilesInDirectories"
,
false
);
public
static
int
LOB_FILES_PER_DIRECTORY
=
getIntSetting
(
"h2.lobFilesPerDirectory"
,
256
);
public
static
final
boolean
LOB_FILES_IN_DIRECTORIES
=
getBooleanSetting
(
"h2.lobFilesInDirectories"
,
false
);
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
RUN_FINALIZERS
=
getBooleanSetting
(
"h2.runFinalizers"
,
true
);
public
static
boolean
OPTIMIZE_MIN_MAX
=
getBooleanSetting
(
"h2.optimizeMinMax"
,
true
);
public
static
boolean
OPTIMIZE_IN
=
getBooleanSetting
(
"h2.optimizeIn"
,
true
);
public
static
int
REDO_BUFFER_SIZE
=
getIntSetting
(
"h2.redoBufferSize"
,
256
*
1024
);
public
static
boolean
RECOMPILE_ALWAYS
=
getBooleanSetting
(
"h2.recompileAlways"
,
false
);
public
static
boolean
OPTIMIZE_SUBQUERY_CACHE
=
getBooleanSetting
(
"h2.optimizeSubqueryCache"
,
true
);
public
static
boolean
OVERFLOW_EXCEPTIONS
=
getBooleanSetting
(
"h2.overflowExceptions"
,
true
);
public
static
boolean
LOG_ALL_ERRORS
=
getBooleanSetting
(
"h2.logAllErrors"
,
false
);
public
static
String
LOG_ALL_ERRORS_FILE
=
getStringSetting
(
"h2.logAllErrorsFile"
,
"h2errors.txt"
);
public
static
int
SERVER_CACHED_OBJECTS
=
getIntSetting
(
"h2.serverCachedObjects"
,
64
);
public
static
final
boolean
OPTIMIZE_MIN_MAX
=
getBooleanSetting
(
"h2.optimizeMinMax"
,
true
);
public
static
final
boolean
OPTIMIZE_IN
=
getBooleanSetting
(
"h2.optimizeIn"
,
true
);
public
static
final
int
REDO_BUFFER_SIZE
=
getIntSetting
(
"h2.redoBufferSize"
,
256
*
1024
);
public
static
final
boolean
RECOMPILE_ALWAYS
=
getBooleanSetting
(
"h2.recompileAlways"
,
false
);
public
static
final
boolean
OPTIMIZE_SUBQUERY_CACHE
=
getBooleanSetting
(
"h2.optimizeSubqueryCache"
,
true
);
public
static
final
boolean
OVERFLOW_EXCEPTIONS
=
getBooleanSetting
(
"h2.overflowExceptions"
,
true
);
public
static
final
boolean
LOG_ALL_ERRORS
=
getBooleanSetting
(
"h2.logAllErrors"
,
false
);
public
static
final
String
LOG_ALL_ERRORS_FILE
=
getStringSetting
(
"h2.logAllErrorsFile"
,
"h2errors.txt"
);
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
EMERGENCY_SPACE_INITIAL
=
getIntSetting
(
"h2.emergencySpaceInitial"
,
1
*
1024
*
1024
);
public
static
final
int
EMERGENCY_SPACE_MIN
=
getIntSetting
(
"h2.emergencySpaceMin"
,
128
*
1024
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Database.java
浏览文件 @
e5e6830b
...
...
@@ -1314,7 +1314,7 @@ public class Database implements DataHandler {
return
lockMode
;
}
public
void
setCloseDelay
(
int
value
)
{
public
synchronized
void
setCloseDelay
(
int
value
)
{
this
.
closeDelay
=
value
;
}
...
...
@@ -1416,7 +1416,7 @@ public class Database implements DataHandler {
return
ignoreCase
;
}
public
void
setDeleteFilesOnDisconnect
(
boolean
b
)
{
public
synchronized
void
setDeleteFilesOnDisconnect
(
boolean
b
)
{
this
.
deleteFilesOnDisconnect
=
b
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/ExpressionColumn.java
浏览文件 @
e5e6830b
...
...
@@ -9,6 +9,7 @@ import java.util.HashMap;
import
org.h2.command.Parser
;
import
org.h2.command.dml.Select
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Database
;
import
org.h2.engine.Session
;
import
org.h2.message.Message
;
...
...
@@ -44,6 +45,7 @@ public class ExpressionColumn extends Expression {
public
ExpressionColumn
(
Database
database
,
Select
select
,
String
schemaName
,
String
tableAlias
,
String
columnName
)
{
this
.
database
=
database
;
this
.
select
=
select
;
this
.
schemaName
=
schemaName
;
this
.
tableAlias
=
tableAlias
;
this
.
columnName
=
columnName
;
}
...
...
@@ -58,7 +60,8 @@ public class ExpressionColumn extends Expression {
if
(
tableAlias
!=
null
)
{
sql
=
Parser
.
quoteIdentifier
(
tableAlias
)
+
"."
+
sql
;
}
if
(
schemaName
!=
null
)
{
if
(
schemaName
!=
null
&&
!
schemaName
.
equals
(
Constants
.
SCHEMA_MAIN
))
{
int
todoTempSolution
;
sql
=
Parser
.
quoteIdentifier
(
schemaName
)
+
"."
+
sql
;
}
return
sql
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbcx/JdbcDataSource.java
浏览文件 @
e5e6830b
...
...
@@ -38,7 +38,7 @@ public class JdbcDataSource extends TraceObject implements XADataSource, DataSou
private
static
final
long
serialVersionUID
=
1288136338451857771L
;
private
transient
JdbcDataSourceFactory
factory
;
private
transient
JdbcDataSourceFactory
factory
=
new
JdbcDataSourceFactory
()
;
private
transient
PrintWriter
logWriter
;
private
int
timeout
;
private
String
user
;
...
...
@@ -46,7 +46,6 @@ public class JdbcDataSource extends TraceObject implements XADataSource, DataSou
private
String
url
;
public
JdbcDataSource
()
{
this
.
factory
=
new
JdbcDataSourceFactory
();
int
id
=
getNextId
(
TraceObject
.
DATASOURCE
);
setTrace
(
factory
.
getTrace
(),
TraceObject
.
DATASOURCE
,
id
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/schema/Sequence.java
浏览文件 @
e5e6830b
...
...
@@ -109,7 +109,7 @@ public class Sequence extends SchemaObject {
// nothing to do
}
public
long
getCurrentValue
()
{
public
synchronized
long
getCurrentValue
()
{
return
value
-
increment
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
e5e6830b
...
...
@@ -18,6 +18,8 @@ import java.util.ArrayList;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
org.h2.command.Parser
;
import
org.h2.engine.Constants
;
...
...
@@ -303,13 +305,14 @@ public class Recover implements DataHandler {
FileStore
store
=
null
;
int
size
=
0
;
String
n
=
fileName
+
(
lobCompression
?
".comp"
:
""
)
+
".txt"
;
InputStream
in
=
null
;
try
{
out
=
new
FileOutputStream
(
n
);
textStorage
=
Database
.
isTextStorage
(
fileName
,
false
);
byte
[]
magic
=
Database
.
getMagic
(
textStorage
);
store
=
FileStore
.
open
(
null
,
fileName
,
magic
);
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
];
while
(
true
)
{
int
l
=
in
.
read
(
buffer
);
...
...
@@ -326,6 +329,7 @@ public class Recover implements DataHandler {
}
}
finally
{
IOUtils
.
closeSilently
(
out
);
IOUtils
.
closeSilently
(
in
);
closeSilently
(
store
);
}
if
(
size
==
0
)
{
...
...
@@ -714,8 +718,9 @@ public class Recover implements DataHandler {
writer
.
println
(
m
.
getSQL
()
+
";"
);
}
for
(
Iterator
it
=
tableMap
.
keySet
().
iterator
();
it
.
hasNext
();
)
{
Integer
objectId
=
(
Integer
)
it
.
next
();
String
name
=
(
String
)
tableMap
.
get
(
objectId
);
Map
.
Entry
entry
=
(
Entry
)
it
.
next
();
Integer
objectId
=
(
Integer
)
entry
.
getKey
();
String
name
=
(
String
)
entry
.
getValue
();
writer
.
println
(
"INSERT INTO "
+
name
+
" SELECT * FROM O_"
+
objectId
+
";"
);
}
for
(
Iterator
it
=
objectIdSet
.
iterator
();
it
.
hasNext
();
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/RunScript.java
浏览文件 @
e5e6830b
...
...
@@ -21,6 +21,7 @@ import java.util.Iterator;
import
org.h2.engine.Constants
;
import
org.h2.message.Message
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.ScriptReader
;
import
org.h2.util.StringUtils
;
...
...
@@ -215,18 +216,19 @@ public class RunScript {
}
private
static
void
executeRunscript
(
String
url
,
String
user
,
String
password
,
String
fileName
,
String
options
)
throws
SQLException
{
Connection
conn
=
null
;
Statement
stat
=
null
;
try
{
org
.
h2
.
Driver
.
load
();
Connection
conn
=
DriverManager
.
getConnection
(
url
,
user
,
password
);
Statement
stat
=
conn
.
createStatement
();
conn
=
DriverManager
.
getConnection
(
url
,
user
,
password
);
stat
=
conn
.
createStatement
();
String
sql
=
"RUNSCRIPT FROM '"
+
fileName
+
"' "
+
options
;
try
{
stat
.
execute
(
sql
);
}
finally
{
conn
.
close
();
}
}
catch
(
Exception
e
)
{
throw
Message
.
convert
(
e
);
}
finally
{
JdbcUtils
.
closeSilently
(
stat
);
JdbcUtils
.
closeSilently
(
conn
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/Server.java
浏览文件 @
e5e6830b
...
...
@@ -17,6 +17,7 @@ import org.h2.server.Service;
import
org.h2.server.TcpServer
;
import
org.h2.server.ftp.FtpServer
;
import
org.h2.server.web.WebServer
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.StartBrowser
;
...
...
@@ -230,9 +231,11 @@ public class Server implements Runnable {
throw
Message
.
convert
(
e
);
}
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
Connection
conn
=
null
;
PreparedStatement
prep
=
null
;
try
{
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:"
+
url
+
"/"
+
db
,
"sa"
,
password
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"CALL STOP_SERVER(?, ?, ?)"
);
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:"
+
url
+
"/"
+
db
,
"sa"
,
password
);
prep
=
conn
.
prepareStatement
(
"CALL STOP_SERVER(?, ?, ?)"
);
prep
.
setInt
(
1
,
port
);
prep
.
setString
(
2
,
password
);
prep
.
setInt
(
3
,
force
?
TcpServer
.
SHUTDOWN_FORCE
:
TcpServer
.
SHUTDOWN_NORMAL
);
...
...
@@ -244,18 +247,15 @@ public class Server implements Runnable {
}
else
{
throw
e
;
}
}
finally
{
try
{
conn
.
close
();
}
catch
(
SQLException
e
)
{
// ignore
}
}
break
;
}
catch
(
SQLException
e
)
{
if
(
i
==
1
)
{
throw
e
;
}
}
finally
{
JdbcUtils
.
closeSilently
(
prep
);
JdbcUtils
.
closeSilently
(
conn
);
}
}
}
...
...
@@ -338,7 +338,8 @@ public class Server implements Runnable {
private
static
void
wait
(
int
i
)
{
try
{
// sleep at most 4096 ms
Thread
.
sleep
(
i
*
i
);
long
sleep
=
(
long
)
i
*
(
long
)
i
;
Thread
.
sleep
(
sleep
);
}
catch
(
InterruptedException
e
)
{
// ignore
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/ByteUtils.java
浏览文件 @
e5e6830b
...
...
@@ -48,7 +48,7 @@ public class ByteUtils {
public
static
byte
[]
convertStringToBytes
(
String
s
)
throws
SQLException
{
int
len
=
s
.
length
();
if
(
len
<
0
||
len
%
2
==
1
)
{
if
(
len
%
2
!=
0
)
{
throw
Message
.
getSQLException
(
Message
.
HEX_STRING_ODD_1
,
s
);
}
len
/=
2
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/FileUtils.java
浏览文件 @
e5e6830b
...
...
@@ -233,7 +233,8 @@ public class FileUtils {
}
try
{
// sleep at most 256 ms
Thread
.
sleep
(
i
*
i
);
long
sleep
=
(
long
)
i
*
(
long
)
i
;
Thread
.
sleep
(
sleep
);
}
catch
(
InterruptedException
e
)
{
// ignore
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/JdbcUtils.java
浏览文件 @
e5e6830b
package
org
.
h2
.
util
;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
...
...
@@ -26,4 +27,14 @@ public class JdbcUtils {
}
}
public
static
void
closeSilently
(
ResultSet
rs
)
{
if
(
rs
!=
null
)
{
try
{
rs
.
close
();
}
catch
(
SQLException
e
)
{
// ignore
}
}
}
}
This diff is collapsed.
Click to expand it.
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 {
for
(
int
i
=
0
;
i
<
a
.
length
();
i
++)
{
String
s
=
a
.
substring
(
0
,
i
);
if
(!
b
.
startsWith
(
s
))
{
s
=
s
.
substring
(
0
,
i
)
+
"<*>"
+
s
.
substring
(
i
);
a
=
a
.
substring
(
0
,
i
)
+
"<*>"
+
a
.
substring
(
i
);
break
;
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/bench/BenchA.java
浏览文件 @
e5e6830b
...
...
@@ -16,8 +16,8 @@ public class BenchA implements Bench {
private
Database
db
;
private
int
branches
;
private
int
tellers
=
branches
*
20
;
private
int
accounts
=
branches
*
100
;
private
int
tellers
;
private
int
accounts
;
private
int
size
;
private
static
final
String
FILLER
=
"abcdefghijklmnopqrstuvwxyz"
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/bench/BenchCThread.java
浏览文件 @
e5e6830b
...
...
@@ -371,7 +371,7 @@ public class BenchCThread {
rs
.
next
();
rs
.
getString
(
1
);
// c_first
rs
.
getString
(
2
);
// c_middle
c_last
=
rs
.
getString
(
3
);
rs
.
getString
(
3
);
// c_last
rs
.
getString
(
4
);
// c_street_1
rs
.
getString
(
5
);
// c_street_2
rs
.
getString
(
6
);
// c_city
...
...
@@ -499,7 +499,7 @@ public class BenchCThread {
rs
.
getBigDecimal
(
1
);
// c_balance
rs
.
getString
(
2
);
// c_first
rs
.
getString
(
3
);
// c_middle
c_last
=
rs
.
getString
(
4
);
rs
.
getString
(
4
);
// c_last
rs
.
close
();
}
prep
=
prepare
(
"SELECT MAX(O_ID) "
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/bench/Database.java
浏览文件 @
e5e6830b
...
...
@@ -20,6 +20,7 @@ import java.util.StringTokenizer;
import
org.h2.test.TestBase
;
import
org.h2.tools.Server
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.StringUtils
;
class
Database
{
...
...
@@ -129,7 +130,13 @@ class Database {
Connection
conn
=
DriverManager
.
getConnection
(
url
,
user
,
password
);
if
(
url
.
startsWith
(
"jdbc:derby:"
))
{
// 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
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/bench/TestPerformance.java
浏览文件 @
e5e6830b
...
...
@@ -10,10 +10,13 @@ import java.sql.Connection;
import
java.sql.DriverManager
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.Statement
;
import
java.util.ArrayList
;
import
java.util.Properties
;
import
org.h2.test.TestBase
;
import
org.h2.util.IOUtils
;
import
org.h2.util.JdbcUtils
;
public
class
TestPerformance
{
...
...
@@ -29,13 +32,20 @@ public class TestPerformance {
}
private
void
openResults
(
boolean
init
)
throws
Exception
{
Connection
conn
=
getResultConnection
();
Connection
conn
=
null
;
Statement
stat
=
null
;
try
{
conn
=
getResultConnection
();
stat
=
conn
.
createStatement
();
if
(
init
)
{
conn
.
createStatement
()
.
execute
(
"DROP TABLE IF EXISTS RESULTS"
);
stat
.
execute
(
"DROP TABLE IF EXISTS RESULTS"
);
}
conn
.
createStatement
()
.
execute
(
"CREATE TABLE IF NOT EXISTS RESULTS(TESTID INT, TEST VARCHAR, "
stat
.
execute
(
"CREATE TABLE IF NOT EXISTS RESULTS(TESTID INT, TEST VARCHAR, "
+
"UNIT VARCHAR, DBID INT, DB VARCHAR, RESULT VARCHAR)"
);
conn
.
close
();
}
finally
{
JdbcUtils
.
closeSilently
(
stat
);
JdbcUtils
.
closeSilently
(
conn
);
}
}
private
void
test
(
String
[]
args
)
throws
Exception
{
...
...
@@ -84,8 +94,14 @@ public class TestPerformance {
return
;
}
ArrayList
results
=
((
Database
)
dbs
.
get
(
0
)).
getResults
();
Connection
conn
=
getResultConnection
();
PreparedStatement
prep
=
conn
.
prepareStatement
(
Connection
conn
=
null
;
PreparedStatement
prep
=
null
;
Statement
stat
=
null
;
PrintWriter
writer
=
null
;
try
{
conn
=
getResultConnection
();
stat
=
conn
.
createStatement
();
prep
=
conn
.
prepareStatement
(
"INSERT INTO RESULTS(TESTID, TEST, UNIT, DBID, DB, RESULT) VALUES(?, ?, ?, ?, ?, ?)"
);
for
(
int
i
=
0
;
i
<
results
.
size
();
i
++)
{
Object
[]
res
=
(
Object
[])
results
.
get
(
i
);
...
...
@@ -103,8 +119,8 @@ public class TestPerformance {
}
}
PrintWriter
writer
=
new
PrintWriter
(
new
FileWriter
(
out
));
ResultSet
rs
=
conn
.
createStatement
()
.
executeQuery
(
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)"
...
...
@@ -118,7 +134,12 @@ public class TestPerformance {
rs
.
next
();
String
result
=
rs
.
getString
(
1
);
writer
.
println
(
result
);
conn
.
close
();
}
finally
{
JdbcUtils
.
closeSilently
(
prep
);
JdbcUtils
.
closeSilently
(
stat
);
JdbcUtils
.
closeSilently
(
conn
);
IOUtils
.
closeSilently
(
writer
);
}
// ResultSet rsDbs = conn.createStatement().executeQuery("SELECT DB RESULTS GROUP BY DBID, DB ORDER BY DBID");
// while(rsDbs.next()) {
...
...
@@ -154,7 +175,6 @@ public class TestPerformance {
// }
// writer.println("</table>");
writer
.
close
();
System
.
out
.
println
(
"Test finished"
);
System
.
exit
(
0
);
}
...
...
This diff is collapsed.
Click to expand it.
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
();
}
}
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/coverage/Coverage.java
浏览文件 @
e5e6830b
...
...
@@ -87,6 +87,7 @@ public class Coverage {
c
.
processAll
();
c
.
data
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
...
...
@@ -154,8 +155,6 @@ public class Coverage {
}
File
f
=
new
File
(
name
);
File
fnew
=
new
File
(
name
+
".new"
);
String
key
=
name
;
key
=
key
.
replace
(
'\\'
,
'.'
);
try
{
writer
=
new
BufferedWriter
(
new
FileWriter
(
fnew
));
Reader
r
=
new
BufferedReader
(
new
FileReader
(
f
));
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/coverage/Profile.java
浏览文件 @
e5e6830b
...
...
@@ -9,6 +9,8 @@ import java.io.FileReader;
import
java.io.FileWriter
;
import
java.io.LineNumberReader
;
import
org.h2.util.IOUtils
;
/**
* The class used at runtime to measure the code usage and performance.
*/
...
...
@@ -16,8 +18,8 @@ public class Profile extends Thread {
public
static
final
boolean
LIST_UNVISITED
=
true
;
public
static
final
boolean
FAST
=
false
;
public
static
final
boolean
TRACE
=
false
;
public
static
final
Profile
main
=
new
Profile
();
public
static
int
current
;
public
static
Profile
main
=
new
Profile
();
private
BufferedWriter
trace
;
public
int
[]
count
;
public
int
[]
time
;
...
...
@@ -74,11 +76,12 @@ public class Profile extends Thread {
}
Profile
()
{
FileReader
reader
=
null
;
try
{
LineNumberReader
r
=
new
LineNumberReader
(
new
FileReader
(
"profile.txt"
)
);
reader
=
new
FileReader
(
"profile.txt"
);
LineNumberReader
r
=
new
LineNumberReader
(
reader
);
while
(
r
.
readLine
()
!=
null
)
{
// nothing
// nothing
- just count lines
}
maxIndex
=
r
.
getLineNumber
();
count
=
new
int
[
maxIndex
];
...
...
@@ -88,6 +91,8 @@ public class Profile extends Thread {
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
System
.
exit
(
1
);
}
finally
{
IOUtils
.
closeSilently
(
reader
);
}
}
...
...
@@ -115,8 +120,13 @@ public class Profile extends Thread {
printLine
(
'='
);
print
(
"NOT COVERED"
);
printLine
(
'-'
);
LineNumberReader
r
=
new
LineNumberReader
(
new
FileReader
(
"profile.txt"
));
BufferedWriter
writer
=
new
BufferedWriter
(
new
FileWriter
(
"notcovered.txt"
));
FileReader
reader
=
null
;
FileWriter
fwriter
=
null
;
try
{
reader
=
new
FileReader
(
"profile.txt"
);
LineNumberReader
r
=
new
LineNumberReader
(
reader
);
fwriter
=
new
FileWriter
(
"notcovered.txt"
);
BufferedWriter
writer
=
new
BufferedWriter
(
fwriter
);
int
unvisited
=
0
;
int
unvisitedthrow
=
0
;
for
(
int
i
=
0
;
i
<
maxIndex
;
i
++)
{
...
...
@@ -133,10 +143,13 @@ public class Profile extends Thread {
}
}
}
writer
.
close
();
int
percent
=
(
100
*
unvisited
/
maxIndex
);
print
(
"Not covered: "
+
percent
+
" % "
+
" ("
+
unvisited
+
" of "
+
maxIndex
+
"; throw="
+
unvisitedthrow
+
")"
);
}
finally
{
IOUtils
.
closeSilently
(
fwriter
);
IOUtils
.
closeSilently
(
reader
);
}
}
void
listTop
(
String
title
,
int
[]
list
,
int
max
)
throws
Exception
{
...
...
@@ -171,7 +184,10 @@ public class Profile extends Thread {
list
[
bigIndex
]
=
-(
big
+
1
);
index
[
i
]
=
bigIndex
;
}
LineNumberReader
r
=
new
LineNumberReader
(
new
FileReader
(
"profile.txt"
));
FileReader
reader
=
null
;
try
{
reader
=
new
FileReader
(
"profile.txt"
);
LineNumberReader
r
=
new
LineNumberReader
(
reader
);
for
(
int
i
=
0
;
i
<
maxIndex
;
i
++)
{
String
line
=
r
.
readLine
();
int
k
=
list
[
i
];
...
...
@@ -189,6 +205,9 @@ public class Profile extends Thread {
for
(
int
i
=
0
;
i
<
max
;
i
++)
{
print
(
text
[
i
]);
}
}
finally
{
IOUtils
.
closeSilently
(
reader
);
}
}
void
print
(
String
s
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/test.in.txt
浏览文件 @
e5e6830b
...
...
@@ -1725,15 +1725,13 @@ select "PUBLIC".test."ID" from test;
> --
> rows: 0
select
"PUBLIC"
."TEST"."ID" from test;
select
public
."TEST"."ID" from test;
> ID
> --
> rows: 0
select "public"."TEST"."ID" from test;
> ID
> --
> rows: 0
> exception
drop table test;
> ok
...
...
This diff is collapsed.
Click to expand it.
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';
> 0011-01-01;
select date'-0010-01-01';
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/tools/doc/GenerateDoc.java
浏览文件 @
e5e6830b
...
...
@@ -18,6 +18,7 @@ import org.h2.bnf.Bnf;
import
org.h2.server.web.PageParser
;
import
org.h2.tools.indexer.Indexer
;
import
org.h2.util.IOUtils
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.StringUtils
;
public
class
GenerateDoc
{
...
...
@@ -80,7 +81,9 @@ public class GenerateDoc {
}
void
map
(
String
key
,
String
sql
)
throws
Exception
{
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
sql
);
ResultSet
rs
=
null
;
try
{
rs
=
conn
.
createStatement
().
executeQuery
(
sql
);
ArrayList
list
=
new
ArrayList
();
while
(
rs
.
next
())
{
HashMap
map
=
new
HashMap
();
...
...
@@ -97,5 +100,8 @@ public class GenerateDoc {
list
.
add
(
map
);
}
session
.
put
(
key
,
list
);
}
finally
{
JdbcUtils
.
closeSilently
(
rs
);
}
}
}
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/tools/indexer/Indexer.java
浏览文件 @
e5e6830b
...
...
@@ -168,7 +168,7 @@ public class Indexer {
return
;
}
if
(!
noIndex
.
contains
(
fileName
))
{
page
=
new
Page
(
pages
.
size
(),
fileName
,
name
);
page
=
new
Page
(
pages
.
size
(),
fileName
);
pages
.
add
(
page
);
readPage
(
file
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/tools/indexer/Page.java
浏览文件 @
e5e6830b
...
...
@@ -8,16 +8,14 @@ package org.h2.tools.indexer;
public
class
Page
{
int
id
;
String
fileName
;
String
name
;
String
title
;
// TODO page.totalWeight is currently not used
int
totalWeight
;
int
relations
;
Page
(
int
id
,
String
fileName
,
String
name
)
{
Page
(
int
id
,
String
fileName
)
{
this
.
id
=
id
;
this
.
fileName
=
fileName
;
this
.
name
=
name
;
}
}
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论