Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
3f6edd17
提交
3f6edd17
authored
9月 01, 2007
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
f447a3e4
全部展开
显示空白字符变更
内嵌
并排
正在显示
82 个修改的文件
包含
3289 行增加
和
3265 行删除
+3289
-3265
newsfeed.sql
h2/src/test/org/h2/samples/newsfeed.sql
+1
-1
newsfeed.xml
h2/src/test/org/h2/samples/newsfeed.xml
+1
-1
TestBackup.java
h2/src/test/org/h2/test/db/TestBackup.java
+3
-4
TestBatchUpdates.java
h2/src/test/org/h2/test/db/TestBatchUpdates.java
+25
-21
TestBigDb.java
h2/src/test/org/h2/test/db/TestBigDb.java
+40
-57
TestBigResult.java
h2/src/test/org/h2/test/db/TestBigResult.java
+33
-35
TestCases.java
h2/src/test/org/h2/test/db/TestCases.java
+164
-153
TestCheckpoint.java
h2/src/test/org/h2/test/db/TestCheckpoint.java
+5
-4
TestCluster.java
h2/src/test/org/h2/test/db/TestCluster.java
+25
-24
TestCsv.java
h2/src/test/org/h2/test/db/TestCsv.java
+33
-32
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+9
-8
TestIndex.java
h2/src/test/org/h2/test/db/TestIndex.java
+83
-80
TestLinkedTable.java
h2/src/test/org/h2/test/db/TestLinkedTable.java
+79
-63
TestListener.java
h2/src/test/org/h2/test/db/TestListener.java
+10
-10
TestLob.java
h2/src/test/org/h2/test/db/TestLob.java
+139
-144
TestLogFile.java
h2/src/test/org/h2/test/db/TestLogFile.java
+14
-14
TestMemoryUsage.java
h2/src/test/org/h2/test/db/TestMemoryUsage.java
+43
-44
TestMultiConn.java
h2/src/test/org/h2/test/db/TestMultiConn.java
+17
-17
TestMultiDimension.java
h2/src/test/org/h2/test/db/TestMultiDimension.java
+36
-41
TestMultiThread.java
h2/src/test/org/h2/test/db/TestMultiThread.java
+13
-13
TestOpenClose.java
h2/src/test/org/h2/test/db/TestOpenClose.java
+20
-19
TestOptimizations.java
h2/src/test/org/h2/test/db/TestOptimizations.java
+44
-41
TestPowerOff.java
h2/src/test/org/h2/test/db/TestPowerOff.java
+83
-83
TestReadOnly.java
h2/src/test/org/h2/test/db/TestReadOnly.java
+9
-9
TestRights.java
h2/src/test/org/h2/test/db/TestRights.java
+46
-41
TestRunscript.java
h2/src/test/org/h2/test/db/TestRunscript.java
+13
-12
TestScript.java
h2/src/test/org/h2/test/db/TestScript.java
+23
-25
TestScriptSimple.java
h2/src/test/org/h2/test/db/TestScriptSimple.java
+10
-10
TestSequence.java
h2/src/test/org/h2/test/db/TestSequence.java
+6
-6
TestSpaceReuse.java
h2/src/test/org/h2/test/db/TestSpaceReuse.java
+3
-2
TestTriggersConstraints.java
h2/src/test/org/h2/test/db/TestTriggersConstraints.java
+33
-25
TestView.java
h2/src/test/org/h2/test/db/TestView.java
+1
-0
clean.task
h2/src/test/org/h2/test/ftp/clean.task
+1
-1
testAll.task
h2/src/test/org/h2/test/ftp/testAll.task
+1
-1
testBtree.task
h2/src/test/org/h2/test/ftp/testBtree.task
+1
-1
testCrash.task
h2/src/test/org/h2/test/ftp/testCrash.task
+1
-1
testHalt.task
h2/src/test/org/h2/test/ftp/testHalt.task
+1
-1
testJoin.task
h2/src/test/org/h2/test/ftp/testJoin.task
+1
-1
testNormal.task
h2/src/test/org/h2/test/ftp/testNormal.task
+1
-1
testRandom.task
h2/src/test/org/h2/test/ftp/testRandom.task
+1
-1
testSynth.task
h2/src/test/org/h2/test/ftp/testSynth.task
+1
-1
TestCancel.java
h2/src/test/org/h2/test/jdbc/TestCancel.java
+20
-14
TestDataSource.java
h2/src/test/org/h2/test/jdbc/TestDataSource.java
+29
-27
TestManyJdbcObjects.java
h2/src/test/org/h2/test/jdbc/TestManyJdbcObjects.java
+20
-20
TestMetaData.java
h2/src/test/org/h2/test/jdbc/TestMetaData.java
+300
-275
TestNativeSQL.java
h2/src/test/org/h2/test/jdbc/TestNativeSQL.java
+49
-61
TestPreparedStatement.java
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
+225
-238
TestResultSet.java
h2/src/test/org/h2/test/jdbc/TestResultSet.java
+302
-335
TestStatement.java
h2/src/test/org/h2/test/jdbc/TestStatement.java
+88
-87
TestTransactionIsolation.java
h2/src/test/org/h2/test/jdbc/TestTransactionIsolation.java
+13
-12
TestUpdatableResultSet.java
h2/src/test/org/h2/test/jdbc/TestUpdatableResultSet.java
+77
-70
TestXASimple.java
h2/src/test/org/h2/test/jdbc/TestXASimple.java
+12
-12
TestZloty.java
h2/src/test/org/h2/test/jdbc/TestZloty.java
+14
-10
Column.java
h2/src/test/org/h2/test/synth/Column.java
+33
-48
Command.java
h2/src/test/org/h2/test/synth/Command.java
+51
-54
DbConnection.java
h2/src/test/org/h2/test/synth/DbConnection.java
+29
-29
DbInterface.java
h2/src/test/org/h2/test/synth/DbInterface.java
+14
-0
DbState.java
h2/src/test/org/h2/test/synth/DbState.java
+11
-11
Expression.java
h2/src/test/org/h2/test/synth/Expression.java
+55
-58
Index.java
h2/src/test/org/h2/test/synth/Index.java
+7
-7
RandomGen.java
h2/src/test/org/h2/test/synth/RandomGen.java
+43
-40
Result.java
h2/src/test/org/h2/test/synth/Result.java
+40
-36
Row.java
h2/src/test/org/h2/test/synth/Row.java
+16
-15
Table.java
h2/src/test/org/h2/test/synth/Table.java
+49
-48
TestBtreeIndex.java
h2/src/test/org/h2/test/synth/TestBtreeIndex.java
+32
-32
TestCrashAPI.java
h2/src/test/org/h2/test/synth/TestCrashAPI.java
+126
-128
TestHalt.java
h2/src/test/org/h2/test/synth/TestHalt.java
+62
-55
TestHaltApp.java
h2/src/test/org/h2/test/synth/TestHaltApp.java
+28
-27
TestJoin.java
h2/src/test/org/h2/test/synth/TestJoin.java
+84
-88
TestKill.java
h2/src/test/org/h2/test/synth/TestKill.java
+27
-31
TestKillProcess.java
h2/src/test/org/h2/test/synth/TestKillProcess.java
+16
-16
TestMulti.java
h2/src/test/org/h2/test/synth/TestMulti.java
+6
-6
TestMultiNews.java
h2/src/test/org/h2/test/synth/TestMultiNews.java
+31
-37
TestMultiNewsSimple.java
h2/src/test/org/h2/test/synth/TestMultiNewsSimple.java
+16
-15
TestMultiOrder.java
h2/src/test/org/h2/test/synth/TestMultiOrder.java
+16
-12
TestMultiThread.java
h2/src/test/org/h2/test/synth/TestMultiThread.java
+12
-8
TestRandomSQL.java
h2/src/test/org/h2/test/synth/TestRandomSQL.java
+37
-37
TestSimpleIndex.java
h2/src/test/org/h2/test/synth/TestSimpleIndex.java
+26
-26
TestSynth.java
h2/src/test/org/h2/test/synth/TestSynth.java
+103
-95
TestThreads.java
h2/src/test/org/h2/test/synth/TestThreads.java
+32
-32
TestTimer.java
h2/src/test/org/h2/test/synth/TestTimer.java
+8
-8
Value.java
h2/src/test/org/h2/test/synth/Value.java
+57
-57
没有找到文件。
h2/src/test/org/h2/samples/newsfeed.sql
浏览文件 @
3f6edd17
h2/src/test/org/h2/samples/newsfeed.xml
浏览文件 @
3f6edd17
h2/src/test/org/h2/test/db/TestBackup.java
浏览文件 @
3f6edd17
...
...
@@ -13,7 +13,7 @@ import org.h2.tools.Restore;
public
class
TestBackup
extends
TestBase
{
public
void
test
()
throws
Exception
{
if
(
config
.
memory
||
config
.
logMode
==
0
)
{
if
(
config
.
memory
||
config
.
logMode
==
0
)
{
return
;
}
testBackup
();
...
...
@@ -51,4 +51,3 @@ public class TestBackup extends TestBase {
}
}
h2/src/test/org/h2/test/db/TestBatchUpdates.java
浏览文件 @
3f6edd17
...
...
@@ -4,7 +4,12 @@
*/
package
org
.
h2
.
test
.
db
;
import
java.sql.*
;
import
java.sql.BatchUpdateException
;
import
java.sql.Connection
;
import
java.sql.DatabaseMetaData
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.Statement
;
import
org.h2.test.TestBase
;
...
...
@@ -75,7 +80,7 @@ public class TestBatchUpdates extends TestBase {
public
void
testAddBatch01
()
throws
Exception
{
trace
(
"testAddBatch01"
);
int
i
=
0
;
int
[]
retValue
=
{
0
,
0
,
0
};
int
[]
retValue
=
{
0
,
0
,
0
};
String
s
=
COFFEE_UPDATE
;
trace
(
"Prepared Statement String:"
+
s
);
prep
=
conn
.
prepareStatement
(
s
);
...
...
@@ -88,15 +93,14 @@ public class TestBatchUpdates extends TestBase {
int
[]
updateCount
=
prep
.
executeBatch
();
int
updateCountLen
=
updateCount
.
length
;
// PreparedStatement p;
// p = conn.prepareStatement(COFFEE_UPDATE);
// p.setInt(1,2);
// System.out.println("upc="+p.executeUpdate());
// p.setInt(1,3);
// System.out.println("upc="+p.executeUpdate());
// p.setInt(1,4);
// System.out.println("upc="+p.executeUpdate());
// PreparedStatement p;
// p = conn.prepareStatement(COFFEE_UPDATE);
// p.setInt(1,2);
// System.out.println("upc="+p.executeUpdate());
// p.setInt(1,3);
// System.out.println("upc="+p.executeUpdate());
// p.setInt(1,4);
// System.out.println("upc="+p.executeUpdate());
trace
(
"updateCount length:"
+
updateCountLen
);
if
(
updateCountLen
!=
3
)
{
...
...
@@ -125,7 +129,7 @@ public class TestBatchUpdates extends TestBase {
public
void
testAddBatch02
()
throws
Exception
{
trace
(
"testAddBatch02"
);
int
i
=
0
;
int
[]
retValue
=
{
0
,
0
,
0
};
int
[]
retValue
=
{
0
,
0
,
0
};
int
updCountLength
=
0
;
String
sUpdCoffee
=
COFFEE_UPDATE1
;
String
sDelCoffee
=
COFFEE_DELETE1
;
...
...
@@ -203,7 +207,7 @@ public class TestBatchUpdates extends TestBase {
public
void
testExecuteBatch01
()
throws
Exception
{
trace
(
"testExecuteBatch01"
);
int
i
=
0
;
int
[]
retValue
=
{
0
,
0
,
0
};
int
[]
retValue
=
{
0
,
0
,
0
};
int
updCountLength
=
0
;
String
sPrepStmt
=
COFFEE_UPDATE
;
trace
(
"Prepared Statement String:"
+
sPrepStmt
);
...
...
@@ -224,9 +228,9 @@ public class TestBatchUpdates extends TestBase {
}
else
{
trace
(
"executeBatch executes the Batch of SQL statements"
);
}
//1 is the number that is set First for Type Id in Prepared Statement
//
1 is the number that is set First for Type Id in Prepared Statement
String
query1
=
"SELECT COUNT(*) FROM TEST WHERE TYPE_ID=1"
;
//2 is the number that is set second for Type id in Prepared Statement
//
2 is the number that is set second for Type id in Prepared Statement
String
query2
=
"SELECT COUNT(*) FROM TEST WHERE TYPE_ID=2"
;
// 3 is the number that is set Third for Type id in Prepared Statement
String
query3
=
"SELECT COUNT(*) FROM TEST WHERE TYPE_ID=3"
;
...
...
@@ -291,7 +295,7 @@ public class TestBatchUpdates extends TestBase {
public
void
testExecuteBatch04
()
throws
Exception
{
trace
(
"testExecuteBatch04"
);
int
i
=
0
;
int
[]
retValue
=
{
0
,
0
,
0
};
int
[]
retValue
=
{
0
,
0
,
0
};
int
updCountLength
=
0
;
String
sUpdCoffee
=
COFFEE_UPDATE1
;
String
sInsCoffee
=
COFFEE_INSERT1
;
...
...
@@ -340,7 +344,7 @@ public class TestBatchUpdates extends TestBase {
public
void
testExecuteBatch06
()
throws
Exception
{
trace
(
"testExecuteBatch06"
);
boolean
batchExceptionFlag
=
false
;
//Insert a row which is already Present
//
Insert a row which is already Present
String
sInsCoffee
=
COFFEE_INSERT1
;
String
sDelCoffee
=
COFFEE_DELETE1
;
stat
.
addBatch
(
sInsCoffee
);
...
...
@@ -384,7 +388,7 @@ public class TestBatchUpdates extends TestBase {
public
void
testContinueBatch01
()
throws
Exception
{
trace
(
"testContinueBatch01"
);
int
[]
batchUpdates
=
{
0
,
0
,
0
};
int
[]
batchUpdates
=
{
0
,
0
,
0
};
int
buCountLen
=
0
;
try
{
String
sPrepStmt
=
COFFEE_UPDATE_SET
;
...
...
h2/src/test/org/h2/test/db/TestBigDb.java
浏览文件 @
3f6edd17
...
...
@@ -15,10 +15,10 @@ import org.h2.util.MemoryUtils;
public
class
TestBigDb
extends
TestBase
{
public
void
test
()
throws
Exception
{
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
}
if
(
config
.
networked
&&
config
.
big
)
{
if
(
config
.
networked
&&
config
.
big
)
{
return
;
}
testLargeTable
();
...
...
@@ -30,51 +30,35 @@ public class TestBigDb extends TestBase {
deleteDb
(
"bigDb"
);
Connection
conn
=
getConnection
(
"bigDb"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE CACHED TABLE TEST("
+
"M_CODE CHAR(1) DEFAULT CAST(RAND()*9 AS INT),"
+
"PRD_CODE CHAR(20) DEFAULT SECURE_RAND(10),"
+
"ORG_CODE_SUPPLIER CHAR(13) DEFAULT SECURE_RAND(6),"
+
"PRD_CODE_1 CHAR(14) DEFAULT SECURE_RAND(7),"
+
"PRD_CODE_2 CHAR(20) DEFAULT SECURE_RAND(10),"
+
"ORG_CODE CHAR(13) DEFAULT SECURE_RAND(6),"
+
"SUBSTITUTED_BY CHAR(20) DEFAULT SECURE_RAND(10),"
+
"SUBSTITUTED_BY_2 CHAR(14) DEFAULT SECURE_RAND(7),"
+
"SUBSTITUTION_FOR CHAR(20) DEFAULT SECURE_RAND(10),"
+
"SUBSTITUTION_FOR_2 CHAR(14) DEFAULT SECURE_RAND(7),"
+
"TEST CHAR(2) DEFAULT SECURE_RAND(1),"
+
"TEST_2 CHAR(2) DEFAULT SECURE_RAND(1),"
+
"TEST_3 DECIMAL(7,2) DEFAULT RAND(),"
+
"PRIMARY_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"
+
"RATE_PRICE_ORDER_UNIT DECIMAL(9,3) DEFAULT RAND(),"
+
"ORDER_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"
+
"ORDER_QTY_MIN DECIMAL(6,1) DEFAULT RAND(),"
+
"ORDER_QTY_LOT_SIZE DECIMAL(6,1) DEFAULT RAND(),"
+
"ORDER_UNIT_CODE_2 CHAR(3) DEFAULT SECURE_RAND(1),"
+
"PRICE_GROUP CHAR(20) DEFAULT SECURE_RAND(10),"
+
"LEAD_TIME INTEGER DEFAULT RAND(),"
+
"LEAD_TIME_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"
+
"PRD_GROUP CHAR(10) DEFAULT SECURE_RAND(5),"
+
"WEIGHT_GROSS DECIMAL(7,3) DEFAULT RAND(),"
+
"WEIGHT_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"
+
"PACK_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"
+
"PACK_LENGTH DECIMAL(7,3) DEFAULT RAND(),"
+
"PACK_WIDTH DECIMAL(7,3) DEFAULT RAND(),"
+
"PACK_HEIGHT DECIMAL(7,3) DEFAULT RAND(),"
+
"SIZE_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"
+
"STATUS_CODE CHAR(3) DEFAULT SECURE_RAND(1),"
+
"INTRA_STAT_CODE CHAR(12) DEFAULT SECURE_RAND(6),"
+
"PRD_TITLE CHAR(50) DEFAULT SECURE_RAND(25),"
+
"VALID_FROM DATE DEFAULT NOW(),"
+
"MOD_DATUM DATE DEFAULT NOW())"
);
stat
.
execute
(
"CREATE CACHED TABLE TEST("
+
"M_CODE CHAR(1) DEFAULT CAST(RAND()*9 AS INT),"
+
"PRD_CODE CHAR(20) DEFAULT SECURE_RAND(10),"
+
"ORG_CODE_SUPPLIER CHAR(13) DEFAULT SECURE_RAND(6),"
+
"PRD_CODE_1 CHAR(14) DEFAULT SECURE_RAND(7),"
+
"PRD_CODE_2 CHAR(20) DEFAULT SECURE_RAND(10),"
+
"ORG_CODE CHAR(13) DEFAULT SECURE_RAND(6),"
+
"SUBSTITUTED_BY CHAR(20) DEFAULT SECURE_RAND(10),"
+
"SUBSTITUTED_BY_2 CHAR(14) DEFAULT SECURE_RAND(7),"
+
"SUBSTITUTION_FOR CHAR(20) DEFAULT SECURE_RAND(10),"
+
"SUBSTITUTION_FOR_2 CHAR(14) DEFAULT SECURE_RAND(7),"
+
"TEST CHAR(2) DEFAULT SECURE_RAND(1),"
+
"TEST_2 CHAR(2) DEFAULT SECURE_RAND(1),"
+
"TEST_3 DECIMAL(7,2) DEFAULT RAND(),"
+
"PRIMARY_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"
+
"RATE_PRICE_ORDER_UNIT DECIMAL(9,3) DEFAULT RAND(),"
+
"ORDER_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"
+
"ORDER_QTY_MIN DECIMAL(6,1) DEFAULT RAND(),"
+
"ORDER_QTY_LOT_SIZE DECIMAL(6,1) DEFAULT RAND(),"
+
"ORDER_UNIT_CODE_2 CHAR(3) DEFAULT SECURE_RAND(1),"
+
"PRICE_GROUP CHAR(20) DEFAULT SECURE_RAND(10),"
+
"LEAD_TIME INTEGER DEFAULT RAND(),"
+
"LEAD_TIME_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"
+
"PRD_GROUP CHAR(10) DEFAULT SECURE_RAND(5),"
+
"WEIGHT_GROSS DECIMAL(7,3) DEFAULT RAND(),"
+
"WEIGHT_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"
+
"PACK_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"
+
"PACK_LENGTH DECIMAL(7,3) DEFAULT RAND(),"
+
"PACK_WIDTH DECIMAL(7,3) DEFAULT RAND(),"
+
"PACK_HEIGHT DECIMAL(7,3) DEFAULT RAND(),"
+
"SIZE_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"
+
"STATUS_CODE CHAR(3) DEFAULT SECURE_RAND(1),"
+
"INTRA_STAT_CODE CHAR(12) DEFAULT SECURE_RAND(6),"
+
"PRD_TITLE CHAR(50) DEFAULT SECURE_RAND(25),"
+
"VALID_FROM DATE DEFAULT NOW(),"
+
"MOD_DATUM DATE DEFAULT NOW())"
);
int
len
=
getSize
(
10
,
50000
);
try
{
PreparedStatement
prep
=
conn
.
prepareStatement
(
"INSERT INTO TEST(PRD_CODE) VALUES('abc' || ?)"
);
long
time
=
System
.
currentTimeMillis
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
if
((
i
%
1000
)
==
0
)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
if
((
i
%
1000
)
==
0
)
{
long
t
=
System
.
currentTimeMillis
();
if
(
t
-
time
>
1000
)
{
if
(
t
-
time
>
1000
)
{
time
=
t
;
int
free
=
MemoryUtils
.
getMemoryFree
();
System
.
out
.
println
(
"i: "
+
i
+
" free: "
+
free
+
" used: "
+
MemoryUtils
.
getMemoryUsed
());
...
...
@@ -86,12 +70,12 @@ public class TestBigDb extends TestBase {
stat
.
execute
(
"CREATE INDEX IDX_TEST_PRD_CODE ON TEST(PRD_CODE)"
);
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST"
);
int
columns
=
rs
.
getMetaData
().
getColumnCount
();
while
(
rs
.
next
())
{
for
(
int
i
=
0
;
i
<
columns
;
i
++)
{
rs
.
getString
(
i
+
1
);
while
(
rs
.
next
())
{
for
(
int
i
=
0
;
i
<
columns
;
i
++)
{
rs
.
getString
(
i
+
1
);
}
}
}
catch
(
OutOfMemoryError
e
)
{
}
catch
(
OutOfMemoryError
e
)
{
TestBase
.
logError
(
"memory"
,
e
);
conn
.
close
();
throw
e
;
...
...
@@ -109,9 +93,9 @@ public class TestBigDb extends TestBase {
int
len
=
getSize
(
10
,
1000
);
int
block
=
getSize
(
3
,
10
);
int
left
,
x
=
0
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
left
=
x
+
block
/
2
;
for
(
int
j
=
0
;
j
<
block
;
j
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
left
=
x
+
block
/
2
;
for
(
int
j
=
0
;
j
<
block
;
j
++)
{
prep
.
setInt
(
1
,
x
++);
prep
.
execute
();
}
...
...
@@ -132,11 +116,11 @@ public class TestBigDb extends TestBase {
PreparedStatement
prep
=
conn
.
prepareStatement
(
"INSERT INTO TEST(NAME) VALUES('Hello World')"
);
int
len
=
getSize
(
1000
,
10000
);
long
time
=
System
.
currentTimeMillis
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
if
(
i
%
1000
==
0
)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
if
(
i
%
1000
==
0
)
{
long
t
=
System
.
currentTimeMillis
();
time
=
t
;
trace
(
"rows:"
+
i
+
" time:"
+
(
t
-
time
));
trace
(
"rows:"
+
i
+
" time:"
+
(
t
-
time
));
Thread
.
yield
();
}
prep
.
execute
();
...
...
@@ -144,5 +128,4 @@ public class TestBigDb extends TestBase {
conn
.
close
();
}
}
h2/src/test/org/h2/test/db/TestBigResult.java
浏览文件 @
3f6edd17
...
...
@@ -4,7 +4,10 @@
*/
package
org
.
h2
.
test
.
db
;
import
java.sql.*
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.Statement
;
import
java.util.ArrayList
;
import
org.h2.store.FileLister
;
...
...
@@ -12,7 +15,7 @@ import org.h2.test.TestBase;
public
class
TestBigResult
extends
TestBase
{
public
void
test
()
throws
Exception
{
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
}
testCloseConnectionDelete
();
...
...
@@ -26,14 +29,14 @@ public class TestBigResult extends TestBase {
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"SET MAX_MEMORY_ROWS 2"
);
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM SYSTEM_RANGE(1, 100)"
);
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
// ignore
}
// rs.close();
conn
.
close
();
deleteDb
(
"bigResult"
);
ArrayList
files
=
FileLister
.
getDatabaseFiles
(
baseDir
,
"bigResult"
,
true
);
if
(
files
.
size
()
>
0
)
{
if
(
files
.
size
()
>
0
)
{
error
(
"file not deleted: "
+
files
.
get
(
0
));
}
}
...
...
@@ -44,21 +47,21 @@ public class TestBigResult extends TestBase {
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"DROP TABLE IF EXISTS TEST"
);
stat
.
execute
(
"CREATE TABLE TEST(ID INT)"
);
for
(
int
i
=
0
;
i
<
200
;
i
++)
{
stat
.
execute
(
"INSERT INTO TEST(ID) VALUES("
+
i
+
")"
);
for
(
int
i
=
0
;
i
<
200
;
i
++)
{
stat
.
execute
(
"INSERT INTO TEST(ID) VALUES("
+
i
+
")"
);
}
stat
.
execute
(
"SET MAX_MEMORY_ROWS 100"
);
ResultSet
rs
;
rs
=
stat
.
executeQuery
(
"select id from test order by id limit 10 offset 85"
);
for
(
int
i
=
85
;
rs
.
next
();
i
++)
{
for
(
int
i
=
85
;
rs
.
next
();
i
++)
{
check
(
i
,
rs
.
getInt
(
1
));
}
rs
=
stat
.
executeQuery
(
"select id from test order by id limit 10 offset 95"
);
for
(
int
i
=
95
;
rs
.
next
();
i
++)
{
for
(
int
i
=
95
;
rs
.
next
();
i
++)
{
check
(
i
,
rs
.
getInt
(
1
));
}
rs
=
stat
.
executeQuery
(
"select id from test order by id limit 10 offset 105"
);
for
(
int
i
=
105
;
rs
.
next
();
i
++)
{
for
(
int
i
=
105
;
rs
.
next
();
i
++)
{
check
(
i
,
rs
.
getInt
(
1
));
}
conn
.
close
();
...
...
@@ -69,19 +72,16 @@ public class TestBigResult extends TestBase {
Connection
conn
=
getConnection
(
"bigResult"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"DROP TABLE IF EXISTS TEST"
);
stat
.
execute
(
"CREATE TABLE TEST("
+
"ID INT PRIMARY KEY, "
+
"Name VARCHAR(255), "
+
"FirstName VARCHAR(255), "
+
"Points INT,"
+
"LicenseID INT)"
);
stat
.
execute
(
"CREATE TABLE TEST("
+
"ID INT PRIMARY KEY, "
+
"Name VARCHAR(255), "
+
"FirstName VARCHAR(255), "
+
"Points INT,"
+
"LicenseID INT)"
);
int
len
=
getSize
(
10
,
5000
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"INSERT INTO TEST VALUES(?, ?, ?, ?, ?)"
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
prep
.
setInt
(
1
,
i
);
prep
.
setString
(
2
,
"Name "
+
i
);
prep
.
setString
(
3
,
"First Name "
+
i
);
prep
.
setInt
(
4
,
i
*
10
);
prep
.
setInt
(
5
,
i
*
i
);
prep
.
setInt
(
4
,
i
*
10
);
prep
.
setInt
(
5
,
i
*
i
);
prep
.
execute
();
}
conn
.
close
();
...
...
@@ -89,29 +89,29 @@ public class TestBigResult extends TestBase {
stat
=
conn
.
createStatement
();
stat
.
setMaxRows
(
len
+
1
);
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST ORDER BY ID"
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
rs
.
next
();
check
(
i
,
rs
.
getInt
(
1
));
check
(
"Name "
+
i
,
rs
.
getString
(
2
));
check
(
"First Name "
+
i
,
rs
.
getString
(
3
));
check
(
i
*
10
,
rs
.
getInt
(
4
));
check
(
i
*
i
,
rs
.
getInt
(
5
));
check
(
i
*
10
,
rs
.
getInt
(
4
));
check
(
i
*
i
,
rs
.
getInt
(
5
));
}
stat
.
setMaxRows
(
len
+
1
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST WHERE ID >= 1000 ORDER BY ID"
);
for
(
int
i
=
1000
;
i
<
len
;
i
++)
{
for
(
int
i
=
1000
;
i
<
len
;
i
++)
{
rs
.
next
();
check
(
i
,
rs
.
getInt
(
1
));
check
(
"Name "
+
i
,
rs
.
getString
(
2
));
check
(
"First Name "
+
i
,
rs
.
getString
(
3
));
check
(
i
*
10
,
rs
.
getInt
(
4
));
check
(
i
*
i
,
rs
.
getInt
(
5
));
check
(
i
*
10
,
rs
.
getInt
(
4
));
check
(
i
*
i
,
rs
.
getInt
(
5
));
}
stat
.
execute
(
"SET MAX_MEMORY_ROWS 2"
);
rs
=
stat
.
executeQuery
(
"SELECT Name, SUM(ID) FROM TEST GROUP BY NAME"
);
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
rs
.
getString
(
1
);
rs
.
getInt
(
2
);
}
...
...
@@ -121,9 +121,9 @@ public class TestBigResult extends TestBase {
stat
.
execute
(
"SET MAX_MEMORY_ROWS 0"
);
stat
.
execute
(
"CREATE TABLE DATA(ID INT, NAME VARCHAR_IGNORECASE(255))"
);
prep
=
conn
.
prepareStatement
(
"INSERT INTO DATA VALUES(?, ?)"
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
prep
.
setInt
(
1
,
i
);
prep
.
setString
(
2
,
""
+
i
/
200
);
prep
.
setString
(
2
,
""
+
i
/
200
);
prep
.
execute
();
}
Statement
s2
=
conn
.
createStatement
(
ResultSet
.
TYPE_SCROLL_INSENSITIVE
,
ResultSet
.
CONCUR_UPDATABLE
);
...
...
@@ -132,13 +132,11 @@ public class TestBigResult extends TestBase {
conn
.
setAutoCommit
(
true
);
rs
=
s2
.
executeQuery
(
"SELECT NAME FROM DATA ORDER BY ID"
);
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
// do nothing
}
conn
.
close
();
}
}
h2/src/test/org/h2/test/db/TestCases.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/db/TestCheckpoint.java
浏览文件 @
3f6edd17
...
...
@@ -4,7 +4,8 @@
*/
package
org
.
h2
.
test
.
db
;
import
java.sql.*
;
import
java.sql.Connection
;
import
java.sql.Statement
;
import
org.h2.test.TestBase
;
...
...
h2/src/test/org/h2/test/db/TestCluster.java
浏览文件 @
3f6edd17
...
...
@@ -19,12 +19,12 @@ import org.h2.tools.Server;
public
class
TestCluster
extends
TestBase
{
public
void
test
()
throws
Exception
{
if
(
config
.
memory
||
config
.
networked
)
{
if
(
config
.
memory
||
config
.
networked
)
{
return
;
}
DeleteDbFiles
.
main
(
new
String
[]
{
"-dir"
,
baseDir
+
"/node1"
,
"-quiet"
});
DeleteDbFiles
.
main
(
new
String
[]
{
"-dir"
,
baseDir
+
"/node2"
,
"-quiet"
});
DeleteDbFiles
.
main
(
new
String
[]
{
"-dir"
,
baseDir
+
"/node1"
,
"-quiet"
});
DeleteDbFiles
.
main
(
new
String
[]
{
"-dir"
,
baseDir
+
"/node2"
,
"-quiet"
});
// create the master database
Connection
conn
;
...
...
@@ -36,34 +36,33 @@ public class TestCluster extends TestBase {
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"INSERT INTO TEST VALUES(?, ?)"
);
int
len
=
getSize
(
10
,
1000
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
prep
.
setInt
(
1
,
i
);
prep
.
setString
(
2
,
"Data"
+
i
);
prep
.
executeUpdate
();
}
conn
.
close
();
CreateCluster
.
main
(
new
String
[]{
"-urlSource"
,
"jdbc:h2:file:"
+
baseDir
+
"/node1/test"
,
"-urlTarget"
,
"jdbc:h2:file:"
+
baseDir
+
"/node2/test"
,
"-user"
,
"sa"
,
"-serverlist"
,
"localhost:9091,localhost:9092"
});
CreateCluster
.
main
(
new
String
[]
{
"-urlSource"
,
"jdbc:h2:file:"
+
baseDir
+
"/node1/test"
,
"-urlTarget"
,
"jdbc:h2:file:"
+
baseDir
+
"/node2/test"
,
"-user"
,
"sa"
,
"-serverlist"
,
"localhost:9091,localhost:9092"
});
Server
n1
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
new
String
[]{
"-tcpPort"
,
"9091"
,
"-baseDir"
,
baseDir
+
"/node1"
}).
start
();
Server
n2
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
new
String
[]{
"-tcpPort"
,
"9092"
,
"-baseDir"
,
baseDir
+
"/node2"
}).
start
();
Server
n1
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
new
String
[]
{
"-tcpPort"
,
"9091"
,
"-baseDir"
,
baseDir
+
"/node1"
}).
start
();
Server
n2
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
new
String
[]
{
"-tcpPort"
,
"9092"
,
"-baseDir"
,
baseDir
+
"/node2"
}).
start
();
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9091/test"
,
"sa"
,
""
);
error
(
"should not be able to connect in standalone mode"
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9092/test"
,
"sa"
,
""
);
error
(
"should not be able to connect in standalone mode"
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
@@ -79,13 +78,15 @@ public class TestCluster extends TestBase {
conn
.
close
();
n2
.
stop
();
n1
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
new
String
[]{
"-tcpPort"
,
"9091"
,
"-baseDir"
,
baseDir
+
"/node1"
}).
start
();
n1
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
new
String
[]
{
"-tcpPort"
,
"9091"
,
"-baseDir"
,
baseDir
+
"/node1"
})
.
start
();
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9091/test;CLUSTER=''"
,
"sa"
,
""
);
check
(
conn
,
len
);
conn
.
close
();
n1
.
stop
();
n2
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
new
String
[]{
"-tcpPort"
,
"9092"
,
"-baseDir"
,
baseDir
+
"/node2"
}).
start
();
n2
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
new
String
[]
{
"-tcpPort"
,
"9092"
,
"-baseDir"
,
baseDir
+
"/node2"
})
.
start
();
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9092/test;CLUSTER=''"
,
"sa"
,
""
);
check
(
conn
,
len
);
conn
.
createStatement
().
execute
(
"SELECT * FROM A"
);
...
...
@@ -95,11 +96,11 @@ public class TestCluster extends TestBase {
void
check
(
Connection
conn
,
int
len
)
throws
Exception
{
PreparedStatement
prep
=
conn
.
prepareStatement
(
"SELECT * FROM TEST WHERE ID=?"
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
prep
.
setInt
(
1
,
i
);
ResultSet
rs
=
prep
.
executeQuery
();
rs
.
next
();
check
(
rs
.
getString
(
2
),
"Data"
+
i
);
check
(
rs
.
getString
(
2
),
"Data"
+
i
);
checkFalse
(
rs
.
next
());
}
}
...
...
h2/src/test/org/h2/test/db/TestCsv.java
浏览文件 @
3f6edd17
...
...
@@ -27,19 +27,20 @@ public class TestCsv extends TestBase {
deleteDb
(
"csv"
);
Connection
conn
=
getConnection
(
"csv"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"call csvwrite('"
+
baseDir
+
"/test.csv', 'select 1 id, ''Hello'' name', 'utf-8', '|')"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select * from csvread('"
+
baseDir
+
"/test.csv', null, 'utf-8', '|')"
);
stat
.
execute
(
"call csvwrite('"
+
baseDir
+
"/test.csv', 'select 1 id, ''Hello'' name', 'utf-8', '|')"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select * from csvread('"
+
baseDir
+
"/test.csv', null, 'utf-8', '|')"
);
check
(
rs
.
next
());
check
(
rs
.
getInt
(
1
),
1
);
check
(
rs
.
getString
(
2
),
"Hello"
);
checkFalse
(
rs
.
next
());
new
File
(
baseDir
+
"/test.csv"
).
delete
();
new
File
(
baseDir
+
"/test.csv"
).
delete
();
// PreparedStatement prep = conn.prepareStatement("select * from csvread(?, null, ?, ?)");
// prep.setString(1, BASE_DIR+"/test.csv");
// prep.setString(2, "utf-8");
// prep.setString(3, "|");
// rs = prep.executeQuery();
// PreparedStatement prep = conn.prepareStatement("select * from
// csvread(?, null, ?, ?)");
// prep.setString(1, BASE_DIR+"/test.csv");
// prep.setString(2, "utf-8");
// prep.setString(3, "|");
// rs = prep.executeQuery();
conn
.
close
();
}
...
...
@@ -48,17 +49,17 @@ public class TestCsv extends TestBase {
deleteDb
(
"csv"
);
Connection
conn
=
getConnection
(
"csv"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"call csvwrite('"
+
baseDir
+
"/test.csv', 'select 1 id, ''Hello'' name')"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select name from csvread('"
+
baseDir
+
"/test.csv')"
);
stat
.
execute
(
"call csvwrite('"
+
baseDir
+
"/test.csv', 'select 1 id, ''Hello'' name')"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select name from csvread('"
+
baseDir
+
"/test.csv')"
);
check
(
rs
.
next
());
check
(
rs
.
getString
(
1
),
"Hello"
);
checkFalse
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"call csvread('"
+
baseDir
+
"/test.csv')"
);
rs
=
stat
.
executeQuery
(
"call csvread('"
+
baseDir
+
"/test.csv')"
);
check
(
rs
.
next
());
check
(
rs
.
getInt
(
1
),
1
);
check
(
rs
.
getString
(
2
),
"Hello"
);
checkFalse
(
rs
.
next
());
new
File
(
baseDir
+
"/test.csv"
).
delete
();
new
File
(
baseDir
+
"/test.csv"
).
delete
();
conn
.
close
();
}
...
...
@@ -97,13 +98,13 @@ public class TestCsv extends TestBase {
check
(
rs
.
getString
(
4
),
"8"
);
checkFalse
(
rs
.
next
());
//
a,b,c,d
//
201,-2,0,18
//
201,2,0,18
//
201,2,0,18
//
201,2,0,18
//
201,2,0,18
//
201,2,0,18
//
a,b,c,d
//
201,-2,0,18
//
201,2,0,18
//
201,2,0,18
//
201,2,0,18
//
201,2,0,18
//
201,2,0,18
}
public
void
testWriteRead
()
throws
Exception
{
...
...
@@ -114,7 +115,7 @@ public class TestCsv extends TestBase {
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TABLE TEST(ID IDENTITY, NAME VARCHAR)"
);
int
len
=
100
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
stat
.
execute
(
"INSERT INTO TEST(NAME) VALUES('Ruebezahl')"
);
}
Csv
.
getInstance
().
write
(
conn
,
baseDir
+
"/testRW.csv"
,
"SELECT * FROM TEST"
,
"UTF8"
);
...
...
@@ -122,9 +123,9 @@ public class TestCsv extends TestBase {
// stat.execute("CREATE ALIAS CSVREAD FOR \"org.h2.tools.Csv.read\"");
ResultSetMetaData
meta
=
rs
.
getMetaData
();
check
(
2
,
meta
.
getColumnCount
());
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
rs
.
next
();
check
(
rs
.
getString
(
"ID"
),
""
+
(
i
+
1
));
check
(
rs
.
getString
(
"ID"
),
""
+
(
i
+
1
));
check
(
rs
.
getString
(
"NAME"
),
"Ruebezahl"
);
}
checkFalse
(
rs
.
next
());
...
...
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
3f6edd17
...
...
@@ -137,11 +137,11 @@ public class TestFunctions extends TestBase {
stat
.
execute
(
"INSERT INTO TEST_BLOB VALUES(0, null)"
);
stat
.
execute
(
"INSERT INTO TEST_BLOB VALUES(1, 'edd1f011edd1f011edd1f011')"
);
rs
=
stat
.
executeQuery
(
"SELECT blob2stream(VALUE) FROM TEST_BLOB"
);
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
}
rs
.
close
();
rs
=
stat
.
executeQuery
(
"SELECT stream2stream(VALUE) FROM TEST_BLOB"
);
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
// ignore
}
...
...
@@ -163,7 +163,7 @@ public class TestFunctions extends TestBase {
}
public
static
BufferedInputStream
blob2stream
(
Blob
value
)
throws
SQLException
{
if
(
value
==
null
)
{
if
(
value
==
null
)
{
return
null
;
}
BufferedInputStream
bufferedInStream
=
new
BufferedInputStream
(
value
.
getBinaryStream
());
...
...
@@ -171,7 +171,7 @@ public class TestFunctions extends TestBase {
}
public
static
BufferedInputStream
stream2stream
(
InputStream
value
)
throws
SQLException
{
if
(
value
==
null
)
{
if
(
value
==
null
)
{
return
null
;
}
BufferedInputStream
bufferedInStream
=
new
BufferedInputStream
(
value
);
...
...
@@ -205,7 +205,8 @@ public class TestFunctions extends TestBase {
return
statement
.
executeQuery
();
}
public
static
ResultSet
simpleResultSet
(
Integer
count
,
int
ip
,
boolean
bp
,
float
fp
,
double
dp
,
long
lp
,
byte
byParam
,
short
sp
)
throws
SQLException
{
public
static
ResultSet
simpleResultSet
(
Integer
count
,
int
ip
,
boolean
bp
,
float
fp
,
double
dp
,
long
lp
,
byte
byParam
,
short
sp
)
throws
SQLException
{
SimpleResultSet
rs
=
new
SimpleResultSet
();
rs
.
addColumn
(
"ID"
,
Types
.
INTEGER
,
10
,
0
);
rs
.
addColumn
(
"NAME"
,
Types
.
VARCHAR
,
255
,
0
);
...
...
h2/src/test/org/h2/test/db/TestIndex.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/db/TestLinkedTable.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/db/TestListener.java
浏览文件 @
3f6edd17
...
...
@@ -21,7 +21,7 @@ public class TestListener extends TestBase implements DatabaseEventListener {
}
public
void
test
()
throws
Exception
{
if
(
config
.
networked
)
{
if
(
config
.
networked
)
{
return
;
}
deleteDb
(
"listener"
);
...
...
@@ -31,7 +31,7 @@ public class TestListener extends TestBase implements DatabaseEventListener {
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"INSERT INTO TEST VALUES(?, 'Test' || SPACE(100))"
);
int
len
=
getSize
(
100
,
100000
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
prep
.
setInt
(
1
,
i
);
prep
.
execute
();
}
...
...
@@ -43,7 +43,7 @@ public class TestListener extends TestBase implements DatabaseEventListener {
}
public
void
diskSpaceIsLow
(
long
stillAvailable
)
throws
SQLException
{
System
.
out
.
println
(
"diskSpaceIsLow stillAvailable="
+
stillAvailable
);
System
.
out
.
println
(
"diskSpaceIsLow stillAvailable="
+
stillAvailable
);
}
public
void
exceptionThrown
(
SQLException
e
,
String
sql
)
{
...
...
@@ -52,12 +52,12 @@ public class TestListener extends TestBase implements DatabaseEventListener {
public
void
setProgress
(
int
state
,
String
name
,
int
current
,
int
max
)
{
long
time
=
System
.
currentTimeMillis
();
if
(
time
<
last
+
1000
)
{
if
(
time
<
last
+
1000
)
{
return
;
}
last
=
time
;
String
stateName
;
switch
(
state
)
{
switch
(
state
)
{
case
STATE_SCAN_FILE:
stateName
=
"Scan "
+
name
;
break
;
...
...
@@ -75,7 +75,7 @@ public class TestListener extends TestBase implements DatabaseEventListener {
Thread
.
sleep
(
1
);
}
catch
(
InterruptedException
e
)
{
}
System
.
out
.
println
(
"state: "
+
stateName
+
" "
+
(
100
*
current
/
max
)
+
" "
+
(
time
-
start
));
System
.
out
.
println
(
"state: "
+
stateName
+
" "
+
(
100
*
current
/
max
)
+
" "
+
(
time
-
start
));
}
public
void
closingDatabase
()
{
...
...
h2/src/test/org/h2/test/db/TestLob.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/db/TestLogFile.java
浏览文件 @
3f6edd17
...
...
@@ -19,13 +19,13 @@ public class TestLogFile extends TestBase {
private
static
final
int
MAX_LOG_SIZE
=
1
;
private
long
reconnect
(
int
maxFiles
)
throws
Exception
{
if
(
conn
!=
null
)
{
if
(
conn
!=
null
)
{
conn
.
close
();
}
long
length
=
0
;
ArrayList
files
=
FileLister
.
getDatabaseFiles
(
baseDir
,
"logfile"
,
false
);
checkSmaller
(
files
.
size
(),
maxFiles
+
2
);
for
(
int
i
=
0
;
i
<
files
.
size
();
i
++)
{
checkSmaller
(
files
.
size
(),
maxFiles
+
2
);
for
(
int
i
=
0
;
i
<
files
.
size
();
i
++)
{
String
fileName
=
(
String
)
files
.
get
(
i
);
long
len
=
new
File
(
fileName
).
length
();
length
+=
len
;
...
...
@@ -35,18 +35,18 @@ public class TestLogFile extends TestBase {
}
public
void
test
()
throws
Exception
{
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
}
deleteDb
(
"logfile"
);
reconnect
(
0
);
insert
();
int
maxFiles
=
3
;
// data, index, log
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
long
length
=
reconnect
(
maxFiles
);
insert
();
long
l2
=
reconnect
(
maxFiles
);
trace
(
"l2="
+
l2
);
trace
(
"l2="
+
l2
);
check
(
l2
<=
length
*
2
);
}
conn
.
close
();
...
...
@@ -54,9 +54,9 @@ public class TestLogFile extends TestBase {
private
void
checkLogSize
()
throws
Exception
{
String
[]
files
=
new
File
(
"."
).
list
();
for
(
int
j
=
0
;
j
<
files
.
length
;
j
++)
{
for
(
int
j
=
0
;
j
<
files
.
length
;
j
++)
{
String
name
=
files
[
j
];
if
(
name
.
startsWith
(
"logfile"
)
&&
name
.
endsWith
(
".log.db"
))
{
if
(
name
.
startsWith
(
"logfile"
)
&&
name
.
endsWith
(
".log.db"
))
{
long
length
=
new
File
(
name
).
length
();
checkSmaller
(
length
,
MAX_LOG_SIZE
*
1024
*
1024
*
2
);
}
...
...
@@ -71,11 +71,11 @@ public class TestLogFile extends TestBase {
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"INSERT INTO TEST VALUES(?, 'Hello' || ?)"
);
int
len
=
getSize
(
1
,
10000
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
prep
.
setInt
(
1
,
i
);
prep
.
setInt
(
2
,
i
);
prep
.
execute
();
if
(
i
>
0
&&
(
i
%
2000
)
==
0
)
{
if
(
i
>
0
&&
(
i
%
2000
)
==
0
)
{
checkLogSize
();
}
}
...
...
h2/src/test/org/h2/test/db/TestMemoryUsage.java
浏览文件 @
3f6edd17
...
...
@@ -17,11 +17,11 @@ public class TestMemoryUsage extends TestBase {
private
Connection
conn
;
private
void
reconnect
()
throws
Exception
{
if
(
conn
!=
null
)
{
if
(
conn
!=
null
)
{
conn
.
close
();
}
//
Class.forName("org.hsqldb.jdbcDriver");
//
conn = DriverManager.getConnection("jdbc:hsqldb:test", "sa", "");
//
Class.forName("org.hsqldb.jdbcDriver");
//
conn = DriverManager.getConnection("jdbc:hsqldb:test", "sa", "");
conn
=
getConnection
(
"memoryUsage"
);
}
...
...
@@ -41,14 +41,14 @@ public class TestMemoryUsage extends TestBase {
Connection
conn1
=
getConnection
(
"memoryUsage"
);
printTimeMemory
(
"start"
,
0
);
long
time
=
System
.
currentTimeMillis
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
Connection
conn2
=
getConnection
(
"memoryUsage"
);
conn2
.
close
();
if
(
i
%
10000
==
0
)
{
printTimeMemory
(
"connect"
,
System
.
currentTimeMillis
()
-
time
);
if
(
i
%
10000
==
0
)
{
printTimeMemory
(
"connect"
,
System
.
currentTimeMillis
()
-
time
);
}
}
printTimeMemory
(
"connect"
,
System
.
currentTimeMillis
()
-
time
);
printTimeMemory
(
"connect"
,
System
.
currentTimeMillis
()
-
time
);
conn1
.
close
();
}
...
...
@@ -60,77 +60,76 @@ public class TestMemoryUsage extends TestBase {
// insert
time
=
System
.
currentTimeMillis
();
stat
.
execute
(
"DROP TABLE IF EXISTS TEST"
);
trace
(
"drop="
+
(
System
.
currentTimeMillis
()
-
time
));
trace
(
"drop="
+
(
System
.
currentTimeMillis
()
-
time
));
stat
.
execute
(
"CREATE CACHED TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"INSERT INTO TEST VALUES(?, 'Hello World')"
);
printTimeMemory
(
"start"
,
0
);
time
=
System
.
currentTimeMillis
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
prep
.
setInt
(
1
,
i
);
prep
.
execute
();
if
(
i
%
50000
==
0
)
{
trace
(
" "
+
(
100
*
i
/
len
)
+
"%"
);
if
(
i
%
50000
==
0
)
{
trace
(
" "
+
(
100
*
i
/
len
)
+
"%"
);
}
}
printTimeMemory
(
"insert"
,
System
.
currentTimeMillis
()
-
time
);
printTimeMemory
(
"insert"
,
System
.
currentTimeMillis
()
-
time
);
// update
time
=
System
.
currentTimeMillis
();
prep
=
conn
.
prepareStatement
(
"UPDATE TEST SET NAME='Hallo Welt' WHERE ID = ?"
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
prep
.
setInt
(
1
,
i
);
prep
.
execute
();
if
(
i
%
50000
==
0
)
{
trace
(
" "
+
(
100
*
i
/
len
)
+
"%"
);
if
(
i
%
50000
==
0
)
{
trace
(
" "
+
(
100
*
i
/
len
)
+
"%"
);
}
}
printTimeMemory
(
"update"
,
System
.
currentTimeMillis
()
-
time
);
printTimeMemory
(
"update"
,
System
.
currentTimeMillis
()
-
time
);
// select
time
=
System
.
currentTimeMillis
();
prep
=
conn
.
prepareStatement
(
"SELECT * FROM TEST WHERE ID = ?"
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
prep
.
setInt
(
1
,
i
);
ResultSet
rs
=
prep
.
executeQuery
();
rs
.
next
();
if
(
rs
.
next
())
{
if
(
rs
.
next
())
{
error
(
"one row expected, got more"
);
}
if
(
i
%
50000
==
0
)
{
trace
(
" "
+
(
100
*
i
/
len
)
+
"%"
);
if
(
i
%
50000
==
0
)
{
trace
(
" "
+
(
100
*
i
/
len
)
+
"%"
);
}
}
printTimeMemory
(
"select"
,
System
.
currentTimeMillis
()
-
time
);
printTimeMemory
(
"select"
,
System
.
currentTimeMillis
()
-
time
);
// select randomized
Random
random
=
new
Random
(
1
);
time
=
System
.
currentTimeMillis
();
prep
=
conn
.
prepareStatement
(
"SELECT * FROM TEST WHERE ID = ?"
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
prep
.
setInt
(
1
,
random
.
nextInt
(
len
));
ResultSet
rs
=
prep
.
executeQuery
();
rs
.
next
();
if
(
rs
.
next
())
{
if
(
rs
.
next
())
{
error
(
"one row expected, got more"
);
}
if
(
i
%
50000
==
0
)
{
trace
(
" "
+
(
100
*
i
/
len
)
+
"%"
);
if
(
i
%
50000
==
0
)
{
trace
(
" "
+
(
100
*
i
/
len
)
+
"%"
);
}
}
printTimeMemory
(
"select randomized"
,
System
.
currentTimeMillis
()
-
time
);
printTimeMemory
(
"select randomized"
,
System
.
currentTimeMillis
()
-
time
);
// delete
time
=
System
.
currentTimeMillis
();
prep
=
conn
.
prepareStatement
(
"DELETE FROM TEST WHERE ID = ?"
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
prep
.
setInt
(
1
,
random
.
nextInt
(
len
));
prep
.
executeUpdate
();
if
(
i
%
50000
==
0
)
{
trace
(
" "
+
(
100
*
i
/
len
)
+
"%"
);
if
(
i
%
50000
==
0
)
{
trace
(
" "
+
(
100
*
i
/
len
)
+
"%"
);
}
}
printTimeMemory
(
"delete"
,
System
.
currentTimeMillis
()
-
time
);
printTimeMemory
(
"delete"
,
System
.
currentTimeMillis
()
-
time
);
}
}
h2/src/test/org/h2/test/db/TestMultiConn.java
浏览文件 @
3f6edd17
...
...
@@ -51,7 +51,7 @@ public class TestMultiConn extends TestBase implements DatabaseEventListener {
try
{
s3
.
execute
(
"INSERT INTO TEST2 VALUES(4)"
);
conn3
.
commit
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
TestBase
.
logError
(
"insert"
,
e
);
}
}
...
...
@@ -63,7 +63,7 @@ public class TestMultiConn extends TestBase implements DatabaseEventListener {
try
{
s2
.
execute
(
"INSERT INTO TEST1 VALUES(5)"
);
conn2
.
commit
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
TestBase
.
logError
(
"insert"
,
e
);
}
}
...
...
@@ -85,7 +85,7 @@ public class TestMultiConn extends TestBase implements DatabaseEventListener {
}
private
void
testConcurrentOpen
()
throws
Exception
{
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
}
deleteDb
(
"multiConn"
);
...
...
@@ -98,9 +98,10 @@ public class TestMultiConn extends TestBase implements DatabaseEventListener {
Runnable
r
=
new
Runnable
()
{
public
void
run
()
{
try
{
Connection
c1
=
getConnection
(
"multiConn;DATABASE_EVENT_LISTENER='"
+
listener
+
"';file_lock=socket"
);
Connection
c1
=
getConnection
(
"multiConn;DATABASE_EVENT_LISTENER='"
+
listener
+
"';file_lock=socket"
);
c1
.
close
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
TestBase
.
logError
(
"connect"
,
e
);
}
}
...
...
@@ -113,7 +114,6 @@ public class TestMultiConn extends TestBase implements DatabaseEventListener {
thread
.
join
();
}
public
void
diskSpaceIsLow
(
long
stillAvailable
)
throws
SQLException
{
}
...
...
@@ -121,7 +121,7 @@ public class TestMultiConn extends TestBase implements DatabaseEventListener {
}
public
void
setProgress
(
int
state
,
String
name
,
int
x
,
int
max
)
{
while
(
wait
>
0
)
{
while
(
wait
>
0
)
{
try
{
Thread
.
sleep
(
wait
);
wait
=
0
;
...
...
@@ -157,16 +157,16 @@ public class TestMultiConn extends TestBase implements DatabaseEventListener {
c1
.
close
();
c2
.
close
();
if
(!
config
.
memory
)
{
if
(!
config
.
memory
)
{
Connection
conn
=
getConnection
(
"multiConn"
);
ResultSet
rs
;
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT * FROM MULTI_A ORDER BY ID"
);
rs
.
next
();
check
(
rs
.
getString
(
"NAME"
),
"0-insert-A"
);
check
(
rs
.
getString
(
"NAME"
),
"0-insert-A"
);
checkFalse
(
rs
.
next
());
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT * FROM MULTI_B ORDER BY ID"
);
rs
.
next
();
check
(
rs
.
getString
(
"NAME"
),
"1-insert-D"
);
check
(
rs
.
getString
(
"NAME"
),
"1-insert-D"
);
checkFalse
(
rs
.
next
());
conn
.
close
();
}
...
...
h2/src/test/org/h2/test/db/TestMultiDimension.java
浏览文件 @
3f6edd17
...
...
@@ -17,10 +17,10 @@ public class TestMultiDimension extends TestBase {
public
void
test
()
throws
Exception
{
Random
rand
=
new
Random
(
10
);
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
int
x
=
rand
.
nextInt
(
1000
),
y
=
rand
.
nextInt
(
1000
),
z
=
rand
.
nextInt
(
1000
);
MultiDimension
tool
=
MultiDimension
.
getInstance
();
long
xyz
=
tool
.
interleave
(
new
int
[]
{
x
,
y
,
z
});
long
xyz
=
tool
.
interleave
(
new
int
[]
{
x
,
y
,
z
});
check
(
x
,
tool
.
deinterleave
(
xyz
,
3
,
0
));
check
(
y
,
tool
.
deinterleave
(
xyz
,
3
,
1
));
check
(
z
,
tool
.
deinterleave
(
xyz
,
3
,
2
));
...
...
@@ -31,24 +31,27 @@ public class TestMultiDimension extends TestBase {
conn
=
getConnection
(
"multiDimension"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE ALIAS MAP FOR \""
+
getClass
().
getName
()
+
".interleave\""
);
stat
.
execute
(
"CREATE TABLE TEST(X INT NOT NULL, Y INT NOT NULL, Z INT NOT NULL, XYZ BIGINT AS MAP(X, Y, Z), DATA VARCHAR)"
);
stat
.
execute
(
"CREATE TABLE TEST(X INT NOT NULL, Y INT NOT NULL, Z INT NOT NULL, XYZ BIGINT AS MAP(X, Y, Z), DATA VARCHAR)"
);
stat
.
execute
(
"CREATE INDEX IDX_X ON TEST(X, Y, Z)"
);
stat
.
execute
(
"CREATE INDEX IDX_XYZ ON TEST(XYZ)"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"INSERT INTO TEST(X, Y, Z, DATA) VALUES(?, ?, ?, ?)"
);
// a reasonable max value to see the performance difference is 60; the higher the bigger the difference
// a reasonable max value to see the performance difference is 60; the
// higher the bigger the difference
int
max
=
getSize
(
10
,
20
);
long
time
=
System
.
currentTimeMillis
();
for
(
int
x
=
0
;
x
<
max
;
x
++)
{
for
(
int
y
=
0
;
y
<
max
;
y
++)
{
for
(
int
z
=
0
;
z
<
max
;
z
++)
{
for
(
int
x
=
0
;
x
<
max
;
x
++)
{
for
(
int
y
=
0
;
y
<
max
;
y
++)
{
for
(
int
z
=
0
;
z
<
max
;
z
++)
{
long
t2
=
System
.
currentTimeMillis
();
if
(
t2
-
time
>
1000
)
{
int
percent
=
(
int
)
(
100.0
*
((
double
)
x
*
x
*
x
)
/
((
double
)
max
*
max
*
max
));
if
(
t2
-
time
>
1000
)
{
int
percent
=
(
int
)
(
100.0
*
((
double
)
x
*
x
*
x
)
/
((
double
)
max
*
max
*
max
));
trace
(
percent
+
"%"
);
time
=
t2
;
try
{
Thread
.
sleep
(
10
);
}
catch
(
Exception
e
)
{}
}
catch
(
Exception
e
)
{
}
}
prep
.
setInt
(
1
,
x
);
prep
.
setInt
(
2
,
y
);
...
...
@@ -59,25 +62,22 @@ public class TestMultiDimension extends TestBase {
}
}
stat
.
execute
(
"ANALYZE SAMPLE_SIZE 10000"
);
PreparedStatement
prepRegular
=
conn
.
prepareStatement
(
"SELECT * FROM TEST WHERE X BETWEEN ? AND ? "
+
"AND Y BETWEEN ? AND ? AND Z BETWEEN ? AND ? ORDER BY X, Y, Z"
);
PreparedStatement
prepRegular
=
conn
.
prepareStatement
(
"SELECT * FROM TEST WHERE X BETWEEN ? AND ? "
+
"AND Y BETWEEN ? AND ? AND Z BETWEEN ? AND ? ORDER BY X, Y, Z"
);
MultiDimension
multi
=
MultiDimension
.
getInstance
();
String
sql
=
multi
.
generatePreparedQuery
(
"TEST"
,
"XYZ"
,
new
String
[]
{
"X"
,
"Y"
,
"Z"
});
String
sql
=
multi
.
generatePreparedQuery
(
"TEST"
,
"XYZ"
,
new
String
[]
{
"X"
,
"Y"
,
"Z"
});
sql
+=
" ORDER BY X, Y, Z"
;
PreparedStatement
prepMulti
=
conn
.
prepareStatement
(
sql
);
long
timeMulti
=
0
,
timeRegular
=
0
;
int
timeMax
=
getSize
(
100
,
2000
);
for
(
int
i
=
0
;
timeMulti
<
timeMax
;
i
++)
{
for
(
int
i
=
0
;
timeMulti
<
timeMax
;
i
++)
{
int
size
=
rand
.
nextInt
(
max
/
10
);
int
minX
=
rand
.
nextInt
(
max
-
size
);
int
minY
=
rand
.
nextInt
(
max
-
size
);
int
minZ
=
rand
.
nextInt
(
max
-
size
);
int
maxX
=
minX
+
size
,
maxY
=
minY
+
size
,
maxZ
=
minZ
+
size
;
int
minX
=
rand
.
nextInt
(
max
-
size
);
int
minY
=
rand
.
nextInt
(
max
-
size
);
int
minZ
=
rand
.
nextInt
(
max
-
size
);
int
maxX
=
minX
+
size
,
maxY
=
minY
+
size
,
maxZ
=
minZ
+
size
;
time
=
System
.
currentTimeMillis
();
ResultSet
rs1
=
multi
.
getResult
(
prepMulti
,
new
int
[]{
minX
,
minY
,
minZ
},
new
int
[]{
maxX
,
maxY
,
maxZ
});
ResultSet
rs1
=
multi
.
getResult
(
prepMulti
,
new
int
[]
{
minX
,
minY
,
minZ
},
new
int
[]
{
maxX
,
maxY
,
maxZ
});
timeMulti
+=
System
.
currentTimeMillis
()
-
time
;
time
=
System
.
currentTimeMillis
();
prepRegular
.
setInt
(
1
,
minX
);
...
...
@@ -88,7 +88,7 @@ public class TestMultiDimension extends TestBase {
prepRegular
.
setInt
(
6
,
maxZ
);
ResultSet
rs2
=
prepRegular
.
executeQuery
();
timeRegular
+=
System
.
currentTimeMillis
()
-
time
;
while
(
rs1
.
next
())
{
while
(
rs1
.
next
())
{
check
(
rs2
.
next
());
check
(
rs1
.
getInt
(
1
),
rs2
.
getInt
(
1
));
check
(
rs1
.
getInt
(
2
),
rs2
.
getInt
(
2
));
...
...
@@ -96,29 +96,24 @@ public class TestMultiDimension extends TestBase {
checkFalse
(
rs2
.
next
());
}
trace
(
"multi: "
+
timeMulti
+
" regular: "
+
timeRegular
);
for
(
int
i
=
0
;
i
<
50
;
i
++)
{
for
(
int
i
=
0
;
i
<
50
;
i
++)
{
int
size
=
rand
.
nextInt
(
max
/
10
);
int
minX
=
rand
.
nextInt
(
max
-
size
);
int
minY
=
rand
.
nextInt
(
max
-
size
);
int
minZ
=
rand
.
nextInt
(
max
-
size
);
int
maxX
=
minX
+
size
,
maxY
=
minY
+
size
,
maxZ
=
minZ
+
size
;
int
minX
=
rand
.
nextInt
(
max
-
size
);
int
minY
=
rand
.
nextInt
(
max
-
size
);
int
minZ
=
rand
.
nextInt
(
max
-
size
);
int
maxX
=
minX
+
size
,
maxY
=
minY
+
size
,
maxZ
=
minZ
+
size
;
long
time1
=
System
.
currentTimeMillis
();
String
query1
=
MultiDimension
.
getInstance
().
generateQuery
(
"TEST"
,
"XYZ"
,
new
String
[]{
"X"
,
"Y"
,
"Z"
},
new
int
[]{
minX
,
minY
,
minZ
},
new
int
[]{
minX
+
size
,
minY
+
size
,
minZ
+
size
});
String
query1
=
MultiDimension
.
getInstance
().
generateQuery
(
"TEST"
,
"XYZ"
,
new
String
[]
{
"X"
,
"Y"
,
"Z"
},
new
int
[]
{
minX
,
minY
,
minZ
},
new
int
[]
{
minX
+
size
,
minY
+
size
,
minZ
+
size
});
ResultSet
rs1
=
conn
.
createStatement
().
executeQuery
(
query1
+
" ORDER BY X, Y, Z"
);
time1
=
System
.
currentTimeMillis
()
-
time1
;
long
time2
=
System
.
currentTimeMillis
();
String
query2
=
"SELECT * FROM TEST WHERE "
+
"X BETWEEN "
+
minX
+
" AND "
+
maxX
+
" AND "
+
"Y BETWEEN "
+
minY
+
" AND "
+
maxY
+
" AND "
+
"Z BETWEEN "
+
minZ
+
" AND "
+
maxZ
;
String
query2
=
"SELECT * FROM TEST WHERE "
+
"X BETWEEN "
+
minX
+
" AND "
+
maxX
+
" AND "
+
"Y BETWEEN "
+
minY
+
" AND "
+
maxY
+
" AND "
+
"Z BETWEEN "
+
minZ
+
" AND "
+
maxZ
;
PreparedStatement
prep2
=
conn
.
prepareStatement
(
query2
+
" ORDER BY X, Y, Z"
);
ResultSet
rs2
=
prep2
.
executeQuery
();
time2
=
System
.
currentTimeMillis
()
-
time2
;
while
(
rs1
.
next
())
{
while
(
rs1
.
next
())
{
check
(
rs2
.
next
());
check
(
rs1
.
getInt
(
1
),
rs2
.
getInt
(
1
));
check
(
rs1
.
getInt
(
2
),
rs2
.
getInt
(
2
));
...
...
@@ -131,6 +126,6 @@ public class TestMultiDimension extends TestBase {
}
public
static
long
interleave
(
int
x
,
int
y
,
int
z
)
{
return
MultiDimension
.
getInstance
().
interleave
(
new
int
[]
{
x
,
y
,
z
});
return
MultiDimension
.
getInstance
().
interleave
(
new
int
[]
{
x
,
y
,
z
});
}
}
h2/src/test/org/h2/test/db/TestMultiThread.java
浏览文件 @
3f6edd17
...
...
@@ -39,21 +39,21 @@ public class TestMultiThread extends TestBase implements Runnable {
stat
.
execute
(
"CREATE TABLE TEST(ID IDENTITY, NAME VARCHAR)"
);
int
len
=
getSize
(
10
,
200
);
Thread
[]
threads
=
new
Thread
[
len
];
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
threads
[
i
]
=
new
Thread
(
new
TestMultiThread
(
config
,
this
));
}
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
threads
[
i
].
start
();
}
int
sleep
=
getSize
(
400
,
10000
);
Thread
.
sleep
(
sleep
);
this
.
stop
=
true
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
threads
[
i
].
join
();
}
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT COUNT(*) FROM TEST"
);
rs
.
next
();
trace
(
"max id="
+
rs
.
getInt
(
1
));
trace
(
"max id="
+
rs
.
getInt
(
1
));
conn
.
close
();
}
...
...
@@ -63,7 +63,7 @@ public class TestMultiThread extends TestBase implements Runnable {
public
void
run
()
{
try
{
while
(!
parent
.
stop
)
{
while
(!
parent
.
stop
)
{
stat
.
execute
(
"SELECT COUNT(*) FROM TEST"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(NULL, 'Hi')"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"UPDATE TEST SET NAME='Hello' WHERE ID=?"
);
...
...
@@ -72,12 +72,12 @@ public class TestMultiThread extends TestBase implements Runnable {
prep
=
conn
.
prepareStatement
(
"SELECT * FROM TEST WHERE ID=?"
);
prep
.
setInt
(
1
,
random
.
nextInt
(
10000
));
ResultSet
rs
=
prep
.
executeQuery
();
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
rs
.
getString
(
"NAME"
);
}
}
conn
.
close
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logError
(
"multi"
,
e
);
}
}
...
...
h2/src/test/org/h2/test/db/TestOpenClose.java
浏览文件 @
3f6edd17
...
...
@@ -33,17 +33,17 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
private
void
testBackup
(
boolean
encrypt
)
throws
Exception
{
deleteDb
(
baseDir
,
"openClose"
);
String
url
;
if
(
encrypt
)
{
url
=
"jdbc:h2:"
+
baseDir
+
"/openClose;CIPHER=XTEA"
;
if
(
encrypt
)
{
url
=
"jdbc:h2:"
+
baseDir
+
"/openClose;CIPHER=XTEA"
;
}
else
{
url
=
"jdbc:h2:"
+
baseDir
+
"/openClose"
;
url
=
"jdbc:h2:"
+
baseDir
+
"/openClose"
;
}
org
.
h2
.
Driver
.
load
();
Connection
conn
=
DriverManager
.
getConnection
(
url
,
"sa"
,
"abc def"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TABLE TEST(C CLOB)"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(SPACE(10000))"
);
stat
.
execute
(
"BACKUP TO '"
+
baseDir
+
"/test.zip'"
);
stat
.
execute
(
"BACKUP TO '"
+
baseDir
+
"/test.zip'"
);
conn
.
close
();
deleteDb
(
baseDir
,
"openClose"
);
Restore
.
execute
(
baseDir
+
"/test.zip"
,
baseDir
,
null
,
true
);
...
...
@@ -58,7 +58,8 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
private
void
testReconnectFast
()
throws
Exception
{
deleteDb
(
baseDir
,
"openClose"
);
String
url
=
"jdbc:h2:"
+
baseDir
+
"/openClose;DATABASE_EVENT_LISTENER='"
+
TestOpenClose
.
class
.
getName
()+
"'"
;
String
url
=
"jdbc:h2:"
+
baseDir
+
"/openClose;DATABASE_EVENT_LISTENER='"
+
TestOpenClose
.
class
.
getName
()
+
"'"
;
Connection
conn
=
DriverManager
.
getConnection
(
url
,
"sa"
,
"sa"
);
Statement
stat
=
conn
.
createStatement
();
try
{
...
...
@@ -91,14 +92,14 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
void
testCase
()
throws
Exception
{
Class
.
forName
(
"org.h2.Driver"
);
deleteDb
(
baseDir
,
"openClose"
);
final
String
url
=
"jdbc:h2:"
+
baseDir
+
"/openClose;FILE_LOCK=NO"
;
final
String
url
=
"jdbc:h2:"
+
baseDir
+
"/openClose;FILE_LOCK=NO"
;
Connection
conn
=
DriverManager
.
getConnection
(
url
,
"sa"
,
""
);
conn
.
createStatement
().
execute
(
"drop table employee if exists"
);
conn
.
createStatement
().
execute
(
"create table employee(id int primary key, name varchar, salary int)"
);
conn
.
close
();
int
len
=
this
.
getSize
(
200
,
4000
);
Thread
[]
threads
=
new
Thread
[
len
];
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
threads
[
i
]
=
new
Thread
()
{
public
void
run
()
{
try
{
...
...
@@ -109,17 +110,17 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
prep
.
setString
(
2
,
"employee "
+
id
);
prep
.
execute
();
conn
.
close
();
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
TestBase
.
logError
(
"insert"
,
e
);
}
}
};
threads
[
i
].
start
();
}
//
for(int i=0; i<len; i++) {
//
threads[i].start();
//
}
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
//
for(int i=0; i<len; i++) {
//
threads[i].start();
//
}
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
threads
[
i
].
join
();
}
conn
=
DriverManager
.
getConnection
(
url
,
"sa"
,
""
);
...
...
@@ -143,16 +144,16 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
public
void
setProgress
(
int
state
,
String
name
,
int
current
,
int
max
)
{
String
stateName
;
switch
(
state
)
{
switch
(
state
)
{
case
STATE_SCAN_FILE:
stateName
=
"Scan "
+
name
+
" "
+
current
+
"/"
+
max
;
if
(
current
>
0
)
{
if
(
current
>
0
)
{
throw
new
Error
(
"unexpected: "
+
stateName
);
}
break
;
case
STATE_CREATE_INDEX:
stateName
=
"Create Index "
+
name
+
" "
+
current
+
"/"
+
max
;
if
(!
"SYS"
.
equals
(
name
))
{
if
(!
"SYS"
.
equals
(
name
))
{
throw
new
Error
(
"unexpected: "
+
stateName
);
}
break
;
...
...
@@ -162,7 +163,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
default
:
stateName
=
"?"
;
}
//
System.out.println(": " + stateName);
//
System.out.println(": " + stateName);
}
public
void
closingDatabase
()
{
...
...
h2/src/test/org/h2/test/db/TestOptimizations.java
浏览文件 @
3f6edd17
...
...
@@ -18,7 +18,7 @@ import org.h2.test.TestBase;
public
class
TestOptimizations
extends
TestBase
{
public
void
test
()
throws
Exception
{
if
(
config
.
networked
)
{
if
(
config
.
networked
)
{
return
;
}
testQueryCacheTimestamp
();
...
...
@@ -32,7 +32,7 @@ public class TestOptimizations extends TestBase {
private
void
testQueryCacheTimestamp
()
throws
Exception
{
deleteDb
(
"optimizations"
);
Connection
conn
=
getConnection
(
"optimizations"
);
Connection
conn
=
getConnection
(
"optimizations"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"SELECT CURRENT_TIMESTAMP()"
);
ResultSet
rs
=
prep
.
executeQuery
();
rs
.
next
();
...
...
@@ -47,10 +47,12 @@ public class TestOptimizations extends TestBase {
private
void
testQueryCacheSpeed
()
throws
Exception
{
deleteDb
(
"optimizations"
);
Connection
conn
=
getConnection
(
"optimizations"
);
Connection
conn
=
getConnection
(
"optimizations"
);
Statement
stat
=
conn
.
createStatement
();
testQuerySpeed
(
stat
,
"select sum(x) from system_range(1, 10000) a where a.x in (select b.x from system_range(1, 30) b)"
);
testQuerySpeed
(
stat
,
"select sum(a.n), sum(b.x) from system_range(1, 100) b, (select sum(x) n from system_range(1, 4000)) a"
);
testQuerySpeed
(
stat
,
"select sum(x) from system_range(1, 10000) a where a.x in (select b.x from system_range(1, 30) b)"
);
testQuerySpeed
(
stat
,
"select sum(a.n), sum(b.x) from system_range(1, 100) b, (select sum(x) n from system_range(1, 4000)) a"
);
conn
.
close
();
}
...
...
@@ -65,16 +67,16 @@ public class TestOptimizations extends TestBase {
long
time2
=
System
.
currentTimeMillis
();
stat
.
execute
(
sql
);
time2
=
System
.
currentTimeMillis
()
-
time2
;
if
(
time2
>
time
)
{
error
(
"not optimized: "
+
time
+
" optimized: "
+
time2
+
" sql:"
+
sql
);
if
(
time2
>
time
)
{
error
(
"not optimized: "
+
time
+
" optimized: "
+
time2
+
" sql:"
+
sql
);
}
}
private
void
testQueryCache
(
boolean
optimize
)
throws
Exception
{
deleteDb
(
"optimizations"
);
Connection
conn
=
getConnection
(
"optimizations"
);
Connection
conn
=
getConnection
(
"optimizations"
);
Statement
stat
=
conn
.
createStatement
();
if
(
optimize
)
{
if
(
optimize
)
{
stat
.
execute
(
"set OPTIMIZE_REUSE_RESULTS 1"
);
}
else
{
stat
.
execute
(
"set OPTIMIZE_REUSE_RESULTS 0"
);
...
...
@@ -101,35 +103,35 @@ public class TestOptimizations extends TestBase {
private
void
testMinMaxCountOptimization
(
boolean
memory
)
throws
Exception
{
deleteDb
(
"optimizations"
);
Connection
conn
=
getConnection
(
"optimizations"
);
Connection
conn
=
getConnection
(
"optimizations"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create "
+(
memory
?
"memory"
:
""
)
+
" table test(id int primary key, value int)"
);
stat
.
execute
(
"create "
+
(
memory
?
"memory"
:
""
)
+
" table test(id int primary key, value int)"
);
stat
.
execute
(
"create index idx_value_id on test(value, id);"
);
int
len
=
getSize
(
1000
,
10000
);
HashMap
map
=
new
HashMap
();
TreeSet
set
=
new
TreeSet
();
Random
random
=
new
Random
(
1
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
if
(
i
==
len
/
2
)
{
if
(!
config
.
memory
)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
if
(
i
==
len
/
2
)
{
if
(!
config
.
memory
)
{
conn
.
close
();
conn
=
getConnection
(
"optimizations"
);
conn
=
getConnection
(
"optimizations"
);
stat
=
conn
.
createStatement
();
}
}
switch
(
random
.
nextInt
(
10
))
{
switch
(
random
.
nextInt
(
10
))
{
case
0
:
case
1
:
case
2
:
case
3
:
case
4
:
case
5
:
if
(
random
.
nextInt
(
1000
)==
1
)
{
stat
.
execute
(
"insert into test values("
+
i
+
", null)"
);
if
(
random
.
nextInt
(
1000
)
==
1
)
{
stat
.
execute
(
"insert into test values("
+
i
+
", null)"
);
map
.
put
(
new
Integer
(
i
),
null
);
}
else
{
int
value
=
random
.
nextInt
();
stat
.
execute
(
"insert into test values("
+
i
+
", "
+
value
+
")"
);
stat
.
execute
(
"insert into test values("
+
i
+
", "
+
value
+
")"
);
map
.
put
(
new
Integer
(
i
),
new
Integer
(
value
));
set
.
add
(
new
Integer
(
value
));
}
...
...
@@ -137,14 +139,14 @@ public class TestOptimizations extends TestBase {
case
6
:
case
7
:
case
8
:
{
if
(
map
.
size
()>
0
)
{
for
(
int
j
=
random
.
nextInt
(
i
),
k
=
0
;
k
<
10
;
k
++,
j
++)
{
if
(
map
.
containsKey
(
new
Integer
(
j
)))
{
if
(
map
.
size
()
>
0
)
{
for
(
int
j
=
random
.
nextInt
(
i
),
k
=
0
;
k
<
10
;
k
++,
j
++)
{
if
(
map
.
containsKey
(
new
Integer
(
j
)))
{
Integer
x
=
(
Integer
)
map
.
remove
(
new
Integer
(
j
));
if
(
x
!=
null
)
{
if
(
x
!=
null
)
{
set
.
remove
(
x
);
}
stat
.
execute
(
"delete from test where id="
+
j
);
stat
.
execute
(
"delete from test where id="
+
j
);
}
}
}
...
...
@@ -154,14 +156,14 @@ public class TestOptimizations extends TestBase {
ArrayList
list
=
new
ArrayList
(
map
.
values
());
int
count
=
list
.
size
();
Integer
min
=
null
,
max
=
null
;
if
(
count
>
0
)
{
if
(
count
>
0
)
{
min
=
(
Integer
)
set
.
first
();
max
=
(
Integer
)
set
.
last
();
}
ResultSet
rs
=
stat
.
executeQuery
(
"select min(value), max(value), count(*) from test"
);
rs
.
next
();
Integer
minDb
=
(
Integer
)
rs
.
getObject
(
1
);
Integer
maxDb
=
(
Integer
)
rs
.
getObject
(
2
);
Integer
minDb
=
(
Integer
)
rs
.
getObject
(
1
);
Integer
maxDb
=
(
Integer
)
rs
.
getObject
(
2
);
int
countDb
=
rs
.
getInt
(
3
);
check
(
minDb
,
min
);
check
(
maxDb
,
max
);
...
...
@@ -174,7 +176,7 @@ public class TestOptimizations extends TestBase {
private
void
testIn
()
throws
Exception
{
deleteDb
(
"optimizations"
);
Connection
conn
=
getConnection
(
"optimizations"
);
Connection
conn
=
getConnection
(
"optimizations"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id int primary key, name varchar)"
);
stat
.
execute
(
"insert into test values(1, 'Hello')"
);
...
...
@@ -210,12 +212,14 @@ public class TestOptimizations extends TestBase {
check
(
rs
.
getString
(
2
),
"World"
);
checkFalse
(
rs
.
next
());
prep
=
conn
.
prepareStatement
(
"select * from test t1 where t1.id in(select t2.id from test t2 where t2.id=? and t1.id<>t2.id)"
);
prep
=
conn
.
prepareStatement
(
"select * from test t1 where t1.id in(select t2.id from test t2 where t2.id=? and t1.id<>t2.id)"
);
prep
.
setInt
(
1
,
2
);
rs
=
prep
.
executeQuery
();
checkFalse
(
rs
.
next
());
prep
=
conn
.
prepareStatement
(
"select * from test t1 where t1.id in(select t2.id from test t2 where t2.id in(cast(?+10 as varchar)))"
);
prep
=
conn
.
prepareStatement
(
"select * from test t1 where t1.id in(select t2.id from test t2 where t2.id in(cast(?+10 as varchar)))"
);
prep
.
setInt
(
1
,
2
);
rs
=
prep
.
executeQuery
();
checkFalse
(
rs
.
next
());
...
...
@@ -223,5 +227,4 @@ public class TestOptimizations extends TestBase {
conn
.
close
();
}
}
h2/src/test/org/h2/test/db/TestPowerOff.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/db/TestReadOnly.java
浏览文件 @
3f6edd17
...
...
@@ -17,7 +17,7 @@ import org.h2.test.TestBase;
public
class
TestReadOnly
extends
TestBase
{
public
void
test
()
throws
Exception
{
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
}
...
...
@@ -53,7 +53,7 @@ public class TestReadOnly extends TestBase {
try
{
stat
.
execute
(
"DELETE FROM TEST"
);
error
(
"read only delete"
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
conn
.
close
();
...
...
@@ -64,7 +64,7 @@ public class TestReadOnly extends TestBase {
try
{
stat
.
execute
(
"DELETE FROM TEST"
);
error
(
"read only delete"
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
conn
.
close
();
...
...
@@ -72,7 +72,7 @@ public class TestReadOnly extends TestBase {
private
void
setReadOnly
()
throws
SQLException
{
ArrayList
list
=
FileLister
.
getDatabaseFiles
(
TestBase
.
baseDir
,
"readonly"
,
true
);
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
String
fileName
=
(
String
)
list
.
get
(
i
);
File
file
=
new
File
(
fileName
);
file
.
setReadOnly
();
...
...
h2/src/test/org/h2/test/db/TestRights.java
浏览文件 @
3f6edd17
...
...
@@ -4,7 +4,11 @@
*/
package
org
.
h2
.
test
.
db
;
import
java.sql.*
;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
import
java.sql.ResultSetMetaData
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
org.h2.test.TestBase
;
...
...
@@ -13,7 +17,7 @@ public class TestRights extends TestBase {
Statement
stat
;
public
void
test
()
throws
Exception
{
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
}
...
...
@@ -80,25 +84,25 @@ public class TestRights extends TestBase {
executeSuccess
(
"ALTER USER TEST SET PASSWORD 'def'"
);
executeSuccess
(
"CREATE USER TEST2 PASSWORD 'def' ADMIN"
);
executeSuccess
(
"ALTER USER TEST ADMIN FALSE"
);
executeSuccess
(
"SCRIPT TO '"
+
baseDir
+
"/rights.sql' CIPHER XTEA PASSWORD 'test'"
);
executeSuccess
(
"SCRIPT TO '"
+
baseDir
+
"/rights.sql' CIPHER XTEA PASSWORD 'test'"
);
conn
.
close
();
try
{
conn
=
getConnection
(
"rights"
,
"Test"
,
"abc"
);
error
(
"unexpected success (mixed case user name)"
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
try
{
conn
=
getConnection
(
"rights"
,
"TEST"
,
"abc"
);
error
(
"unexpected success (wrong password)"
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
try
{
conn
=
getConnection
(
"rights"
,
"TEST"
,
null
);
error
(
"unexpected success (wrong password)"
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
conn
=
getConnection
(
"rights"
,
"TEST"
,
"def"
);
...
...
@@ -153,7 +157,8 @@ public class TestRights extends TestBase {
private
void
testTableType
(
Connection
conn
,
String
type
)
throws
Exception
{
executeSuccess
(
"SET DEFAULT_TABLE_TYPE "
+
type
);
executeSuccess
(
"CREATE TABLE TEST(ID INT)"
);
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT STORAGE_TYPE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='TEST'"
);
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT STORAGE_TYPE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='TEST'"
);
rs
.
next
();
check
(
rs
.
getString
(
1
),
type
);
executeSuccess
(
"DROP TABLE TEST"
);
...
...
@@ -163,13 +168,13 @@ public class TestRights extends TestBase {
try
{
stat
.
execute
(
sql
);
error
(
"unexpected success (not admin)"
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
}
public
void
executeSuccess
(
String
sql
)
throws
Exception
{
if
(
stat
.
execute
(
sql
))
{
if
(
stat
.
execute
(
sql
))
{
ResultSet
rs
=
stat
.
getResultSet
();
// this will check if the result set is updatable
...
...
@@ -177,22 +182,22 @@ public class TestRights extends TestBase {
ResultSetMetaData
meta
=
rs
.
getMetaData
();
int
columnCount
=
meta
.
getColumnCount
();
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
meta
.
getCatalogName
(
i
+
1
);
meta
.
getColumnClassName
(
i
+
1
);
meta
.
getColumnDisplaySize
(
i
+
1
);
meta
.
getColumnLabel
(
i
+
1
);
meta
.
getColumnName
(
i
+
1
);
meta
.
getColumnType
(
i
+
1
);
meta
.
getColumnTypeName
(
i
+
1
);
meta
.
getPrecision
(
i
+
1
);
meta
.
getScale
(
i
+
1
);
meta
.
getSchemaName
(
i
+
1
);
meta
.
getTableName
(
i
+
1
);
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
meta
.
getCatalogName
(
i
+
1
);
meta
.
getColumnClassName
(
i
+
1
);
meta
.
getColumnDisplaySize
(
i
+
1
);
meta
.
getColumnLabel
(
i
+
1
);
meta
.
getColumnName
(
i
+
1
);
meta
.
getColumnType
(
i
+
1
);
meta
.
getColumnTypeName
(
i
+
1
);
meta
.
getPrecision
(
i
+
1
);
meta
.
getScale
(
i
+
1
);
meta
.
getSchemaName
(
i
+
1
);
meta
.
getTableName
(
i
+
1
);
}
while
(
rs
.
next
())
{
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
rs
.
getObject
(
i
+
1
);
while
(
rs
.
next
())
{
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
rs
.
getObject
(
i
+
1
);
}
}
}
...
...
h2/src/test/org/h2/test/db/TestRunscript.java
浏览文件 @
3f6edd17
...
...
@@ -31,22 +31,23 @@ public class TestRunscript extends TestBase implements Trigger {
stat1
.
execute
(
"create table test (id identity, name varchar(12))"
);
stat1
.
execute
(
"insert into test (name) values ('first'), ('second')"
);
stat1
.
execute
(
"create sequence testSeq start with 100 increment by 10"
);
stat1
.
execute
(
"create alias myTest for \""
+
getClass
().
getName
()+
".test\""
);
stat1
.
execute
(
"create trigger myTrigger before insert on test nowait call \""
+
getClass
().
getName
()+
"\""
);
stat1
.
execute
(
"create alias myTest for \""
+
getClass
().
getName
()
+
".test\""
);
stat1
.
execute
(
"create trigger myTrigger before insert on test nowait call \""
+
getClass
().
getName
()
+
"\""
);
stat1
.
execute
(
"create view testView as select * from test where 1=0 union all select * from test where 0=1"
);
stat1
.
execute
(
"create user testAdmin salt '00' hash '01' admin"
);
stat1
.
execute
(
"create schema testSchema authorization testAdmin"
);
stat1
.
execute
(
"create table testSchema.parent(id int primary key, name varchar)"
);
stat1
.
execute
(
"create index idxname on testSchema.parent(name)"
);
stat1
.
execute
(
"create table testSchema.child(id int primary key, parentId int, name varchar, foreign key(parentId) references parent(id))"
);
stat1
.
execute
(
"create table testSchema.child(id int primary key, parentId int, name varchar, foreign key(parentId) references parent(id))"
);
stat1
.
execute
(
"create user testUser salt '02' hash '03'"
);
stat1
.
execute
(
"create role testRole"
);
stat1
.
execute
(
"grant all on testSchema.child to testUser"
);
stat1
.
execute
(
"grant select, insert on testSchema.parent to testRole"
);
stat1
.
execute
(
"grant testRole to testUser"
);
String
sql
=
"script to '"
+
baseDir
+
"/backup.2.sql'"
;
if
(
password
)
{
String
sql
=
"script to '"
+
baseDir
+
"/backup.2.sql'"
;
if
(
password
)
{
sql
+=
" CIPHER AES PASSWORD 't1e2s3t4'"
;
}
stat1
.
execute
(
sql
);
...
...
@@ -54,24 +55,24 @@ public class TestRunscript extends TestBase implements Trigger {
deleteDb
(
"runscriptRestore"
);
conn2
=
getConnection
(
"runscriptRestore"
);
stat2
=
conn2
.
createStatement
();
sql
=
"runscript from '"
+
baseDir
+
"/backup.2.sql'"
;
if
(
password
)
{
sql
=
"runscript from '"
+
baseDir
+
"/backup.2.sql'"
;
if
(
password
)
{
sql
+=
" CIPHER AES PASSWORD 'wrongPassword'"
;
}
if
(
password
)
{
if
(
password
)
{
try
{
stat2
.
execute
(
sql
);
error
(
"should fail"
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
}
sql
=
"runscript from '"
+
baseDir
+
"/backup.2.sql'"
;
if
(
password
)
{
sql
=
"runscript from '"
+
baseDir
+
"/backup.2.sql'"
;
if
(
password
)
{
sql
+=
" CIPHER AES PASSWORD 't1e2s3t4'"
;
}
stat2
.
execute
(
sql
);
stat2
.
execute
(
"script to '"
+
baseDir
+
"/backup.3.sql'"
);
stat2
.
execute
(
"script to '"
+
baseDir
+
"/backup.3.sql'"
);
compareDatabases
(
stat1
,
stat2
);
...
...
h2/src/test/org/h2/test/db/TestScript.java
浏览文件 @
3f6edd17
...
...
@@ -48,13 +48,13 @@ public class TestScript extends TestBase {
}
public
void
test
()
throws
Exception
{
if
(
config
.
networked
&&
config
.
big
)
{
if
(
config
.
networked
&&
config
.
big
)
{
return
;
}
alwaysReconnect
=
false
;
testScript
();
if
(!
config
.
memory
)
{
if
(
config
.
big
)
{
if
(!
config
.
memory
)
{
if
(
config
.
big
)
{
alwaysReconnect
=
true
;
testScript
();
}
...
...
@@ -72,7 +72,7 @@ public class TestScript extends TestBase {
testFile
(
inFile
);
conn
.
close
();
out
.
close
();
if
(
errors
.
length
()>
0
)
{
if
(
errors
.
length
()
>
0
)
{
throw
new
Exception
(
"errors:\n"
+
errors
.
toString
());
}
else
{
new
File
(
outFile
).
delete
();
...
...
@@ -85,13 +85,13 @@ public class TestScript extends TestBase {
putBack
=
null
;
return
s
;
}
while
(
true
)
{
while
(
true
)
{
String
s
=
in
.
readLine
();
if
(
s
==
null
)
{
if
(
s
==
null
)
{
return
s
;
}
s
=
s
.
trim
();
if
(
s
.
length
()
>
0
)
{
if
(
s
.
length
()
>
0
)
{
return
s
;
}
}
...
...
@@ -125,11 +125,11 @@ public class TestScript extends TestBase {
}
private
boolean
containsTempTables
()
throws
SQLException
{
ResultSet
rs
=
conn
.
getMetaData
().
getTables
(
null
,
null
,
null
,
new
String
[]
{
"TABLE"
});
while
(
rs
.
next
())
{
ResultSet
rs
=
conn
.
getMetaData
().
getTables
(
null
,
null
,
null
,
new
String
[]
{
"TABLE"
});
while
(
rs
.
next
())
{
String
sql
=
rs
.
getString
(
"SQL"
);
if
(
sql
!=
null
)
{
if
(
sql
.
indexOf
(
"TEMPORARY"
)
>=
0
)
{
if
(
sql
!=
null
)
{
if
(
sql
.
indexOf
(
"TEMPORARY"
)
>=
0
)
{
return
true
;
}
}
...
...
@@ -138,10 +138,10 @@ public class TestScript extends TestBase {
}
private
void
process
(
String
sql
)
throws
Exception
{
if
(
alwaysReconnect
)
{
if
(!
containsTempTables
())
{
if
(
alwaysReconnect
)
{
if
(!
containsTempTables
())
{
boolean
autocommit
=
conn
.
getAutoCommit
();
if
(
autocommit
)
{
if
(
autocommit
)
{
conn
.
close
();
conn
=
getConnection
(
"script"
);
conn
.
setAutoCommit
(
autocommit
);
...
...
@@ -149,7 +149,7 @@ public class TestScript extends TestBase {
}
}
}
if
(
statements
!=
null
)
{
if
(
statements
!=
null
)
{
statements
.
add
(
sql
);
}
if
(
sql
.
indexOf
(
'?'
)
==
-
1
)
{
...
...
@@ -179,16 +179,14 @@ public class TestScript extends TestBase {
write
(
""
);
}
private
void
setParameter
(
PreparedStatement
prep
,
int
i
,
String
param
)
throws
SQLException
{
private
void
setParameter
(
PreparedStatement
prep
,
int
i
,
String
param
)
throws
SQLException
{
if
(
param
.
equalsIgnoreCase
(
"null"
))
{
param
=
null
;
}
prep
.
setString
(
i
,
param
);
}
private
int
processPrepared
(
String
sql
,
PreparedStatement
prep
,
String
param
)
throws
Exception
{
private
int
processPrepared
(
String
sql
,
PreparedStatement
prep
,
String
param
)
throws
Exception
{
try
{
StringBuffer
buff
=
new
StringBuffer
();
int
index
=
0
;
...
...
@@ -238,7 +236,7 @@ public class TestScript extends TestBase {
}
private
String
formatString
(
String
s
)
{
if
(
s
==
null
)
{
if
(
s
==
null
)
{
return
"null"
;
}
return
s
.
replace
(
'\n'
,
' '
);
...
...
@@ -288,7 +286,7 @@ public class TestScript extends TestBase {
int
length
=
max
.
length
;
StringBuffer
buff
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
if
(
i
>
0
)
{
if
(
i
>
0
)
{
buff
.
append
(
' '
);
}
if
(
row
==
null
)
{
...
...
@@ -298,7 +296,7 @@ public class TestScript extends TestBase {
}
else
{
int
len
=
row
[
i
].
length
();
buff
.
append
(
row
[
i
]);
if
(
i
<
length
-
1
)
{
if
(
i
<
length
-
1
)
{
for
(
int
j
=
len
;
j
<
max
[
i
];
j
++)
{
buff
.
append
(
' '
);
}
...
...
@@ -325,10 +323,10 @@ public class TestScript extends TestBase {
errors
.
append
(
"\n"
+
"got: "
);
errors
.
append
(
s
);
errors
.
append
(
"\n"
);
if
(
e
!=
null
)
{
if
(
e
!=
null
)
{
TestBase
.
logError
(
"script"
,
e
);
}
if
(
failFast
)
{
if
(
failFast
)
{
TestBase
.
logError
(
errors
.
toString
(),
null
);
conn
.
close
();
System
.
exit
(
1
);
...
...
h2/src/test/org/h2/test/db/TestScriptSimple.java
浏览文件 @
3f6edd17
...
...
@@ -16,8 +16,9 @@ import org.h2.util.ScriptReader;
public
class
TestScriptSimple
extends
TestBase
{
private
Connection
conn
;
public
void
test
()
throws
Exception
{
if
(
config
.
memory
||
config
.
big
||
config
.
networked
)
{
if
(
config
.
memory
||
config
.
big
||
config
.
networked
)
{
return
;
}
deleteDb
(
"scriptSimple"
);
...
...
@@ -26,19 +27,19 @@ public class TestScriptSimple extends TestBase {
InputStream
is
=
getClass
().
getClassLoader
().
getResourceAsStream
(
inFile
);
LineNumberReader
lineReader
=
new
LineNumberReader
(
new
InputStreamReader
(
is
,
"Cp1252"
));
ScriptReader
reader
=
new
ScriptReader
(
lineReader
);
while
(
true
)
{
while
(
true
)
{
String
sql
=
reader
.
readStatement
();
if
(
sql
==
null
)
{
if
(
sql
==
null
)
{
break
;
}
sql
=
sql
.
trim
();
if
(
"@reconnect"
.
equals
(
sql
.
toLowerCase
()))
{
if
(
"@reconnect"
.
equals
(
sql
.
toLowerCase
()))
{
reconnect
();
}
else
if
(
sql
.
length
()
==
0
)
{
}
else
if
(
sql
.
length
()
==
0
)
{
// ignore
}
else
if
(
sql
.
toLowerCase
().
startsWith
(
"select"
))
{
}
else
if
(
sql
.
toLowerCase
().
startsWith
(
"select"
))
{
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
sql
);
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
String
expected
=
reader
.
readStatement
().
trim
();
String
got
=
"> "
+
rs
.
getString
(
1
);
check
(
expected
,
got
);
...
...
@@ -52,11 +53,10 @@ public class TestScriptSimple extends TestBase {
}
private
void
reconnect
()
throws
Exception
{
if
(
conn
!=
null
)
{
if
(
conn
!=
null
)
{
conn
.
close
();
}
conn
=
getConnection
(
"scriptSimple"
);
}
}
h2/src/test/org/h2/test/db/TestSequence.java
浏览文件 @
3f6edd17
...
...
@@ -14,21 +14,21 @@ public class TestSequence extends TestBase {
public
void
test
()
throws
Exception
{
deleteDb
(
"sequence"
);
Connection
conn
=
getConnection
(
"sequence"
);
Connection
conn
=
getConnection
(
"sequence"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create sequence testSequence"
);
conn
.
setAutoCommit
(
false
);
Connection
conn2
=
getConnection
(
"sequence"
);
Connection
conn2
=
getConnection
(
"sequence"
);
Statement
stat2
=
conn2
.
createStatement
();
conn2
.
setAutoCommit
(
false
);
long
last
=
0
;
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
long
v1
=
getNext
(
stat
);
check
(
v1
>
last
);
last
=
v1
;
for
(
int
j
=
0
;
j
<
100
;
j
++)
{
for
(
int
j
=
0
;
j
<
100
;
j
++)
{
long
v2
=
getNext
(
stat2
);
check
(
v2
>
last
);
last
=
v2
;
...
...
h2/src/test/org/h2/test/db/TestSpaceReuse.java
浏览文件 @
3f6edd17
...
...
@@ -4,8 +4,9 @@
*/
package
org
.
h2
.
test
.
db
;
import
java.io.*
;
import
java.sql.*
;
import
java.io.File
;
import
java.sql.Connection
;
import
java.sql.Statement
;
import
org.h2.test.TestBase
;
...
...
h2/src/test/org/h2/test/db/TestTriggersConstraints.java
浏览文件 @
3f6edd17
...
...
@@ -33,7 +33,8 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"DROP TABLE IF EXISTS TEST"
);
stat
.
execute
(
"create table test(id int primary key, parent int)"
);
stat
.
execute
(
"alter table test add constraint test_parent_id foreign key(parent) references test (id) on delete cascade"
);
stat
.
execute
(
"alter table test add constraint test_parent_id foreign key(parent) references test (id) on delete cascade"
);
stat
.
execute
(
"insert into test select x, x/2 from system_range(0, 100)"
);
stat
.
execute
(
"delete from test"
);
checkSingleValue
(
stat
,
"select count(*) from test"
,
0
);
...
...
@@ -47,22 +48,29 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"DROP TABLE IF EXISTS TEST"
);
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))"
);
// CREATE TRIGGER trigger {BEFORE|AFTER} {INSERT|UPDATE|DELETE} ON table [FOR EACH ROW] [QUEUE n] [NOWAIT] CALL triggeredClass
stat
.
execute
(
"CREATE TRIGGER IF NOT EXISTS INS_BEFORE BEFORE INSERT ON TEST FOR EACH ROW NOWAIT CALL \""
+
getClass
().
getName
()+
"\""
);
stat
.
execute
(
"CREATE TRIGGER IF NOT EXISTS INS_BEFORE BEFORE INSERT ON TEST FOR EACH ROW NOWAIT CALL \""
+
getClass
().
getName
()+
"\""
);
stat
.
execute
(
"CREATE TRIGGER INS_AFTER AFTER INSERT ON TEST FOR EACH ROW NOWAIT CALL \""
+
getClass
().
getName
()+
"\""
);
stat
.
execute
(
"CREATE TRIGGER UPD_BEFORE BEFORE UPDATE ON TEST FOR EACH ROW NOWAIT CALL \""
+
getClass
().
getName
()+
"\""
);
// CREATE TRIGGER trigger {BEFORE|AFTER} {INSERT|UPDATE|DELETE} ON table
// [FOR EACH ROW] [QUEUE n] [NOWAIT] CALL triggeredClass
stat
.
execute
(
"CREATE TRIGGER IF NOT EXISTS INS_BEFORE BEFORE INSERT ON TEST FOR EACH ROW NOWAIT CALL \""
+
getClass
().
getName
()
+
"\""
);
stat
.
execute
(
"CREATE TRIGGER IF NOT EXISTS INS_BEFORE BEFORE INSERT ON TEST FOR EACH ROW NOWAIT CALL \""
+
getClass
().
getName
()
+
"\""
);
stat
.
execute
(
"CREATE TRIGGER INS_AFTER AFTER INSERT ON TEST FOR EACH ROW NOWAIT CALL \""
+
getClass
().
getName
()
+
"\""
);
stat
.
execute
(
"CREATE TRIGGER UPD_BEFORE BEFORE UPDATE ON TEST FOR EACH ROW NOWAIT CALL \""
+
getClass
().
getName
()
+
"\""
);
stat
.
execute
(
"INSERT INTO TEST VALUES(1, 'Hello')"
);
ResultSet
rs
;
rs
=
stat
.
executeQuery
(
"SCRIPT"
);
checkRows
(
rs
,
new
String
[]{
"CREATE TRIGGER PUBLIC.INS_BEFORE BEFORE INSERT ON PUBLIC.TEST FOR EACH ROW NOWAIT CALL \""
+
getClass
().
getName
()+
"\""
,
"CREATE TRIGGER PUBLIC.INS_AFTER AFTER INSERT ON PUBLIC.TEST FOR EACH ROW NOWAIT CALL \""
+
getClass
().
getName
()+
"\""
,
"CREATE TRIGGER PUBLIC.UPD_BEFORE BEFORE UPDATE ON PUBLIC.TEST FOR EACH ROW NOWAIT CALL \""
+
getClass
().
getName
()+
"\""
});
while
(
rs
.
next
())
{
checkRows
(
rs
,
new
String
[]
{
"CREATE TRIGGER PUBLIC.INS_BEFORE BEFORE INSERT ON PUBLIC.TEST FOR EACH ROW NOWAIT CALL \""
+
getClass
().
getName
()
+
"\""
,
"CREATE TRIGGER PUBLIC.INS_AFTER AFTER INSERT ON PUBLIC.TEST FOR EACH ROW NOWAIT CALL \""
+
getClass
().
getName
()
+
"\""
,
"CREATE TRIGGER PUBLIC.UPD_BEFORE BEFORE UPDATE ON PUBLIC.TEST FOR EACH ROW NOWAIT CALL \""
+
getClass
().
getName
()
+
"\""
});
while
(
rs
.
next
())
{
String
sql
=
rs
.
getString
(
1
);
if
(
sql
.
startsWith
(
"CREATE TRIGGER"
))
{
if
(
sql
.
startsWith
(
"CREATE TRIGGER"
))
{
System
.
out
.
println
(
sql
);
}
}
...
...
@@ -83,7 +91,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
try
{
stat
.
execute
(
"DROP TRIGGER INS_BEFORE"
);
error
(
"must not work"
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
stat
.
execute
(
"DROP TRIGGER INS_AFTER"
);
...
...
@@ -100,10 +108,10 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
private
void
checkRows
(
ResultSet
rs
,
String
[]
expected
)
throws
Exception
{
HashSet
set
=
new
HashSet
(
Arrays
.
asList
(
expected
));
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
set
.
remove
(
rs
.
getString
(
1
));
}
if
(
set
.
size
()>
0
)
{
if
(
set
.
size
()
>
0
)
{
error
(
"set should be empty: "
+
set
);
}
}
...
...
@@ -111,22 +119,22 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
private
String
triggerName
;
public
void
fire
(
Connection
conn
,
Object
[]
oldRow
,
Object
[]
newRow
)
throws
SQLException
{
if
(
mustNotCallTrigger
)
{
if
(
mustNotCallTrigger
)
{
throw
new
Error
(
"must not be called now"
);
}
if
(
conn
==
null
)
{
if
(
conn
==
null
)
{
throw
new
Error
(
"connection is null"
);
}
if
(
triggerName
.
startsWith
(
"INS_BEFORE"
))
{
if
(
triggerName
.
startsWith
(
"INS_BEFORE"
))
{
newRow
[
1
]
=
newRow
[
1
]
+
"-updated"
;
}
else
if
(
triggerName
.
startsWith
(
"INS_AFTER"
))
{
if
(!
newRow
[
1
].
toString
().
endsWith
(
"-updated"
))
{
}
else
if
(
triggerName
.
startsWith
(
"INS_AFTER"
))
{
if
(!
newRow
[
1
].
toString
().
endsWith
(
"-updated"
))
{
throw
new
Error
(
"supposed to be updated"
);
}
}
else
if
(
triggerName
.
startsWith
(
"UPD_BEFORE"
))
{
}
else
if
(
triggerName
.
startsWith
(
"UPD_BEFORE"
))
{
newRow
[
1
]
=
newRow
[
1
]
+
"-updated2"
;
}
else
if
(
triggerName
.
startsWith
(
"UPD_AFTER"
))
{
if
(!
newRow
[
1
].
toString
().
endsWith
(
"-updated2"
))
{
}
else
if
(
triggerName
.
startsWith
(
"UPD_AFTER"
))
{
if
(!
newRow
[
1
].
toString
().
endsWith
(
"-updated2"
))
{
throw
new
Error
(
"supposed to be updated2"
);
}
}
...
...
@@ -134,7 +142,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
public
void
init
(
Connection
conn
,
String
schemaName
,
String
triggerName
,
String
tableName
)
throws
SQLException
{
this
.
triggerName
=
triggerName
;
if
(!
"TEST"
.
equals
(
tableName
))
{
if
(!
"TEST"
.
equals
(
tableName
))
{
throw
new
Error
(
"supposed to be TEST"
);
}
}
...
...
h2/src/test/org/h2/test/db/TestView.java
浏览文件 @
3f6edd17
...
...
@@ -7,6 +7,7 @@ package org.h2.test.db;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
import
java.sql.Statement
;
import
org.h2.test.TestBase
;
public
class
TestView
extends
TestBase
{
...
...
h2/src/test/org/h2/test/ftp/clean.task
浏览文件 @
3f6edd17
h2/src/test/org/h2/test/ftp/testAll.task
浏览文件 @
3f6edd17
h2/src/test/org/h2/test/ftp/testBtree.task
浏览文件 @
3f6edd17
h2/src/test/org/h2/test/ftp/testCrash.task
浏览文件 @
3f6edd17
h2/src/test/org/h2/test/ftp/testHalt.task
浏览文件 @
3f6edd17
h2/src/test/org/h2/test/ftp/testJoin.task
浏览文件 @
3f6edd17
h2/src/test/org/h2/test/ftp/testNormal.task
浏览文件 @
3f6edd17
h2/src/test/org/h2/test/ftp/testRandom.task
浏览文件 @
3f6edd17
h2/src/test/org/h2/test/ftp/testSynth.task
浏览文件 @
3f6edd17
h2/src/test/org/h2/test/jdbc/TestCancel.java
浏览文件 @
3f6edd17
...
...
@@ -4,7 +4,11 @@
*/
package
org
.
h2
.
test
.
jdbc
;
import
java.sql.*
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
org.h2.test.TestBase
;
...
...
@@ -17,10 +21,12 @@ public class TestCancel extends TestBase {
class
CancelThread
extends
Thread
{
private
Statement
cancel
;
private
int
wait
;
CancelThread
(
Statement
cancel
,
int
wait
)
{
this
.
cancel
=
cancel
;
this
.
wait
=
wait
;
}
public
void
run
()
{
try
{
Thread
.
sleep
(
wait
);
...
...
@@ -28,7 +34,7 @@ public class TestCancel extends TestBase {
Thread
.
yield
();
}
catch
(
SQLException
e
)
{
// ignore errors on closed statements
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
TestBase
.
logError
(
"sleep"
,
e
);
}
}
...
...
@@ -43,9 +49,9 @@ public class TestCancel extends TestBase {
PreparedStatement
prep
=
conn
.
prepareStatement
(
"INSERT INTO TEST VALUES(?, ?)"
);
trace
(
"insert"
);
int
len
=
getSize
(
1
,
1000
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
prep
.
setInt
(
1
,
i
);
//prep.setString(2, "Test Value "+i);
//
prep.setString(2, "Test Value "+i);
prep
.
setString
(
2
,
"hi"
);
prep
.
execute
();
}
...
...
@@ -56,21 +62,21 @@ public class TestCancel extends TestBase {
CancelThread
cancel
=
new
CancelThread
(
query
,
i
);
cancel
.
start
();
Thread
.
yield
();
int
j
=
0
;
int
j
=
0
;
try
{
ResultSet
rs
=
query
.
executeQuery
(
"SELECT * FROM TEST"
);
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
j
++;
}
trace
(
"record count: "
+
j
);
}
catch
(
SQLException
e
)
{
trace
(
"record count: "
+
j
);
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
// ignore cancelled statements
trace
(
"record count: "
+
j
);
trace
(
"record count: "
+
j
);
}
if
(
j
==
0
)
{
if
(
j
==
0
)
{
i
+=
10
;
}
else
if
(
j
==
len
)
{
}
else
if
(
j
==
len
)
{
break
;
}
}
...
...
h2/src/test/org/h2/test/jdbc/TestDataSource.java
浏览文件 @
3f6edd17
...
...
@@ -18,28 +18,29 @@ import org.h2.test.TestBase;
public
class
TestDataSource
extends
TestBase
{
// public static void main(String[] args) throws Exception {
//
// // first, need to start on the command line:
// // rmiregistry 1099
//
// // System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.rmi.registry.RegistryContextFactory");
// System.setProperty(Context.PROVIDER_URL, "rmi://localhost:1099");
//
// JdbcDataSource ds = new JdbcDataSource();
// ds.setURL("jdbc:h2:test");
// ds.setUser("test");
// ds.setPassword("");
//
// Context ctx = new InitialContext();
// ctx.bind("jdbc/test", ds);
//
// DataSource ds2 = (DataSource)ctx.lookup("jdbc/test");
// Connection conn = ds2.getConnection();
// conn.close();
// }
// public static void main(String[] args) throws Exception {
//
// // first, need to start on the command line:
// // rmiregistry 1099
//
// // System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// "com.sun.jndi.ldap.LdapCtxFactory");
// System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
// "com.sun.jndi.rmi.registry.RegistryContextFactory");
// System.setProperty(Context.PROVIDER_URL, "rmi://localhost:1099");
//
// JdbcDataSource ds = new JdbcDataSource();
// ds.setURL("jdbc:h2:test");
// ds.setUser("test");
// ds.setPassword("");
//
// Context ctx = new InitialContext();
// ctx.bind("jdbc/test", ds);
//
// DataSource ds2 = (DataSource)ctx.lookup("jdbc/test");
// Connection conn = ds2.getConnection();
// conn.close();
// }
public
void
test
()
throws
Exception
{
testDataSource
();
...
...
@@ -49,11 +50,12 @@ public class TestDataSource extends TestBase {
private
void
testXAConnection
()
throws
Exception
{
deleteDb
(
baseDir
,
"dataSource"
);
JdbcDataSource
ds
=
new
JdbcDataSource
();
ds
.
setURL
(
"jdbc:h2:"
+
baseDir
+
"/dataSource"
);
ds
.
setURL
(
"jdbc:h2:"
+
baseDir
+
"/dataSource"
);
XAConnection
xaConn
=
ds
.
getXAConnection
();
xaConn
.
addConnectionEventListener
(
new
ConnectionEventListener
()
{
public
void
connectionClosed
(
ConnectionEvent
event
)
{
}
public
void
connectionErrorOccurred
(
ConnectionEvent
event
)
{
}
});
...
...
@@ -70,7 +72,7 @@ public class TestDataSource extends TestBase {
private
void
testDataSource
()
throws
Exception
{
deleteDb
(
baseDir
,
"dataSource"
);
JdbcDataSource
ds
=
new
JdbcDataSource
();
ds
.
setURL
(
"jdbc:h2:"
+
baseDir
+
"/dataSource"
);
ds
.
setURL
(
"jdbc:h2:"
+
baseDir
+
"/dataSource"
);
ds
.
setUser
(
"sa"
);
Connection
conn
=
ds
.
getConnection
();
Statement
stat
=
conn
.
createStatement
();
...
...
h2/src/test/org/h2/test/jdbc/TestManyJdbcObjects.java
浏览文件 @
3f6edd17
...
...
@@ -22,14 +22,14 @@ public class TestManyJdbcObjects extends TestBase {
}
private
void
testNestedResultSets
()
throws
Exception
{
if
(
config
.
networked
==
false
)
{
if
(!
config
.
networked
)
{
return
;
}
deleteDb
(
"manyObjects"
);
Connection
conn
=
getConnection
(
"manyObjects"
);
DatabaseMetaData
meta
=
conn
.
getMetaData
();
ResultSet
rsTables
=
meta
.
getColumns
(
null
,
null
,
null
,
null
);
while
(
rsTables
.
next
())
{
while
(
rsTables
.
next
())
{
meta
.
getExportedKeys
(
null
,
null
,
null
);
meta
.
getImportedKeys
(
null
,
null
,
null
);
}
...
...
@@ -37,7 +37,7 @@ public class TestManyJdbcObjects extends TestBase {
}
private
void
testManyConnections
()
throws
Exception
{
if
(
config
.
networked
==
false
||
config
.
memory
)
{
if
(!
config
.
networked
||
config
.
memory
)
{
return
;
}
// SERVER_CACHED_OBJECTS = 1000: connections = 20 (1250)
...
...
@@ -47,19 +47,19 @@ public class TestManyJdbcObjects extends TestBase {
SysProperties
.
runFinalize
=
false
;
int
connCount
=
getSize
(
4
,
40
);
Connection
[]
conn
=
new
Connection
[
connCount
];
for
(
int
i
=
0
;
i
<
connCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
connCount
;
i
++)
{
conn
[
i
]
=
getConnection
(
"manyObjects"
);
}
int
len
=
getSize
(
50
,
500
);
for
(
int
j
=
0
;
j
<
len
;
j
++)
{
if
((
j
%
10
)
==
0
)
{
for
(
int
j
=
0
;
j
<
len
;
j
++)
{
if
((
j
%
10
)
==
0
)
{
trace
(
"j="
+
j
);
}
for
(
int
i
=
0
;
i
<
connCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
connCount
;
i
++)
{
conn
[
i
].
getMetaData
().
getSchemas
().
close
();
}
}
for
(
int
i
=
0
;
i
<
connCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
connCount
;
i
++)
{
conn
[
i
].
close
();
}
SysProperties
.
runFinalize
=
true
;
...
...
@@ -72,30 +72,30 @@ public class TestManyJdbcObjects extends TestBase {
PreparedStatement
prep
;
Statement
stat
;
int
size
=
getSize
(
10
,
1000
);
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
conn
.
getMetaData
();
}
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
conn
.
createStatement
();
}
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(1, 'Hello')"
);
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
stat
.
executeQuery
(
"SELECT * FROM TEST WHERE 1=0"
);
}
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
stat
.
executeQuery
(
"SELECT * FROM TEST"
);
}
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
conn
.
prepareStatement
(
"SELECT * FROM TEST"
);
}
prep
=
conn
.
prepareStatement
(
"SELECT * FROM TEST WHERE 1=0"
);
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
prep
.
executeQuery
();
}
prep
=
conn
.
prepareStatement
(
"SELECT * FROM TEST"
);
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
prep
.
executeQuery
();
}
SysProperties
.
runFinalize
=
true
;
...
...
h2/src/test/org/h2/test/jdbc/TestMetaData.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/jdbc/TestNativeSQL.java
浏览文件 @
3f6edd17
...
...
@@ -4,7 +4,9 @@
*/
package
org
.
h2
.
test
.
jdbc
;
import
java.sql.*
;
import
java.sql.Connection
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
org.h2.test.TestBase
;
...
...
@@ -18,8 +20,8 @@ public class TestNativeSQL extends TestBase {
deleteDb
(
"nativeSql"
);
Connection
conn
=
getConnection
(
"nativeSql"
);
for
(
int
i
=
0
;
i
<
PAIRS
.
length
;
i
+=
2
)
{
test
(
conn
,
PAIRS
[
i
],
PAIRS
[
i
+
1
]);
for
(
int
i
=
0
;
i
<
PAIRS
.
length
;
i
+=
2
)
{
test
(
conn
,
PAIRS
[
i
],
PAIRS
[
i
+
1
]);
}
conn
.
nativeSQL
(
"TEST"
);
conn
.
nativeSQL
(
"TEST--testing"
);
...
...
@@ -42,7 +44,7 @@ public class TestNativeSQL extends TestBase {
try
{
stat
.
execute
(
"CALL {d '2001-01-01'} // this is a test"
);
error
(
"expected error if setEscapeProcessing=false"
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
checkFalse
(
conn
.
isClosed
());
...
...
@@ -50,31 +52,22 @@ public class TestNativeSQL extends TestBase {
check
(
conn
.
isClosed
());
}
static
final
String
[]
PAIRS
=
new
String
[]{
"CREATE TABLE TEST(ID INT PRIMARY KEY)"
,
static
final
String
[]
PAIRS
=
new
String
[]
{
"CREATE TABLE TEST(ID INT PRIMARY KEY)"
,
"CREATE TABLE TEST(ID INT PRIMARY KEY)"
,
"INSERT INTO TEST VALUES(1)"
,
"INSERT INTO TEST VALUES(1)"
,
"INSERT INTO TEST VALUES(1)"
,
"INSERT INTO TEST VALUES(1)"
,
"SELECT '{nothing}' FROM TEST"
,
"SELECT '{nothing}' FROM TEST"
,
"SELECT '{nothing}' FROM TEST"
,
"SELECT '{nothing}' FROM TEST"
,
"SELECT '{fn ABS(1)}' FROM TEST"
,
"SELECT '{fn ABS(1)}' FROM TEST"
,
"SELECT '{fn ABS(1)}' FROM TEST"
,
"SELECT '{fn ABS(1)}' FROM TEST"
,
"SELECT {d '2001-01-01'} FROM TEST"
,
"SELECT '2001-01-01' FROM TEST"
,
"SELECT {d '2001-01-01'} FROM TEST"
,
"SELECT '2001-01-01' FROM TEST"
,
"SELECT {t '20:00:00'} FROM TEST"
,
"SELECT '20:00:00' FROM TEST"
,
"SELECT {t '20:00:00'} FROM TEST"
,
"SELECT '20:00:00' FROM TEST"
,
"SELECT {ts '2001-01-01 20:00:00'} FROM TEST"
,
"SELECT '2001-01-01 20:00:00' FROM TEST"
,
"SELECT {ts '2001-01-01 20:00:00'} FROM TEST"
,
"SELECT '2001-01-01 20:00:00' FROM TEST"
,
"SELECT {fn CONCAT('{fn x}','{oj}')} FROM TEST"
,
"SELECT CONCAT('{fn x}','{oj}') FROM TEST"
,
"SELECT {fn CONCAT('{fn x}','{oj}')} FROM TEST"
,
"SELECT CONCAT('{fn x}','{oj}') FROM TEST"
,
"SELECT * FROM {oj TEST T1 LEFT OUTER JOIN TEST T2 ON T1.ID=T2.ID}"
,
"SELECT * FROM TEST T1 LEFT OUTER JOIN TEST T2 ON T1.ID=T2.ID "
,
...
...
@@ -85,27 +78,22 @@ public class TestNativeSQL extends TestBase {
"SELECT * FROM TEST WHERE '}' LIKE '}}' {escape '}'}"
,
"SELECT * FROM TEST WHERE '}' LIKE '}}' escape '}' "
,
"{call TEST('}')}"
,
" call TEST('}') "
,
"{call TEST('}')}"
,
" call TEST('}') "
,
"{?= call TEST('}')}"
,
" call TEST('}') "
,
"{?= call TEST('}')}"
,
" call TEST('}') "
,
"{? = call TEST('}')}"
,
" call TEST('}') "
,
"{? = call TEST('}')}"
,
" call TEST('}') "
,
"{{{{this is a bug}"
,
null
,
};
"{{{{this is a bug}"
,
null
,
};
void
test
(
Connection
conn
,
String
original
,
String
expected
)
throws
Exception
{
trace
(
"original: <"
+
original
+
">"
);
trace
(
"expected: <"
+
expected
+
">"
);
void
test
(
Connection
conn
,
String
original
,
String
expected
)
throws
Exception
{
trace
(
"original: <"
+
original
+
">"
);
trace
(
"expected: <"
+
expected
+
">"
);
try
{
String
result
=
conn
.
nativeSQL
(
original
);
trace
(
"result: <"
+
result
+
">"
);
String
result
=
conn
.
nativeSQL
(
original
);
trace
(
"result: <"
+
result
+
">"
);
check
(
expected
,
result
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
check
(
expected
,
null
);
checkNotGeneralException
(
e
);
trace
(
"got exception, good"
);
...
...
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/jdbc/TestResultSet.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/jdbc/TestStatement.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/jdbc/TestTransactionIsolation.java
浏览文件 @
3f6edd17
...
...
@@ -4,7 +4,8 @@
*/
package
org
.
h2
.
test
.
jdbc
;
import
java.sql.*
;
import
java.sql.Connection
;
import
java.sql.SQLException
;
import
org.h2.test.TestBase
;
...
...
@@ -13,7 +14,7 @@ public class TestTransactionIsolation extends TestBase {
Connection
conn1
,
conn2
;
public
void
test
()
throws
Exception
{
if
(
config
.
isMVCC
())
{
if
(
config
.
isMVCC
())
{
// no tests yet
}
else
{
testTableLevelLocking
();
...
...
@@ -54,7 +55,7 @@ public class TestTransactionIsolation extends TestBase {
try
{
checkSingleValue
(
conn2
.
createStatement
(),
"SELECT * FROM TEST"
,
1
);
error
(
"Expected lock timeout"
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
conn1
.
commit
();
...
...
@@ -76,7 +77,7 @@ public class TestTransactionIsolation extends TestBase {
try
{
conn1
.
createStatement
().
executeUpdate
(
"DELETE FROM TEST"
);
error
(
"Expected lock timeout"
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
conn2
.
commit
();
...
...
h2/src/test/org/h2/test/jdbc/TestUpdatableResultSet.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/jdbc/TestXASimple.java
浏览文件 @
3f6edd17
...
...
@@ -5,6 +5,7 @@
package
org
.
h2
.
test
.
jdbc
;
import
java.sql.Connection
;
import
org.h2.jdbcx.JdbcDataSource
;
public
class
TestXASimple
{
...
...
@@ -14,9 +15,8 @@ public class TestXASimple {
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Class
.
forName
(
"org.h2.Driver"
);
// InitialContext context = new InitialContext();
// context.rebind(USER_TRANSACTION_JNDI_NAME, j.getUserTransaction());
// InitialContext context = new InitialContext();
// context.rebind(USER_TRANSACTION_JNDI_NAME, j.getUserTransaction());
JdbcDataSource
ds1
=
new
JdbcDataSource
();
ds1
.
setPassword
(
""
);
...
...
@@ -28,8 +28,9 @@ public class TestXASimple {
ds2
.
setUser
(
"sa"
);
ds2
.
setURL
(
"jdbc:h2:db2H2"
);
// UserTransaction ut = (UserTransaction) context.lookup("UserTransaction");
// ut.begin();
// UserTransaction ut = (UserTransaction)
// context.lookup("UserTransaction");
// ut.begin();
Connection
c1
=
ds1
.
getXAConnection
().
getConnection
();
c1
.
setAutoCommit
(
false
);
...
...
@@ -39,13 +40,12 @@ public class TestXASimple {
c1
.
createStatement
().
executeUpdate
(
"create table test(id int, test varchar(255))"
);
c2
.
createStatement
().
executeUpdate
(
"create table test(id int, test varchar(255))"
);
// ut.rollback();
// ut.rollback();
c1
.
close
();
c2
.
close
();
//
j.stop();
//
System.exit(0);
//
j.stop();
//
System.exit(0);
}
}
h2/src/test/org/h2/test/jdbc/TestZloty.java
浏览文件 @
3f6edd17
...
...
@@ -61,6 +61,7 @@ public class TestZloty extends TestBase {
/**
* H2 destroyer application ;->
*
* @author Maciej Wegorkiewicz
*/
private
void
testZloty
()
throws
Exception
{
...
...
@@ -76,20 +77,23 @@ public class TestZloty extends TestBase {
prep
.
setBigDecimal
(
2
,
new
ZlotyBigDecimal
(
"11.0"
));
prep
.
execute
();
error
(
"unexpected success"
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
prep
.
setInt
(
1
,
3
);
try
{
BigDecimal
value
=
new
BigDecimal
(
"12.100000"
)
{
BigDecimal
value
=
new
BigDecimal
(
"12.100000"
)
{
private
static
final
long
serialVersionUID
=
-
7909023971521750844L
;
public
String
toString
()
{
return
"12,100000 EURO"
;
}
public
String
toString
()
{
return
"12,100000 EURO"
;
}
};
prep
.
setBigDecimal
(
2
,
value
);
prep
.
execute
();
error
(
"unexpected success"
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
h2/src/test/org/h2/test/synth/Column.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/Command.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/DbConnection.java
浏览文件 @
3f6edd17
...
...
@@ -31,7 +31,7 @@ class DbConnection implements DbInterface {
this
.
password
=
password
;
this
.
id
=
id
;
this
.
useSentinel
=
useSentinel
;
log
(
"url="
+
url
);
log
(
"url="
+
url
);
}
public
void
reset
()
throws
SQLException
{
...
...
@@ -39,10 +39,10 @@ class DbConnection implements DbInterface {
DatabaseMetaData
meta
=
conn
.
getMetaData
();
Statement
stat
=
conn
.
createStatement
();
ArrayList
tables
=
new
ArrayList
();
ResultSet
rs
=
meta
.
getTables
(
null
,
null
,
null
,
new
String
[]
{
"TABLE"
});
ResultSet
rs
=
meta
.
getTables
(
null
,
null
,
null
,
new
String
[]
{
"TABLE"
});
while
(
rs
.
next
())
{
String
schemaName
=
rs
.
getString
(
"TABLE_SCHEM"
);
if
(!
"INFORMATION_SCHEMA"
.
equals
(
schemaName
))
{
if
(!
"INFORMATION_SCHEMA"
.
equals
(
schemaName
))
{
tables
.
add
(
rs
.
getString
(
"TABLE_NAME"
));
}
}
...
...
@@ -61,22 +61,22 @@ class DbConnection implements DbInterface {
}
// could not drop any table and still tables to drop
if
(
dropped
==
0
&&
tables
.
size
()
>
0
)
{
throw
new
Error
(
"Cannot drop "
+
tables
);
throw
new
Error
(
"Cannot drop "
+
tables
);
}
}
}
public
void
connect
()
throws
Exception
{
if
(
useSentinel
&&
sentinel
==
null
)
{
if
(
useSentinel
&&
sentinel
==
null
)
{
sentinel
=
getConnection
();
}
log
(
"connect to "
+
url
+
";"
);
log
(
"connect to "
+
url
+
";"
);
conn
=
getConnection
();
}
private
Connection
getConnection
()
throws
Exception
{
log
(
"(getConnection to "
+
url
+
");"
);
if
(
driver
==
null
)
{
log
(
"(getConnection to "
+
url
+
");"
);
if
(
driver
==
null
)
{
return
config
.
getConnection
(
"synth"
);
}
else
{
Class
.
forName
(
driver
);
...
...
@@ -85,13 +85,13 @@ class DbConnection implements DbInterface {
}
public
void
disconnect
()
throws
SQLException
{
log
(
"disconnect "
+
url
+
";"
);
log
(
"disconnect "
+
url
+
";"
);
conn
.
close
();
}
public
void
end
()
throws
SQLException
{
log
(
"end "
+
url
+
";"
);
if
(
sentinel
!=
null
)
{
log
(
"end "
+
url
+
";"
);
if
(
sentinel
!=
null
)
{
sentinel
.
close
();
sentinel
=
null
;
}
...
...
@@ -122,12 +122,12 @@ class DbConnection implements DbInterface {
}
private
void
execute
(
String
sql
)
throws
SQLException
{
log
(
sql
+
";"
);
log
(
sql
+
";"
);
conn
.
createStatement
().
execute
(
sql
);
}
public
Result
select
(
String
sql
)
throws
SQLException
{
log
(
sql
+
";"
);
log
(
sql
+
";"
);
Statement
stat
=
conn
.
createStatement
();
Result
result
=
new
Result
(
config
,
sql
,
stat
.
executeQuery
(
sql
));
return
result
;
...
...
@@ -135,10 +135,10 @@ class DbConnection implements DbInterface {
public
Result
delete
(
Table
table
,
String
condition
)
throws
SQLException
{
String
sql
=
"DELETE FROM "
+
table
.
getName
();
if
(
condition
!=
null
)
{
if
(
condition
!=
null
)
{
sql
+=
" WHERE "
+
condition
;
}
log
(
sql
+
";"
);
log
(
sql
+
";"
);
Statement
stat
=
conn
.
createStatement
();
Result
result
=
new
Result
(
sql
,
stat
.
executeUpdate
(
sql
));
return
result
;
...
...
@@ -146,23 +146,23 @@ class DbConnection implements DbInterface {
public
Result
update
(
Table
table
,
Column
[]
columns
,
Value
[]
values
,
String
condition
)
throws
SQLException
{
String
sql
=
"UPDATE "
+
table
.
getName
()
+
" SET "
;
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++)
{
if
(
i
>
0
)
{
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++)
{
if
(
i
>
0
)
{
sql
+=
", "
;
}
sql
+=
columns
[
i
].
getName
()
+
"="
+
values
[
i
].
getSQL
();
}
if
(
condition
!=
null
)
{
if
(
condition
!=
null
)
{
sql
+=
" WHERE "
+
condition
;
}
log
(
sql
+
";"
);
log
(
sql
+
";"
);
Statement
stat
=
conn
.
createStatement
();
Result
result
=
new
Result
(
sql
,
stat
.
executeUpdate
(
sql
));
return
result
;
}
public
void
setAutoCommit
(
boolean
b
)
throws
SQLException
{
log
(
"set autoCommit "
+
b
+
";"
);
log
(
"set autoCommit "
+
b
+
";"
);
conn
.
setAutoCommit
(
b
);
}
...
...
h2/src/test/org/h2/test/synth/DbInterface.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/DbState.java
浏览文件 @
3f6edd17
...
...
@@ -75,7 +75,7 @@ public class DbState implements DbInterface {
}
public
Table
randomTable
()
{
if
(
tables
.
size
()
==
0
)
{
if
(
tables
.
size
()
==
0
)
{
return
null
;
}
int
i
=
config
.
random
().
getInt
(
tables
.
size
());
...
...
h2/src/test/org/h2/test/synth/Expression.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/Index.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/RandomGen.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/Result.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/Row.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/Table.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/TestBtreeIndex.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/TestCrashAPI.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/TestHalt.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/TestHaltApp.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/TestJoin.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/TestKill.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/TestKillProcess.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/TestMulti.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/TestMultiNews.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/TestMultiNewsSimple.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/TestMultiOrder.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/TestMultiThread.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/TestRandomSQL.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/TestSimpleIndex.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/TestSynth.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/TestThreads.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/TestTimer.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
h2/src/test/org/h2/test/synth/Value.java
浏览文件 @
3f6edd17
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论