Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
b562327f
提交
b562327f
authored
2月 20, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tests.
上级
52184120
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
86 行增加
和
70 行删除
+86
-70
roadmap.html
h2/src/docsrc/html/roadmap.html
+2
-1
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+6
-28
TestBase.java
h2/src/test/org/h2/test/TestBase.java
+0
-13
TestReadOnly.java
h2/src/test/org/h2/test/db/TestReadOnly.java
+1
-6
TestDataSource.java
h2/src/test/org/h2/test/jdbcx/TestDataSource.java
+12
-2
TestRecover.java
h2/src/test/org/h2/test/poweroff/TestRecover.java
+57
-20
tools.sql
h2/src/test/org/h2/test/todo/tools.sql
+8
-0
没有找到文件。
h2/src/docsrc/html/roadmap.html
浏览文件 @
b562327f
...
...
@@ -272,6 +272,7 @@ See also <a href="build.html#providing_patches">Providing Patches</a>.
</li><li>
Javadoc: document design patterns used
</li><li>
Write an article about SQLInjection (h2/src/docsrc/html/images/SQLInjection.txt)
</li><li>
Convert SQL-injection-2.txt to html document, include SQLInjection.java sample
</li><li>
Support OUT parameters in user-defined procedures.
</li><li>
Improve LOB in directories performance
</li><li>
Web site design: http://www.igniterealtime.org/projects/openfire/index.jsp
</li><li>
HSQLDB compatibility: Openfire server uses: CREATE SCHEMA PUBLIC AUTHORIZATION DBA;
...
...
@@ -307,7 +308,6 @@ See also <a href="build.html#providing_patches">Providing Patches</a>.
</li><li>
H2 Console: support CLOB/BLOB download using a link.
</li><li>
Support flashback queries as in Oracle.
</li><li>
Import / Export of fixed with text files.
</li><li>
Support OUT parameters in user-defined procedures.
</li><li>
Support getGeneratedKeys to return multiple rows when used with batch updates.
This is supported by MySQL, but not Derby. Both PostgreSQL and HSQLDB don't support getGeneratedKeys.
Also support it when using INSERT ... SELECT.
...
...
@@ -482,6 +482,7 @@ See also <a href="build.html#providing_patches">Providing Patches</a>.
</li><li>
Logback: write a native DBAppender.
</li><li>
Cache size: don't use more cache than what is available.
</li><li>
Use the Java service provider mechanism to register file systems and function libraries.
</li><li>
Tree index: Instead of an AVL tree, use a general balanced trees or a scapegoat tree.
</li></ul>
<h2>
Not Planned
</h2>
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
b562327f
...
...
@@ -183,11 +183,6 @@ java org.h2.test.TestAll timer
*/
public
boolean
memory
;
/**
* If index files should be deleted before re-opening the database.
*/
public
boolean
deleteIndex
;
/**
* If code coverage is enabled.
*/
...
...
@@ -292,29 +287,16 @@ java org.h2.test.TestAll timer
System
.
setProperty
(
"h2.check2"
,
"true"
);
/*
test recovery of large pages and transaction log
test recovery with 'trace' mode (many secondary indexes, small data rows)
improve Row.getMemorySize
maybe remove ValueHashMap
rename Page* classes
move classes to the right packages
instead of AVL trees, use general balanced trees
test Row.getMemorySize
review package and class level javadocs
TestAll deleteIndex
power failure test: larger binaries and additional index.
power failure test: larger binaries and additional indexes
(with many columns).
outer join bug
rename Page* classes
move classes to the right packages
// System.setProperty("h2.pageSize", "64");
test with small freeList pages, page size 64
test if compact always works as expected
google app engine
documentation: review package and class level javadocs
documentation: rolling review at jaqu.html
-------------
...
...
@@ -382,14 +364,13 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
}
else
{
cipher
=
"AES"
;
}
for
(
int
a
=
0
;
a
<
128
;
a
++)
{
for
(
int
a
=
0
;
a
<
64
;
a
++)
{
smallLog
=
(
a
&
1
)
!=
0
;
big
=
(
a
&
2
)
!=
0
;
networked
=
(
a
&
4
)
!=
0
;
memory
=
(
a
&
8
)
!=
0
;
ssl
=
(
a
&
16
)
!=
0
;
diskResult
=
(
a
&
32
)
!=
0
;
deleteIndex
=
(
a
&
64
)
!=
0
;
for
(
int
trace
=
0
;
trace
<
3
;
trace
++)
{
traceLevelFile
=
trace
;
test
();
...
...
@@ -404,7 +385,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
private
void
runTests
()
throws
SQLException
{
jdk14
=
true
;
smallLog
=
big
=
networked
=
memory
=
ssl
=
false
;
diskResult
=
deleteIndex
=
traceSystemOut
=
diskUndo
=
false
;
diskResult
=
traceSystemOut
=
diskUndo
=
false
;
mvcc
=
traceTest
=
stopOnError
=
false
;
traceLevelFile
=
throttle
=
0
;
cipher
=
null
;
...
...
@@ -421,7 +402,6 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
diskUndo
=
true
;
diskResult
=
true
;
deleteIndex
=
true
;
traceLevelFile
=
3
;
throttle
=
1
;
cacheType
=
"SOFT_LRU"
;
...
...
@@ -430,7 +410,6 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
diskUndo
=
false
;
diskResult
=
false
;
deleteIndex
=
false
;
traceLevelFile
=
1
;
throttle
=
0
;
cacheType
=
null
;
...
...
@@ -693,7 +672,6 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
appendIf
(
buff
,
throttle
>
0
,
"throttle:"
+
throttle
);
appendIf
(
buff
,
traceTest
,
"traceTest"
);
appendIf
(
buff
,
stopOnError
,
"stopOnError"
);
appendIf
(
buff
,
deleteIndex
,
"deleteIndex"
);
return
buff
.
toString
();
}
...
...
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
b562327f
...
...
@@ -191,16 +191,6 @@ public abstract class TestBase {
return
getPassword
(
"123"
);
}
private
void
deleteIndexFiles
(
String
name
)
{
if
(
name
.
indexOf
(
";"
)
>
0
)
{
name
=
name
.
substring
(
0
,
name
.
indexOf
(
';'
));
}
name
+=
".index.db"
;
if
(
new
File
(
name
).
canWrite
())
{
new
File
(
name
).
delete
();
}
}
/**
* Get the database URL for the given database name using the current
* configuration options.
...
...
@@ -220,9 +210,6 @@ public abstract class TestBase {
if
(!
name
.
startsWith
(
"memFS:"
)
&&
!
name
.
startsWith
(
baseDir
+
"/"
))
{
name
=
baseDir
+
"/"
+
name
;
}
if
(
config
.
deleteIndex
)
{
deleteIndexFiles
(
name
);
}
}
if
(
config
.
networked
)
{
if
(
config
.
ssl
)
{
...
...
h2/src/test/org/h2/test/db/TestReadOnly.java
浏览文件 @
b562327f
...
...
@@ -40,16 +40,11 @@ public class TestReadOnly extends TestBase {
if
(!
config
.
googleAppEngine
)
{
testReadOnlyFiles
(
true
);
}
if
(!
config
.
deleteIndex
)
{
testReadOnlyFiles
(
false
);
}
testReadOnlyFiles
(
false
);
deleteDb
(
"readonly"
);
}
private
void
testReadOnlyDbCreate
()
throws
SQLException
{
if
(
config
.
deleteIndex
)
{
return
;
}
deleteDb
(
"readonly"
);
Connection
conn
=
getConnection
(
"readonly"
);
conn
.
close
();
...
...
h2/src/test/org/h2/test/jdbcx/TestDataSource.java
浏览文件 @
b562327f
...
...
@@ -21,6 +21,7 @@ import javax.transaction.xa.XAResource;
import
javax.transaction.xa.Xid
;
import
org.h2.jdbcx.JdbcDataSource
;
import
org.h2.jdbcx.JdbcDataSourceFactory
;
import
org.h2.jdbcx.JdbcXAConnection
;
import
org.h2.test.TestBase
;
/**
...
...
@@ -96,10 +97,19 @@ public class TestDataSource extends TestBase {
private
void
testXAConnection
()
throws
Exception
{
deleteDb
(
"dataSource"
);
JdbcDataSource
ds
=
new
JdbcDataSource
();
ds
.
setURL
(
getURL
(
"dataSource"
,
true
));
ds
.
setUser
(
getUser
());
String
url
=
getURL
(
"dataSource"
,
true
);
String
user
=
getUser
();
ds
.
setURL
(
url
);
ds
.
setUser
(
user
);
ds
.
setPassword
(
getPassword
());
assertEquals
(
"ds"
+
ds
.
getTraceId
()
+
": url="
+
url
+
" user="
+
user
,
ds
.
toString
());
XAConnection
xaConn
=
ds
.
getXAConnection
();
int
traceId
=
((
JdbcXAConnection
)
xaConn
).
getTraceId
();
assertEquals
(
"xads"
+
traceId
+
": url="
+
url
+
" user="
+
user
,
xaConn
.
toString
());
xaConn
.
addConnectionEventListener
(
new
ConnectionEventListener
()
{
public
void
connectionClosed
(
ConnectionEvent
event
)
{
// nothing to do
...
...
h2/src/test/org/h2/test/poweroff/TestRecover.java
浏览文件 @
b562327f
...
...
@@ -38,6 +38,7 @@ import org.h2.util.New;
*/
public
class
TestRecover
{
private
static
final
int
MAX_STRING_LENGTH
=
10000
;
private
static
final
String
NODE
=
System
.
getProperty
(
"test.node"
,
""
);
private
static
final
String
DIR
=
System
.
getProperty
(
"test.dir"
,
"/temp/db"
);
...
...
@@ -185,7 +186,8 @@ public class TestRecover {
Connection
conn
=
DriverManager
.
getConnection
(
URL
,
"sa"
,
"sa"
);
Statement
stat
=
conn
.
createStatement
();
try
{
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))"
);
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, D INT, NAME VARCHAR("
+
MAX_STRING_LENGTH
+
"))"
);
stat
.
execute
(
"CREATE INDEX IDX_TEST_D ON TEST(D)"
);
}
catch
(
SQLException
e
)
{
// ignore
}
...
...
@@ -231,8 +233,8 @@ public class TestRecover {
// make the length odd
len
++;
}
//
byte[] data = new byte[len];
//
random.nextBytes(data);
//
byte[] data = new byte[len];
//
random.nextBytes(data);
int
op
=
random
.
nextInt
();
if
(
op
%
1000000
==
0
)
{
closeConnection
(
conn
);
...
...
@@ -243,10 +245,32 @@ public class TestRecover {
}
if
(
random
.
nextBoolean
())
{
if
(
prepInsert
==
null
)
{
prepInsert
=
conn
.
prepareStatement
(
"INSERT INTO TEST(ID,
NAME) VALUES(
?, ?)"
);
prepInsert
=
conn
.
prepareStatement
(
"INSERT INTO TEST(ID,
D, NAME) VALUES(?,
?, ?)"
);
}
prepInsert
.
setInt
(
1
,
id
);
prepInsert
.
setString
(
2
,
""
+
len
);
prepInsert
.
setInt
(
2
,
random
.
nextInt
(
10000
));
StringBuilder
buff
=
new
StringBuilder
();
buff
.
append
(
len
);
switch
(
random
.
nextInt
(
10
))
{
case
0
:
len
=
random
.
nextInt
(
MAX_STRING_LENGTH
);
break
;
case
1
:
case
2
:
case
3
:
len
=
random
.
nextInt
(
MAX_STRING_LENGTH
/
20
);
break
;
default
:
len
=
0
;
}
len
-=
10
;
while
(
len
>
0
)
{
buff
.
append
(
'-'
);
len
--;
}
buff
.
append
(
"->"
);
String
s
=
buff
.
toString
();
prepInsert
.
setString
(
3
,
s
);
prepInsert
.
execute
();
}
else
{
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT COUNT(*) FROM TEST"
);
...
...
@@ -283,22 +307,9 @@ public class TestRecover {
Connection
conn
=
null
;
try
{
conn
=
openConnection
();
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT * FROM TEST"
);
int
max
=
0
;
int
count
=
0
;
while
(
rs
.
next
())
{
count
++;
int
id
=
rs
.
getInt
(
"ID"
);
String
name
=
rs
.
getString
(
"NAME"
);
int
value
=
Integer
.
parseInt
(
name
);
if
(
value
%
2
!=
0
)
{
throw
new
Exception
(
"unexpected odd entry "
+
id
+
" value "
+
value
);
}
max
=
Math
.
max
(
max
,
id
);
}
rs
.
close
();
test
(
conn
,
""
);
test
(
conn
,
"ORDER BY D"
);
closeConnection
(
conn
);
System
.
out
.
println
(
"max row id: "
+
max
+
" rows: "
+
count
);
return
true
;
}
catch
(
Throwable
t
)
{
t
.
printStackTrace
();
...
...
@@ -319,4 +330,30 @@ public class TestRecover {
}
}
private
void
test
(
Connection
conn
,
String
order
)
throws
Exception
{
ResultSet
rs
;
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT * FROM TEST "
+
order
);
int
max
=
0
;
int
count
=
0
;
while
(
rs
.
next
())
{
count
++;
int
id
=
rs
.
getInt
(
"ID"
);
String
name
=
rs
.
getString
(
"NAME"
);
if
(!
name
.
endsWith
(
">"
))
{
throw
new
Exception
(
"unexpected entry "
+
id
+
" value "
+
name
);
}
int
idx
=
name
.
indexOf
(
'-'
);
if
(
idx
<
0
)
{
throw
new
Exception
(
"unexpected entry "
+
id
+
" value "
+
name
);
}
int
value
=
Integer
.
parseInt
(
name
.
substring
(
0
,
idx
));
if
(
value
%
2
!=
0
)
{
throw
new
Exception
(
"unexpected odd entry "
+
id
+
" value "
+
value
);
}
max
=
Math
.
max
(
max
,
id
);
}
rs
.
close
();
System
.
out
.
println
(
"max row id: "
+
max
+
" rows: "
+
count
);
}
}
h2/src/test/org/h2/test/todo/tools.sql
浏览文件 @
b562327f
...
...
@@ -5,6 +5,14 @@
* Initial Developer: H2 Group
*/
-- TO_DATE
create
alias
TO_DATE
as
$$
java
.
util
.
Date
toDate
(
String
s
)
throws
Exception
{
return
new
java
.
text
.
SimpleDateFormat
(
"yyyy.MM.dd"
).
parse
(
s
);
}
$$
;
call
TO_DATE
(
'1990.02.03'
)
-- update all rows in all tables
select
'update '
||
table_schema
||
'.'
||
table_name
||
' set '
||
column_name
||
'='
||
column_name
||
';'
from
information_schema
.
columns
where
ORDINAL_POSITION
=
1
and
table_schema
<>
'INFORMATION_SCHEMA'
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论