Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
2bdc3556
提交
2bdc3556
authored
11月 11, 2016
作者:
Noel Grandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix some TestRandomSQL bugs
found by running TestRandomSQL for long periods of time
上级
a21876c1
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
41 行增加
和
58 行删除
+41
-58
Select.java
h2/src/main/org/h2/command/dml/Select.java
+3
-2
Session.java
h2/src/main/org/h2/engine/Session.java
+3
-4
TestRandomSQL.java
h2/src/test/org/h2/test/synth/TestRandomSQL.java
+35
-52
没有找到文件。
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
2bdc3556
...
...
@@ -922,8 +922,9 @@ public class Select extends Query {
// another order
sortUsingIndex
=
true
;
}
}
else
if
(
index
.
getIndexColumns
().
length
>=
current
.
getIndexColumns
().
length
)
{
}
else
if
(
index
.
getIndexColumns
()
!=
null
&&
index
.
getIndexColumns
().
length
>=
current
.
getIndexColumns
().
length
)
{
IndexColumn
[]
sortColumns
=
index
.
getIndexColumns
();
IndexColumn
[]
currentColumns
=
current
.
getIndexColumns
();
boolean
swapIndex
=
false
;
...
...
h2/src/main/org/h2/engine/Session.java
浏览文件 @
2bdc3556
...
...
@@ -938,13 +938,12 @@ public class Session extends SessionWithState {
private
void
cleanTempTables
(
boolean
closeSession
)
{
if
(
localTempTables
!=
null
&&
localTempTables
.
size
()
>
0
)
{
synchronized
(
database
)
{
Iterator
<
Table
>
it
=
localTempTables
.
values
().
iterator
()
;
while
(
it
.
hasNext
())
{
Table
table
=
it
.
next
();
HashMap
<
String
,
Table
>
tempTables
=
localTempTables
;
localTempTables
=
null
;
for
(
Table
table
:
tempTables
.
values
())
{
if
(
closeSession
||
table
.
getOnCommitDrop
())
{
modificationId
++;
table
.
setModified
();
it
.
remove
();
table
.
removeChildrenAndResources
(
this
);
if
(
closeSession
)
{
// need to commit, otherwise recovery might
...
...
h2/src/test/org/h2/test/synth/TestRandomSQL.java
浏览文件 @
2bdc3556
...
...
@@ -8,10 +8,8 @@ package org.h2.test.synth;
import
java.sql.Connection
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
org.h2.engine.SysProperties
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.test.TestAll
;
import
org.h2.test.TestBase
;
import
org.h2.util.MathUtils
;
...
...
@@ -20,8 +18,6 @@ import org.h2.util.MathUtils;
*/
public
class
TestRandomSQL
extends
TestBase
{
private
int
seed
;
private
boolean
exitOnError
=
true
;
private
int
success
,
total
;
/**
...
...
@@ -33,41 +29,28 @@ public class TestRandomSQL extends TestBase {
TestBase
.
createCaller
().
init
().
test
();
}
private
void
processException
(
String
sql
,
SQLException
e
)
{
if
(
e
.
getSQLState
().
equals
(
"HY000"
))
{
TestBase
.
logError
(
"new TestRandomSQL().init(test).testCase("
+
seed
+
"); "
+
"// FAIL: "
+
e
.
toString
()
+
" sql: "
+
sql
,
e
);
if
(
exitOnError
)
{
System
.
exit
(
0
);
}
}
}
protected
String
getDatabaseName
()
{
return
getTestName
()
+
"/db"
+
seed
;
}
private
Connection
connect
()
throws
SQLException
{
return
getConnection
(
getDatabaseName
());
@Override
public
void
test
()
throws
Exception
{
if
(
config
.
networked
)
{
return
;
}
private
void
deleteDb
()
{
FileUtils
.
delete
(
getDatabaseName
());
int
len
=
getSize
(
2
,
6
);
for
(
int
a
=
0
;
a
<
len
;
a
++)
{
int
s
=
MathUtils
.
randomInt
(
Integer
.
MAX_VALUE
);
testCase
(
s
);
}
@Override
public
TestBase
init
(
TestAll
conf
)
throws
Exception
{
super
.
init
(
conf
);
return
this
;
}
private
void
testWithSeed
()
throws
Exception
{
private
void
testWithSeed
(
int
seed
)
throws
Exception
{
Connection
conn
=
null
;
try
{
conn
=
connect
(
);
conn
=
getConnection
(
getDatabaseName
(
seed
)
);
}
catch
(
SQLException
e
)
{
processException
(
"connect"
,
e
);
conn
=
connect
();
if
(
e
.
getSQLState
().
equals
(
"HY000"
))
{
TestBase
.
logError
(
"new TestRandomSQL().init(test).testCase("
+
seed
+
"); "
+
"// FAIL: "
+
e
.
toString
()
+
" sql: "
+
"connect"
,
e
);
}
conn
=
getConnection
(
getDatabaseName
(
seed
));
}
Statement
stat
=
conn
.
createStatement
();
...
...
@@ -86,47 +69,47 @@ public class TestRandomSQL extends TestBase {
stat
.
execute
(
sql
);
success
++;
}
catch
(
SQLException
e
)
{
processException
(
sql
,
e
);
if
(
e
.
getSQLState
().
equals
(
"HY000"
))
{
TestBase
.
logError
(
"new TestRandomSQL().init(test).testCase("
+
seed
+
"); "
+
"// FAIL: "
+
e
.
toString
()
+
" sql: "
+
sql
,
e
);
}
}
}
}
try
{
conn
.
close
();
conn
=
connect
(
);
conn
=
getConnection
(
getDatabaseName
(
seed
)
);
conn
.
createStatement
().
execute
(
"shutdown immediately"
);
conn
.
close
();
}
catch
(
SQLException
e
)
{
processException
(
"conn.close"
,
e
);
if
(
e
.
getSQLState
().
equals
(
"HY000"
))
{
TestBase
.
logError
(
"new TestRandomSQL().init(test).testCase("
+
seed
+
"); "
+
"// FAIL: "
+
e
.
toString
()
+
" sql: "
+
"conn.close"
,
e
);
}
}
}
@Override
public
void
testCase
(
int
i
)
throws
Exception
{
public
void
testCase
(
int
seed
)
throws
Exception
{
String
old
=
SysProperties
.
getScriptDirectory
();
try
{
System
.
setProperty
(
SysProperties
.
H2_SCRIPT_DIRECTORY
,
getBaseDir
()
+
"/"
+
getTestName
());
seed
=
i
;
printTime
(
"seed: "
+
seed
);
deleteDb
();
testWithSeed
();
deleteDb
(
seed
);
testWithSeed
(
seed
);
}
finally
{
System
.
setProperty
(
SysProperties
.
H2_SCRIPT_DIRECTORY
,
old
);
}
deleteDb
();
deleteDb
(
seed
);
}
@Override
public
void
test
()
throws
Exception
{
if
(
config
.
networked
)
{
return
;
}
int
len
=
getSize
(
2
,
6
);
exitOnError
=
false
;
for
(
int
a
=
0
;
a
<
len
;
a
++)
{
int
s
=
MathUtils
.
randomInt
(
Integer
.
MAX_VALUE
);
testCase
(
s
);
private
String
getDatabaseName
(
int
seed
)
{
return
getTestName
()
+
"/db"
+
seed
;
}
private
void
deleteDb
(
int
seed
)
{
FileUtils
.
delete
(
getDatabaseName
(
seed
));
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论