Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
18bb2a2e
提交
18bb2a2e
authored
2月 19, 2008
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
cf291f53
隐藏空白字符变更
内嵌
并排
正在显示
33 个修改的文件
包含
117 行增加
和
109 行删除
+117
-109
history.html
h2/src/docsrc/html/history.html
+1
-0
RuleFixed.java
h2/src/main/org/h2/bnf/RuleFixed.java
+3
-3
RuleOptional.java
h2/src/main/org/h2/bnf/RuleOptional.java
+1
-1
User.java
h2/src/main/org/h2/engine/User.java
+4
-0
DiskFile.java
h2/src/main/org/h2/store/DiskFile.java
+2
-14
Storage.java
h2/src/main/org/h2/store/Storage.java
+2
-1
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+4
-21
TestBase.java
h2/src/test/org/h2/test/TestBase.java
+4
-0
TestAutoRecompile.java
h2/src/test/org/h2/test/db/TestAutoRecompile.java
+2
-2
TestCases.java
h2/src/test/org/h2/test/db/TestCases.java
+4
-4
TestExclusive.java
h2/src/test/org/h2/test/db/TestExclusive.java
+1
-1
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+1
-1
TestLinkedTable.java
h2/src/test/org/h2/test/db/TestLinkedTable.java
+1
-1
TestPowerOff.java
h2/src/test/org/h2/test/db/TestPowerOff.java
+5
-5
TestRights.java
h2/src/test/org/h2/test/db/TestRights.java
+29
-6
TestRunscript.java
h2/src/test/org/h2/test/db/TestRunscript.java
+1
-1
TestSQLInjection.java
h2/src/test/org/h2/test/db/TestSQLInjection.java
+1
-1
TestSpaceReuse.java
h2/src/test/org/h2/test/db/TestSpaceReuse.java
+1
-1
TestTransaction.java
h2/src/test/org/h2/test/db/TestTransaction.java
+1
-1
TestTriggersConstraints.java
h2/src/test/org/h2/test/db/TestTriggersConstraints.java
+1
-1
TestBatchUpdates.java
h2/src/test/org/h2/test/jdbc/TestBatchUpdates.java
+3
-3
TestCancel.java
h2/src/test/org/h2/test/jdbc/TestCancel.java
+3
-3
TestPreparedStatement.java
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
+12
-13
TestStatement.java
h2/src/test/org/h2/test/jdbc/TestStatement.java
+4
-4
TestUpdatableResultSet.java
h2/src/test/org/h2/test/jdbc/TestUpdatableResultSet.java
+1
-1
TestZloty.java
h2/src/test/org/h2/test/jdbc/TestZloty.java
+2
-2
TestMvcc1.java
h2/src/test/org/h2/test/mvcc/TestMvcc1.java
+5
-5
TestPgServer.java
h2/src/test/org/h2/test/server/TestPgServer.java
+2
-2
TestRandomSQL.java
h2/src/test/org/h2/test/synth/TestRandomSQL.java
+8
-3
TestFileSystem.java
h2/src/test/org/h2/test/unit/TestFileSystem.java
+1
-1
TestOverflow.java
h2/src/test/org/h2/test/unit/TestOverflow.java
+2
-2
TestServlet.java
h2/src/test/org/h2/test/unit/TestServlet.java
+3
-3
TestStringUtils.java
h2/src/test/org/h2/test/unit/TestStringUtils.java
+2
-2
没有找到文件。
h2/src/docsrc/html/history.html
浏览文件 @
18bb2a2e
...
...
@@ -109,6 +109,7 @@ via PayPal:
</li><li>
lumber-mill.co.jp, Japan
</li><li>
Oliver Computing LLC, USA
</li><li>
Harpal Grover Consulting Inc., USA
</li><li>
Elisabetta Berlini, Italy
</li></ul>
</div></td></tr></table></body></html>
h2/src/main/org/h2/bnf/RuleFixed.java
浏览文件 @
18bb2a2e
...
...
@@ -42,9 +42,9 @@ public class RuleFixed implements Rule {
case
ANY_WORD:
case
ANY_UNTIL_END:
{
StringBuffer
buff
=
new
StringBuffer
();
int
len
=
r
.
next
Int
(
10
);
int
len
=
r
.
next
Boolean
()
?
1
:
r
.
nextInt
(
5
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
buff
.
append
((
char
)
(
'A'
+
r
.
nextInt
(
'
Z
'
-
'A'
)));
buff
.
append
((
char
)
(
'A'
+
r
.
nextInt
(
'
C
'
-
'A'
)));
}
return
buff
.
toString
();
}
...
...
@@ -53,7 +53,7 @@ public class RuleFixed implements Rule {
case
CONCAT:
return
"||"
;
case
AZ_UNDERLINE:
return
""
+
(
char
)
(
'A'
+
r
.
nextInt
(
'
Z
'
-
'A'
));
return
""
+
(
char
)
(
'A'
+
r
.
nextInt
(
'
C
'
-
'A'
));
case
AF:
return
""
+
(
char
)
(
'A'
+
r
.
nextInt
(
'F'
-
'A'
));
case
DIGIT:
...
...
h2/src/main/org/h2/bnf/RuleOptional.java
浏览文件 @
18bb2a2e
...
...
@@ -22,7 +22,7 @@ public class RuleOptional implements Rule {
}
public
String
random
(
Bnf
config
,
int
level
)
{
if
(
level
>
10
?
config
.
getRandom
().
nextInt
(
level
)
==
1
:
config
.
getRandom
().
next
Boolean
()
)
{
if
(
level
>
10
?
config
.
getRandom
().
nextInt
(
level
)
==
1
:
config
.
getRandom
().
next
Int
(
4
)
==
1
)
{
return
rule
.
random
(
config
,
level
+
1
);
}
else
{
return
""
;
...
...
h2/src/main/org/h2/engine/User.java
浏览文件 @
18bb2a2e
...
...
@@ -92,6 +92,10 @@ public class User extends RightOwner {
}
}
if
(!
isRightGrantedRecursive
(
table
,
rightMask
))
{
if
(
table
.
getTemporary
()
&&
!
table
.
getGlobalTemporary
())
{
// the owner has all rights on local temporary tables
return
;
}
throw
Message
.
getSQLException
(
ErrorCode
.
NOT_ENOUGH_RIGHTS_FOR_1
,
table
.
getSQL
());
}
}
...
...
h2/src/main/org/h2/store/DiskFile.java
浏览文件 @
18bb2a2e
...
...
@@ -33,7 +33,6 @@ import org.h2.util.CacheObject;
import
org.h2.util.CacheWriter
;
import
org.h2.util.FileUtils
;
import
org.h2.util.IntArray
;
import
org.h2.util.IntHashMap
;
import
org.h2.util.MathUtils
;
import
org.h2.util.ObjectArray
;
import
org.h2.util.ObjectUtils
;
...
...
@@ -80,9 +79,6 @@ public class DiskFile implements CacheWriter {
private
HashSet
potentiallyFreePages
;
private
int
fileBlockCount
;
private
IntArray
pageOwners
;
// the latest delete in a page
private
IntArray
pageDelete
;
private
Cache
cache
;
private
LogSystem
log
;
private
DataPage
rowBuff
;
...
...
@@ -138,7 +134,6 @@ public class DiskFile implements CacheWriter {
used
=
new
BitField
();
deleted
=
new
BitField
();
pageOwners
=
new
IntArray
();
pageDelete
=
new
IntArray
();
// init pageOwners
setBlockCount
(
fileBlockCount
);
redoBuffer
=
new
ObjectArray
();
...
...
@@ -150,7 +145,6 @@ public class DiskFile implements CacheWriter {
int
pages
=
getPage
(
count
);
while
(
pages
>=
pageOwners
.
size
())
{
pageOwners
.
add
(
FREE_PAGE
);
pageDelete
.
add
(
0
);
}
}
...
...
@@ -609,10 +603,6 @@ public class DiskFile implements CacheWriter {
freePage
(
getPage
(
i
));
}
}
int
start
=
getPage
(
pos
),
end
=
getPage
(
pos
+
blockCount
);
for
(
int
i
=
start
;
i
<=
end
;
i
++)
{
pageDelete
.
set
(
i
,
nextDeleteId
);
}
}
void
reuseSpace
()
throws
SQLException
{
...
...
@@ -622,14 +612,13 @@ public class DiskFile implements CacheWriter {
int
oldest
=
0
;
for
(
int
i
=
0
;
i
<
sessions
.
length
;
i
++)
{
int
deleteId
=
sessions
[
i
].
getLastUncommittedDelete
();
if
(
oldest
==
0
||
deleteId
<
oldest
)
{
if
(
oldest
==
0
||
(
deleteId
!=
0
&&
deleteId
<
oldest
)
)
{
oldest
=
deleteId
;
}
}
for
(
Iterator
it
=
potentiallyFreePages
.
iterator
();
it
.
hasNext
();)
{
int
p
=
((
Integer
)
it
.
next
()).
intValue
();
int
testingReallyCareful
;
if
(
oldest
==
0
/*|| oldest > pageDelete.get(p)*/
)
{
if
(
oldest
==
0
)
{
setPageOwner
(
p
,
FREE_PAGE
);
it
.
remove
();
}
...
...
@@ -698,7 +687,6 @@ public class DiskFile implements CacheWriter {
database
.
getStorage
(
storageId
,
this
).
addPage
(
page
);
if
(
SysProperties
.
REUSE_SPACE_QUICKLY
)
{
potentiallyFreePages
.
remove
(
ObjectUtils
.
getInteger
(
page
));
pageDelete
.
set
(
page
,
0
);
}
}
pageOwners
.
set
(
page
,
storageId
);
...
...
h2/src/main/org/h2/store/Storage.java
浏览文件 @
18bb2a2e
...
...
@@ -149,6 +149,7 @@ public class Storage {
}
record
.
setDeleted
(
true
);
int
blockCount
=
record
.
getBlockCount
();
file
.
uncommittedDelete
(
session
);
free
(
pos
,
blockCount
);
recordCount
--;
file
.
removeRecord
(
session
,
pos
,
record
,
blockCount
);
...
...
@@ -266,7 +267,7 @@ public class Storage {
pageCheckIndex
=
(
pageCheckIndex
+
1
)
%
pages
.
size
();
int
page
=
pages
.
get
(
pageCheckIndex
);
if
(
file
.
isPageFree
(
page
)
&&
file
.
getPageOwner
(
page
)
==
id
)
{
file
.
freePage
(
page
);
//
file.freePage(page);
}
}
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
18bb2a2e
...
...
@@ -156,6 +156,9 @@ java org.h2.test.TestAll timer
Test space re-use
REUSE_SPACE_AFTER=20 or so
delete old ipowerb content (first filter, then remove)
link to new changelog and roadmap, remove pages from google groups
sourceDocs.html: move
Automate real power off tests
...
...
@@ -163,33 +166,18 @@ timer test
Can sometimes not delete log file? need test case
link to new changelog and roadmap, remove pages from google groups
Adjust cache memory usage
// test with garbage at the end of the log file (must be consistently detected as such)
// TestRandomSQL is too random; most statements fails
// extend the random join test that compared the result against PostgreSQL
// long running test with the same database
// repeatable test with a very big database (making backups of the database files)
Test Recovery with MAX_LOG_FILE_SIZE=1; test with various log file sizes
History:
Empty space is re-used less agressively because this could cause database corruption in some cases.
CSV tool now support lineSeparator
Roadmap:
The user should be allowed to do everything with his own temp tables (and views).
CREATE USER IF NOT EXISTS READER PASSWORD 'READER';
<login as READER>
CREATE LOCAL TEMPORARY TABLE IF NOT EXISTS MY_TEST(ID INT);
INSERT INTO MY_TEST VALUES(1);
SELECT * FROM MY_TEST;
DROP TABLE MY_TEST;
*/
if
(
args
.
length
>
0
)
{
...
...
@@ -426,10 +414,7 @@ DROP TABLE MY_TEST;
new
TestSQLInjection
().
runTest
(
this
);
new
TestSessionsLocks
().
runTest
(
this
);
new
TestSequence
().
runTest
(
this
);
int
todo2
;
new
TestSpaceReuse
().
runTest
(
this
);
new
TestSpeed
().
runTest
(
this
);
new
TestTempTables
().
runTest
(
this
);
new
TestTransaction
().
runTest
(
this
);
...
...
@@ -469,8 +454,6 @@ DROP TABLE MY_TEST;
// synth
new
TestCrashAPI
().
runTest
(
this
);
new
TestRandomSQL
().
runTest
(
this
);
int
test3
;
new
TestKillRestart
().
runTest
(
this
);
new
TestKillRestartMulti
().
runTest
(
this
);
...
...
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
18bb2a2e
...
...
@@ -211,6 +211,10 @@ public abstract class TestBase {
return
mb
;
}
protected
void
error
()
throws
Exception
{
error
(
"Unexpected success"
);
}
protected
void
error
(
String
string
)
throws
Exception
{
println
(
string
);
throw
new
Exception
(
string
);
...
...
h2/src/test/org/h2/test/db/TestAutoRecompile.java
浏览文件 @
18bb2a2e
...
...
@@ -34,13 +34,13 @@ public class TestAutoRecompile extends TestBase {
stat
.
execute
(
"ALTER TABLE TEST ADD COLUMN Z INT"
);
try
{
prep
.
execute
();
error
(
"must fail"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
try
{
prep
.
execute
();
error
(
"must fail"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
h2/src/test/org/h2/test/db/TestCases.java
浏览文件 @
18bb2a2e
...
...
@@ -226,7 +226,7 @@ public class TestCases extends TestBase {
stat
.
execute
(
"insert into test values(1);"
);
try
{
stat
.
execute
(
"alter table test add column name varchar not null;"
);
error
(
"shouldn't work"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
@@ -253,7 +253,7 @@ public class TestCases extends TestBase {
stat
.
execute
(
"insert into test values(1)"
);
try
{
stat
.
execute
(
"alter table test alter column id date"
);
error
(
"shouldn't work"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
@@ -353,7 +353,7 @@ public class TestCases extends TestBase {
stat
=
conn
.
createStatement
();
try
{
stat
.
execute
(
"select * from abc"
);
error
(
"abc should be deleted"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
@@ -560,7 +560,7 @@ public class TestCases extends TestBase {
Statement
stat2
=
conn2
.
createStatement
();
try
{
stat2
.
execute
(
"UPDATE TEST SET ID=2"
);
error
(
"must fail"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
h2/src/test/org/h2/test/db/TestExclusive.java
浏览文件 @
18bb2a2e
...
...
@@ -23,7 +23,7 @@ public class TestExclusive extends TestBase {
try
{
Connection
conn2
=
getConnection
(
"exclusive"
);
conn2
.
close
();
error
(
"unexpected success"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
18bb2a2e
...
...
@@ -146,7 +146,7 @@ public class TestFunctions extends TestBase {
try
{
rs
=
stat
.
executeQuery
(
"CALL SELECT_F('ERROR')"
);
error
(
"expected error"
);
error
();
}
catch
(
SQLException
e
)
{
check
(
"42001"
,
e
.
getSQLState
());
}
...
...
h2/src/test/org/h2/test/db/TestLinkedTable.java
浏览文件 @
18bb2a2e
...
...
@@ -127,7 +127,7 @@ public class TestLinkedTable extends TestBase {
stat2
.
executeUpdate
(
"INSERT INTO TEST_LINK_DI VALUES(2, 'World')"
);
try
{
stat2
.
executeUpdate
(
"UPDATE TEST_LINK_U SET ID=ID+1"
);
error
(
"unexpected success"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
h2/src/test/org/h2/test/db/TestPowerOff.java
浏览文件 @
18bb2a2e
...
...
@@ -163,9 +163,9 @@ public class TestPowerOff extends TestBase {
try
{
stat
.
execute
(
"INSERT INTO TEST VALUES(2, 'Hello')"
);
stat
.
execute
(
"CHECKPOINT"
);
error
(
"should not work!"
);
error
();
}
catch
(
SQLException
e
)
{
// expected
checkNotGeneralException
(
e
);
}
boolean
deleted
=
false
;
ArrayList
files
=
FileLister
.
getDatabaseFiles
(
dir
,
dbName
,
false
);
...
...
@@ -197,9 +197,9 @@ public class TestPowerOff extends TestBase {
stat
.
execute
(
"INSERT INTO TEST VALUES(2, 'Hello')"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(3, 'Hello')"
);
stat
.
execute
(
"CHECKPOINT"
);
error
(
"should have failed!"
);
}
catch
(
Exception
e
)
{
// ok
error
();
}
catch
(
SQL
Exception
e
)
{
checkNotGeneralException
(
e
);
}
((
JdbcConnection
)
conn
).
setPowerOffCount
(
0
);
...
...
h2/src/test/org/h2/test/db/TestRights.java
浏览文件 @
18bb2a2e
...
...
@@ -20,6 +20,7 @@ public class TestRights extends TestBase {
private
Statement
stat
;
public
void
test
()
throws
Exception
{
testDropTempTables
();
// testLowerCaseUser();
testSchemaRenameUser
();
testAccessRights
();
...
...
@@ -39,6 +40,28 @@ public class TestRights extends TestBase {
// conn.close();
// }
private
void
testDropTempTables
()
throws
Exception
{
deleteDb
(
"rights"
);
Connection
conn
=
getConnection
(
"rights"
);
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE USER IF NOT EXISTS READER PASSWORD 'READER'"
);
stat
.
execute
(
"CREATE TABLE TEST(ID INT)"
);
Connection
conn2
=
getConnection
(
"rights"
,
"READER"
,
"READER"
);
Statement
stat2
=
conn2
.
createStatement
();
try
{
stat2
.
execute
(
"SELECT * FROM TEST"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
stat2
.
execute
(
"CREATE LOCAL TEMPORARY TABLE IF NOT EXISTS MY_TEST(ID INT)"
);
stat2
.
execute
(
"INSERT INTO MY_TEST VALUES(1)"
);
stat2
.
execute
(
"SELECT * FROM MY_TEST"
);
stat2
.
execute
(
"DROP TABLE MY_TEST"
);
conn2
.
close
();
conn
.
close
();
}
public
void
testSchemaRenameUser
()
throws
Exception
{
if
(
config
.
memory
)
{
return
;
...
...
@@ -56,13 +79,13 @@ public class TestRights extends TestBase {
stat
.
execute
(
"select * from b.test"
);
try
{
stat
.
execute
(
"alter user test1 admin false"
);
error
(
"Unexpected success"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
try
{
stat
.
execute
(
"drop user test1"
);
error
(
"Unexpected success"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
@@ -145,19 +168,19 @@ public class TestRights extends TestBase {
try
{
conn
=
getConnection
(
"rights"
,
"Test"
,
"abc"
);
error
(
"
unexpected success (mixed case user name)
"
);
error
(
"
mixed case user name
"
);
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
try
{
conn
=
getConnection
(
"rights"
,
"TEST"
,
"abc"
);
error
(
"
unexpected success (wrong password)
"
);
error
(
"
wrong password
"
);
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
try
{
conn
=
getConnection
(
"rights"
,
"TEST"
,
null
);
error
(
"
unexpected success (wrong password)
"
);
error
(
"
wrong password
"
);
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
@@ -223,7 +246,7 @@ public class TestRights extends TestBase {
public
void
executeError
(
String
sql
)
throws
Exception
{
try
{
stat
.
execute
(
sql
);
error
(
"
unexpected success (not admin)
"
);
error
(
"
not admin
"
);
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
h2/src/test/org/h2/test/db/TestRunscript.java
浏览文件 @
18bb2a2e
...
...
@@ -65,7 +65,7 @@ public class TestRunscript extends TestBase implements Trigger {
if
(
password
)
{
try
{
stat2
.
execute
(
sql
);
error
(
"should fail"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
h2/src/test/org/h2/test/db/TestSQLInjection.java
浏览文件 @
18bb2a2e
...
...
@@ -38,7 +38,7 @@ public class TestSQLInjection extends TestBase {
try
{
check
(
checkPasswordInsecure
(
"123456"
));
error
(
"Should fail now"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
h2/src/test/org/h2/test/db/TestSpaceReuse.java
浏览文件 @
18bb2a2e
...
...
@@ -36,7 +36,7 @@ public class TestSpaceReuse extends TestBase {
}
}
if
(
now
>
first
)
{
this
.
error
(
"first: "
+
first
+
" now: "
+
now
);
error
(
"first: "
+
first
+
" now: "
+
now
);
}
}
...
...
h2/src/test/org/h2/test/db/TestTransaction.java
浏览文件 @
18bb2a2e
...
...
@@ -41,7 +41,7 @@ public class TestTransaction extends TestBase {
Statement
s2
=
c2
.
createStatement
();
try
{
s2
.
executeUpdate
(
"insert into B values('two', 1)"
);
error
(
"Unexpected success"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
h2/src/test/org/h2/test/db/TestTriggersConstraints.java
浏览文件 @
18bb2a2e
...
...
@@ -89,7 +89,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
stat
.
execute
(
"DROP TRIGGER IF EXISTS INS_BEFORE"
);
try
{
stat
.
execute
(
"DROP TRIGGER INS_BEFORE"
);
error
(
"must not work"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
h2/src/test/org/h2/test/jdbc/TestBatchUpdates.java
浏览文件 @
18bb2a2e
...
...
@@ -167,7 +167,7 @@ public class TestBatchUpdates extends TestBase {
trace
(
"updateCount length:"
+
updateCountLen
);
if
(
updateCountLen
!=
3
)
{
error
(
"
addBatch"
);
error
(
"
updateCount: "
+
updateCountLen
);
}
else
{
trace
(
"addBatch add the SQL statements to Batch "
);
}
...
...
@@ -204,7 +204,7 @@ public class TestBatchUpdates extends TestBase {
updCountLength
=
updateCount
.
length
;
trace
(
"updateCount Length:"
+
updCountLength
);
if
(
updCountLength
!=
3
)
{
error
(
"addBatch
"
);
error
(
"addBatch
"
+
updCountLength
);
}
else
{
trace
(
"addBatch add the SQL statements to Batch "
);
}
...
...
@@ -243,7 +243,7 @@ public class TestBatchUpdates extends TestBase {
if
(
updCountLength
==
0
)
{
trace
(
"clearBatch Method clears the current Batch "
);
}
else
{
error
(
"clearBatch
"
);
error
(
"clearBatch
"
+
updCountLength
);
}
}
...
...
h2/src/test/org/h2/test/jdbc/TestCancel.java
浏览文件 @
18bb2a2e
...
...
@@ -63,7 +63,7 @@ public class TestCancel extends TestBase {
check
(
1000
,
rs
.
getInt
(
1
));
try
{
stat
.
executeQuery
(
"SELECT MAX(RAND()) FROM SYSTEM_RANGE(1, 100000000)"
);
error
(
"unexpected success"
);
error
();
}
catch
(
SQLException
e
)
{
check
(
ErrorCode
.
STATEMENT_WAS_CANCELLED
,
e
.
getErrorCode
());
}
...
...
@@ -80,7 +80,7 @@ public class TestCancel extends TestBase {
stat
.
execute
(
"SET QUERY_TIMEOUT 10"
);
try
{
stat
.
executeQuery
(
"SELECT MAX(RAND()) FROM SYSTEM_RANGE(1, 100000000)"
);
error
(
"unexpected success"
);
error
();
}
catch
(
SQLException
e
)
{
check
(
ErrorCode
.
STATEMENT_WAS_CANCELLED
,
e
.
getErrorCode
());
}
...
...
@@ -96,7 +96,7 @@ public class TestCancel extends TestBase {
Statement
stat
=
conn
.
createStatement
();
try
{
stat
.
executeQuery
(
"SELECT MAX(RAND()) FROM SYSTEM_RANGE(1, 100000000)"
);
error
(
"unexpected success"
);
error
();
}
catch
(
SQLException
e
)
{
check
(
ErrorCode
.
STATEMENT_WAS_CANCELLED
,
e
.
getErrorCode
());
}
...
...
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
浏览文件 @
18bb2a2e
...
...
@@ -58,18 +58,18 @@ public class TestPreparedStatement extends TestBase {
testParameterMetaData
(
conn
);
conn
.
close
();
}
private
void
testExecuteErrorTwice
(
Connection
conn
)
throws
Exception
{
PreparedStatement
prep
=
conn
.
prepareStatement
(
"CREATE TABLE BAD AS SELECT A"
);
try
{
prep
.
execute
();
error
(
"Unexpected success"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
try
{
prep
.
execute
();
error
(
"Unexpected success"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
@@ -174,9 +174,9 @@ public class TestPreparedStatement extends TestBase {
"SELECT * FROM (SELECT ? FROM DUAL)"
);
prep
.
setInt
(
1
,
1
);
prep
.
execute
();
error
(
"Must fail"
);
error
();
}
catch
(
SQLException
e
)
{
// expected
checkNotGeneralException
(
e
);
}
PreparedStatement
prep
=
conn
.
prepareStatement
(
"SELECT -?"
);
prep
.
setInt
(
1
,
1
);
...
...
@@ -342,22 +342,22 @@ public class TestPreparedStatement extends TestBase {
check
(
pm
.
isSigned
(
1
),
true
);
try
{
pm
.
getPrecision
(
0
);
error
(
"should fail"
);
error
();
}
catch
(
SQLException
e
)
{
// ok
checkNotGeneralException
(
e
);
}
try
{
pm
.
getPrecision
(
4
);
error
(
"should fail"
);
error
();
}
catch
(
SQLException
e
)
{
// ok
checkNotGeneralException
(
e
);
}
prep
.
close
();
try
{
pm
.
getPrecision
(
1
);
error
(
"should fail"
);
error
();
}
catch
(
SQLException
e
)
{
// ok
checkNotGeneralException
(
e
);
}
}
...
...
@@ -439,10 +439,9 @@ public class TestPreparedStatement extends TestBase {
checkFalse
(
rs
.
next
());
try
{
prep
=
conn
.
prepareStatement
(
"select ? from dual union select ? from dual"
);
error
(
"expected error"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
// ok
}
prep
=
conn
.
prepareStatement
(
"select cast(? as varchar) from dual union select ? from dual"
);
check
(
prep
.
getParameterMetaData
().
getParameterCount
(),
2
);
...
...
h2/src/test/org/h2/test/jdbc/TestStatement.java
浏览文件 @
18bb2a2e
...
...
@@ -56,7 +56,7 @@ public class TestStatement extends TestBase {
int
id1
=
savepoint1
.
getSavepointId
();
try
{
savepoint1
.
getSavepointName
();
error
(
"exception expected"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
@@ -68,7 +68,7 @@ public class TestStatement extends TestBase {
conn
.
releaseSavepoint
(
savepoint2a
);
try
{
savepoint2a
.
getSavepointId
();
error
(
"exception expected"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
@@ -80,7 +80,7 @@ public class TestStatement extends TestBase {
check
(
savepointTest
.
getSavepointName
(),
"Joe's"
);
try
{
savepointTest
.
getSavepointId
();
error
(
"exception expected"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
@@ -93,7 +93,7 @@ public class TestStatement extends TestBase {
checkFalse
(
rs
.
next
());
try
{
conn
.
rollback
(
savepoint2
);
error
(
"exception expected"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
h2/src/test/org/h2/test/jdbc/TestUpdatableResultSet.java
浏览文件 @
18bb2a2e
...
...
@@ -53,7 +53,7 @@ public class TestUpdatableResultSet extends TestBase {
try
{
rs
.
insertRow
();
error
(
"Unexpected success"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
h2/src/test/org/h2/test/jdbc/TestZloty.java
浏览文件 @
18bb2a2e
...
...
@@ -80,7 +80,7 @@ public class TestZloty extends TestBase {
try
{
prep
.
setBigDecimal
(
2
,
new
ZlotyBigDecimal
(
"11.0"
));
prep
.
execute
();
error
(
"unexpected success"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
@@ -96,7 +96,7 @@ public class TestZloty extends TestBase {
};
prep
.
setBigDecimal
(
2
,
value
);
prep
.
execute
();
error
(
"unexpected success"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
h2/src/test/org/h2/test/mvcc/TestMvcc1.java
浏览文件 @
18bb2a2e
...
...
@@ -38,7 +38,7 @@ public class TestMvcc1 extends TestBase {
check
(
"FALSE"
,
rs
.
getString
(
"VALUE"
));
try
{
stat
.
execute
(
"SET MVCC TRUE"
);
error
(
"Unexpected success"
);
error
();
}
catch
(
SQLException
e
)
{
check
(
ErrorCode
.
CANNOT_CHANGE_SETTING_WHEN_OPEN_1
,
e
.
getErrorCode
());
}
...
...
@@ -80,7 +80,7 @@ public class TestMvcc1 extends TestBase {
s1
.
execute
(
"insert into test values(1)"
);
try
{
s2
.
execute
(
"drop table test"
);
error
(
"Unexpected success"
);
error
();
}
catch
(
SQLException
e
)
{
// lock timeout expected
checkNotGeneralException
(
e
);
...
...
@@ -107,7 +107,7 @@ public class TestMvcc1 extends TestBase {
s1
.
execute
(
"insert into a(code) values('one')"
);
try
{
s2
.
execute
(
"insert into b values('un B', 1)"
);
error
(
"Unexpected success"
);
error
(
);
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
@@ -123,7 +123,7 @@ public class TestMvcc1 extends TestBase {
s2
.
execute
(
"select * from test for update"
);
try
{
s1
.
execute
(
"insert into test values(2, 'x')"
);
error
(
"Unexpected success"
);
error
();
}
catch
(
SQLException
e
)
{
// lock timeout expected
checkNotGeneralException
(
e
);
...
...
@@ -346,7 +346,7 @@ public class TestMvcc1 extends TestBase {
c1
.
commit
();
try
{
s1
.
execute
(
"update test set id=2 where id=1"
);
error
(
"unexpected success"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
h2/src/test/org/h2/test/server/TestPgServer.java
浏览文件 @
18bb2a2e
...
...
@@ -40,9 +40,9 @@ public class TestPgServer extends TestBase {
Statement
stat
=
conn
.
createStatement
();
try
{
stat
.
execute
(
"select ***"
);
error
(
"expected failure"
);
error
();
}
catch
(
SQLException
e
)
{
// expected
checkNotGeneralException
(
e
);
}
conn
.
close
();
conn
=
DriverManager
.
getConnection
(
"jdbc:postgresql://localhost:5535/test"
,
"sa"
,
"sa"
);
...
...
h2/src/test/org/h2/test/synth/TestRandomSQL.java
浏览文件 @
18bb2a2e
...
...
@@ -29,6 +29,7 @@ public class TestRandomSQL extends TestBase {
private
int
seed
;
private
boolean
exitOnError
=
true
;
private
Bnf
bnf
;
private
int
success
,
total
;
private
void
processException
(
String
sql
,
SQLException
e
)
{
if
(
e
.
getSQLState
().
equals
(
"HY000"
))
{
...
...
@@ -100,7 +101,7 @@ public class TestRandomSQL extends TestBase {
if
(
topic
.
equals
(
"select"
))
{
weight
=
10
;
}
else
if
(
topic
.
equals
(
"createtable"
))
{
weight
=
5
;
weight
=
20
;
}
else
if
(
topic
.
equals
(
"insert"
))
{
weight
=
5
;
}
else
if
(
topic
.
startsWith
(
"update"
))
{
...
...
@@ -130,11 +131,10 @@ public class TestRandomSQL extends TestBase {
conn
=
connect
();
}
Statement
stat
=
conn
.
createStatement
();
for
(
int
i
=
0
;
i
<
statements
.
size
();
i
++)
{
int
sid
=
config
.
getRandom
().
nextInt
(
statements
.
size
());
RuleHead
r
=
(
RuleHead
)
statements
.
get
(
sid
);
String
rand
=
r
.
getRule
().
random
(
config
,
0
);
String
rand
=
r
.
getRule
().
random
(
config
,
0
)
.
trim
()
;
if
(
rand
.
length
()
>
0
)
{
try
{
Thread
.
yield
();
...
...
@@ -144,7 +144,12 @@ public class TestRandomSQL extends TestBase {
if
(
showSQL
)
{
System
.
out
.
println
(
i
+
" "
+
rand
);
}
total
++;
if
(
total
%
100
==
0
)
{
printTime
(
"total: "
+
total
+
" success: "
+
(
100
*
success
/
total
)
+
"%"
);
}
stat
.
execute
(
rand
);
success
++;
}
}
catch
(
SQLException
e
)
{
processException
(
rand
,
e
);
...
...
h2/src/test/org/h2/test/unit/TestFileSystem.java
浏览文件 @
18bb2a2e
...
...
@@ -165,7 +165,7 @@ public class TestFileSystem extends TestBase {
FileObject
f
=
fs
.
openFileObject
(
s
,
"rw"
);
try
{
f
.
readFully
(
new
byte
[
1
],
0
,
1
);
error
(
"Unexpected success"
);
error
();
}
catch
(
EOFException
e
)
{
// expected
}
...
...
h2/src/test/org/h2/test/unit/TestOverflow.java
浏览文件 @
18bb2a2e
...
...
@@ -69,13 +69,13 @@ public class TestOverflow extends TestBase {
void
onSuccess
()
throws
Exception
{
if
(!
successExpected
&&
SysProperties
.
OVERFLOW_EXCEPTIONS
)
{
error
(
"unexpected success"
);
error
();
}
}
void
onError
()
throws
Exception
{
if
(
successExpected
)
{
error
(
"unexpected error"
);
error
();
}
}
...
...
h2/src/test/org/h2/test/unit/TestServlet.java
浏览文件 @
18bb2a2e
...
...
@@ -170,7 +170,7 @@ public class TestServlet extends TestBase {
try
{
stat1
.
execute
(
"SELECT * FROM T"
);
error
(
"Unexpected success"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
@@ -182,7 +182,7 @@ public class TestServlet extends TestBase {
// listener must be stopped
try
{
conn2
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:8888/"
+
baseDir
+
"/servlet"
,
getUser
(),
getPassword
());
error
(
"Unexpected success"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
@@ -190,7 +190,7 @@ public class TestServlet extends TestBase {
// connection must be closed
try
{
stat1
.
execute
(
"SELECT * FROM DUAL"
);
error
(
"Unexpected success"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
h2/src/test/org/h2/test/unit/TestStringUtils.java
浏览文件 @
18bb2a2e
...
...
@@ -35,13 +35,13 @@ public class TestStringUtils extends TestBase {
check
(
new
byte
[]
{
(
byte
)
0xfa
,
(
byte
)
0xce
},
ByteUtils
.
convertStringToBytes
(
"FaCe"
));
try
{
ByteUtils
.
convertStringToBytes
(
"120"
);
error
(
"unexpected success"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
try
{
ByteUtils
.
convertStringToBytes
(
"fast"
);
error
(
"unexpected success"
);
error
();
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论