Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
280c7a28
提交
280c7a28
authored
2月 17, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
b6686049
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
100 行增加
和
6 行删除
+100
-6
Function.java
h2/src/test/org/h2/samples/Function.java
+19
-1
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+6
-1
TestBitField.java
h2/src/test/org/h2/test/unit/TestBitField.java
+7
-1
TestFileLock.java
h2/src/test/org/h2/test/unit/TestFileLock.java
+28
-0
TestPattern.java
h2/src/test/org/h2/test/unit/TestPattern.java
+9
-0
TestReader.java
h2/src/test/org/h2/test/unit/TestReader.java
+9
-0
TestRecovery.java
h2/src/test/org/h2/test/unit/TestRecovery.java
+9
-0
TestSampleApps.java
h2/src/test/org/h2/test/unit/TestSampleApps.java
+10
-1
GenerateDoc.java
h2/src/tools/org/h2/build/doc/GenerateDoc.java
+2
-1
dictionary.txt
h2/src/tools/org/h2/build/doc/dictionary.txt
+1
-1
没有找到文件。
h2/src/test/org/h2/samples/Function.java
浏览文件 @
280c7a28
...
...
@@ -9,11 +9,11 @@ package org.h2.samples;
import
java.math.BigInteger
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Types
;
import
org.h2.tools.SimpleResultSet
;
/**
...
...
@@ -32,6 +32,8 @@ public class Function {
Class
.
forName
(
"org.h2.Driver"
);
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:mem:"
,
"sa"
,
""
);
Statement
stat
=
conn
.
createStatement
();
// Using a custom Java function
stat
.
execute
(
"CREATE ALIAS IS_PRIME FOR \"org.h2.samples.Function.isPrime\" "
);
ResultSet
rs
;
rs
=
stat
.
executeQuery
(
"SELECT IS_PRIME(X), X FROM SYSTEM_RANGE(1, 20) ORDER BY X"
);
...
...
@@ -42,6 +44,22 @@ public class Function {
System
.
out
.
println
(
x
+
" is prime"
);
}
}
// Calling the built-in 'table' function
stat
.
execute
(
"CREATE TABLE TEST(ID INT) AS "
+
"SELECT X FROM SYSTEM_RANGE(1, 100)"
);
PreparedStatement
prep
;
prep
=
conn
.
prepareStatement
(
"SELECT * FROM TABLE(X INT=?, O INT=?) J "
+
"INNER JOIN TEST T ON J.X=T.ID ORDER BY J.O"
);
prep
.
setObject
(
1
,
new
Integer
[]
{
new
Integer
(
30
),
new
Integer
(
20
)
});
prep
.
setObject
(
2
,
new
Integer
[]
{
new
Integer
(
1
),
new
Integer
(
2
)
});
ResultSet
rs2
=
prep
.
executeQuery
();
while
(
rs2
.
next
())
{
System
.
out
.
println
(
rs2
.
getInt
(
1
));
}
conn
.
close
();
}
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
280c7a28
...
...
@@ -283,7 +283,12 @@ java org.h2.test.TestAll timer
/*
arc
line breaks in grammar (specially select)
test performance with log=2
maybe make log=2 the default option
TRANSACTION_ID()
select 1 from dual a where 1 in(select 1 from dual b
where 1 in(select 1 from dual c where a.x=1));
...
...
h2/src/test/org/h2/test/unit/TestBitField.java
浏览文件 @
280c7a28
...
...
@@ -49,8 +49,14 @@ public class TestBitField extends TestBase {
}
private
void
testNextClearBit
()
{
Random
random
=
new
Random
(
1
);
BitSet
set
=
new
BitSet
(
);
BitField
field
=
new
BitField
();
set
.
set
(
0
,
640
);
field
.
setRange
(
0
,
640
,
true
);
assertEquals
(
set
.
nextClearBit
(
0
),
field
.
nextClearBit
(
0
));
Random
random
=
new
Random
(
1
);
field
=
new
BitField
();
field
.
setRange
(
0
,
500
,
true
);
for
(
int
i
=
0
;
i
<
100000
;
i
++)
{
int
a
=
random
.
nextInt
(
120
);
...
...
h2/src/test/org/h2/test/unit/TestFileLock.java
浏览文件 @
280c7a28
...
...
@@ -7,7 +7,9 @@
package
org
.
h2
.
test
.
unit
;
import
java.io.File
;
import
java.sql.SQLException
;
import
org.h2.engine.Constants
;
import
org.h2.message.TraceSystem
;
import
org.h2.store.FileLock
;
import
org.h2.test.TestBase
;
...
...
@@ -35,11 +37,37 @@ public class TestFileLock extends TestBase implements Runnable {
this
.
allowSockets
=
allowSockets
;
}
/**
* Run just this test.
*
* @param a ignored
*/
public
static
void
main
(
String
[]
a
)
throws
Exception
{
TestBase
.
createCaller
().
init
().
test
();
}
public
void
test
()
throws
Exception
{
testSimple
();
test
(
false
);
test
(
true
);
}
private
void
testSimple
()
throws
SQLException
{
FileLock
lock1
=
new
FileLock
(
new
TraceSystem
(
null
,
false
),
FILE
,
Constants
.
LOCK_SLEEP
);
FileLock
lock2
=
new
FileLock
(
new
TraceSystem
(
null
,
false
),
FILE
,
Constants
.
LOCK_SLEEP
);
lock1
.
lock
(
FileLock
.
LOCK_FILE
);
try
{
lock2
.
lock
(
FileLock
.
LOCK_FILE
);
fail
();
}
catch
(
Exception
e
)
{
// expected
}
lock1
.
unlock
();
lock2
=
new
FileLock
(
new
TraceSystem
(
null
,
false
),
FILE
,
Constants
.
LOCK_SLEEP
);
lock2
.
lock
(
FileLock
.
LOCK_FILE
);
lock2
.
unlock
();
}
private
void
test
(
boolean
allowSockets
)
throws
Exception
{
int
threadCount
=
getSize
(
3
,
5
);
wait
=
getSize
(
20
,
200
);
...
...
h2/src/test/org/h2/test/unit/TestPattern.java
浏览文件 @
280c7a28
...
...
@@ -17,6 +17,15 @@ import org.h2.value.CompareMode;
*/
public
class
TestPattern
extends
TestBase
{
/**
* Run just this test.
*
* @param a ignored
*/
public
static
void
main
(
String
[]
a
)
throws
Exception
{
TestBase
.
createCaller
().
init
().
test
();
}
public
void
test
()
throws
SQLException
{
CompareMode
mode
=
new
CompareMode
(
null
,
null
,
100
);
CompareLike
comp
=
new
CompareLike
(
mode
,
null
,
null
,
null
,
false
);
...
...
h2/src/test/org/h2/test/unit/TestReader.java
浏览文件 @
280c7a28
...
...
@@ -20,6 +20,15 @@ import org.h2.util.IOUtils;
*/
public
class
TestReader
extends
TestBase
{
/**
* Run just this test.
*
* @param a ignored
*/
public
static
void
main
(
String
[]
a
)
throws
Exception
{
TestBase
.
createCaller
().
init
().
test
();
}
public
void
test
()
throws
Exception
{
String
s
=
"\u00ef\u00f6\u00fc"
;
StringReader
r
=
new
StringReader
(
s
);
...
...
h2/src/test/org/h2/test/unit/TestRecovery.java
浏览文件 @
280c7a28
...
...
@@ -19,6 +19,15 @@ import org.h2.tools.DeleteDbFiles;
*/
public
class
TestRecovery
extends
TestBase
{
/**
* Run just this test.
*
* @param a ignored
*/
public
static
void
main
(
String
[]
a
)
throws
Exception
{
TestBase
.
createCaller
().
init
().
test
();
}
public
void
test
()
throws
SQLException
{
DeleteDbFiles
.
execute
(
baseDir
,
"recovery"
,
true
);
org
.
h2
.
Driver
.
load
();
...
...
h2/src/test/org/h2/test/unit/TestSampleApps.java
浏览文件 @
280c7a28
...
...
@@ -20,6 +20,15 @@ import org.h2.util.StringUtils;
*/
public
class
TestSampleApps
extends
TestBase
{
/**
* Run just this test.
*
* @param a ignored
*/
public
static
void
main
(
String
[]
a
)
throws
Exception
{
TestBase
.
createCaller
().
init
().
test
();
}
public
void
test
()
throws
Exception
{
deleteDb
(
"optimizations"
);
String
url
=
"jdbc:h2:"
+
baseDir
+
"/optimizations"
;
...
...
@@ -32,7 +41,7 @@ public class TestSampleApps extends TestBase {
+
"PHONE: +41123456789\n\n"
+
"NAME: John Jones\n"
+
"EMAIL: john.jones@abcde.abc\n"
+
"PHONE: +41976543210\n"
);
testApp
(
org
.
h2
.
samples
.
Function
.
class
,
null
,
"2 is prime\n3 is prime\n5 is prime\n7 is prime\n11 is prime\n13 is prime\n17 is prime\n19 is prime"
);
"2 is prime\n3 is prime\n5 is prime\n7 is prime\n11 is prime\n13 is prime\n17 is prime\n19 is prime
\n30\n20
"
);
// Not compatible with PostgreSQL JDBC driver (throws a NullPointerException)
//testApp(org.h2.samples.SecurePassword.class, null, "Joe");
// TODO test ShowProgress (percent numbers are hardware specific)
...
...
h2/src/tools/org/h2/build/doc/GenerateDoc.java
浏览文件 @
280c7a28
...
...
@@ -135,7 +135,8 @@ public class GenerateDoc {
String
topic
=
rs
.
getString
(
"TOPIC"
);
String
syntax
=
rs
.
getString
(
"SYNTAX"
);
syntax
=
PageParser
.
escapeHtml
(
syntax
);
syntax
=
StringUtils
.
replaceAll
(
syntax
,
"<br />"
,
" "
);
// if enabled, HTML docs get very wide
// syntax = StringUtils.replaceAll(syntax, "<br />", " ");
syntax
=
bnf
.
getSyntaxHtml
(
syntax
);
map
.
put
(
"syntax"
,
syntax
);
String
link
=
topic
.
toLowerCase
();
...
...
h2/src/tools/org/h2/build/doc/dictionary.txt
浏览文件 @
280c7a28
...
...
@@ -581,4 +581,4 @@ titles headers grew orchestration social razor finder ranging friend intervals
bot jot delicious rife appenders circles spelling cash sky ecm nuxeo poland
opengeospatial sfs symmetric obsolete failing parenthesis unloading refreshed
grails reloading slightly accepting deploying conflicting recovered counters
versus extracts squirrel misdirected rle looking arc
versus extracts squirrel misdirected rle looking arc
addressed european
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论