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 {
...
@@ -922,8 +922,9 @@ public class Select extends Query {
// another order
// another order
sortUsingIndex
=
true
;
sortUsingIndex
=
true
;
}
}
}
else
if
(
index
.
getIndexColumns
().
length
>=
}
else
if
(
index
.
getIndexColumns
()
!=
null
current
.
getIndexColumns
().
length
)
{
&&
index
.
getIndexColumns
().
length
>=
current
.
getIndexColumns
().
length
)
{
IndexColumn
[]
sortColumns
=
index
.
getIndexColumns
();
IndexColumn
[]
sortColumns
=
index
.
getIndexColumns
();
IndexColumn
[]
currentColumns
=
current
.
getIndexColumns
();
IndexColumn
[]
currentColumns
=
current
.
getIndexColumns
();
boolean
swapIndex
=
false
;
boolean
swapIndex
=
false
;
...
...
h2/src/main/org/h2/engine/Session.java
浏览文件 @
2bdc3556
...
@@ -938,13 +938,12 @@ public class Session extends SessionWithState {
...
@@ -938,13 +938,12 @@ public class Session extends SessionWithState {
private
void
cleanTempTables
(
boolean
closeSession
)
{
private
void
cleanTempTables
(
boolean
closeSession
)
{
if
(
localTempTables
!=
null
&&
localTempTables
.
size
()
>
0
)
{
if
(
localTempTables
!=
null
&&
localTempTables
.
size
()
>
0
)
{
synchronized
(
database
)
{
synchronized
(
database
)
{
Iterator
<
Table
>
it
=
localTempTables
.
values
().
iterator
()
;
HashMap
<
String
,
Table
>
tempTables
=
localTempTables
;
while
(
it
.
hasNext
())
{
localTempTables
=
null
;
Table
table
=
it
.
next
();
for
(
Table
table
:
tempTables
.
values
())
{
if
(
closeSession
||
table
.
getOnCommitDrop
())
{
if
(
closeSession
||
table
.
getOnCommitDrop
())
{
modificationId
++;
modificationId
++;
table
.
setModified
();
table
.
setModified
();
it
.
remove
();
table
.
removeChildrenAndResources
(
this
);
table
.
removeChildrenAndResources
(
this
);
if
(
closeSession
)
{
if
(
closeSession
)
{
// need to commit, otherwise recovery might
// 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;
...
@@ -8,10 +8,8 @@ package org.h2.test.synth;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Statement
;
import
org.h2.engine.SysProperties
;
import
org.h2.engine.SysProperties
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.test.TestAll
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.util.MathUtils
;
import
org.h2.util.MathUtils
;
...
@@ -20,8 +18,6 @@ import org.h2.util.MathUtils;
...
@@ -20,8 +18,6 @@ import org.h2.util.MathUtils;
*/
*/
public
class
TestRandomSQL
extends
TestBase
{
public
class
TestRandomSQL
extends
TestBase
{
private
int
seed
;
private
boolean
exitOnError
=
true
;
private
int
success
,
total
;
private
int
success
,
total
;
/**
/**
...
@@ -33,41 +29,28 @@ public class TestRandomSQL extends TestBase {
...
@@ -33,41 +29,28 @@ public class TestRandomSQL extends TestBase {
TestBase
.
createCaller
().
init
().
test
();
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
());
}
private
void
deleteDb
()
{
FileUtils
.
delete
(
getDatabaseName
());
}
@Override
@Override
public
TestBase
init
(
TestAll
conf
)
throws
Exception
{
public
void
test
()
throws
Exception
{
super
.
init
(
conf
);
if
(
config
.
networked
)
{
return
this
;
return
;
}
int
len
=
getSize
(
2
,
6
);
for
(
int
a
=
0
;
a
<
len
;
a
++)
{
int
s
=
MathUtils
.
randomInt
(
Integer
.
MAX_VALUE
);
testCase
(
s
);
}
}
}
private
void
testWithSeed
()
throws
Exception
{
private
void
testWithSeed
(
int
seed
)
throws
Exception
{
Connection
conn
=
null
;
Connection
conn
=
null
;
try
{
try
{
conn
=
connect
(
);
conn
=
getConnection
(
getDatabaseName
(
seed
)
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
processException
(
"connect"
,
e
);
if
(
e
.
getSQLState
().
equals
(
"HY000"
))
{
conn
=
connect
();
TestBase
.
logError
(
"new TestRandomSQL().init(test).testCase("
+
seed
+
"); "
+
"// FAIL: "
+
e
.
toString
()
+
" sql: "
+
"connect"
,
e
);
}
conn
=
getConnection
(
getDatabaseName
(
seed
));
}
}
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
...
@@ -86,47 +69,47 @@ public class TestRandomSQL extends TestBase {
...
@@ -86,47 +69,47 @@ public class TestRandomSQL extends TestBase {
stat
.
execute
(
sql
);
stat
.
execute
(
sql
);
success
++;
success
++;
}
catch
(
SQLException
e
)
{
}
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
{
try
{
conn
.
close
();
conn
.
close
();
conn
=
connect
(
);
conn
=
getConnection
(
getDatabaseName
(
seed
)
);
conn
.
createStatement
().
execute
(
"shutdown immediately"
);
conn
.
createStatement
().
execute
(
"shutdown immediately"
);
conn
.
close
();
conn
.
close
();
}
catch
(
SQLException
e
)
{
}
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
@Override
public
void
testCase
(
int
i
)
throws
Exception
{
public
void
testCase
(
int
seed
)
throws
Exception
{
String
old
=
SysProperties
.
getScriptDirectory
();
String
old
=
SysProperties
.
getScriptDirectory
();
try
{
try
{
System
.
setProperty
(
SysProperties
.
H2_SCRIPT_DIRECTORY
,
System
.
setProperty
(
SysProperties
.
H2_SCRIPT_DIRECTORY
,
getBaseDir
()
+
"/"
+
getTestName
());
getBaseDir
()
+
"/"
+
getTestName
());
seed
=
i
;
printTime
(
"seed: "
+
seed
);
printTime
(
"seed: "
+
seed
);
deleteDb
();
deleteDb
(
seed
);
testWithSeed
();
testWithSeed
(
seed
);
}
finally
{
}
finally
{
System
.
setProperty
(
SysProperties
.
H2_SCRIPT_DIRECTORY
,
old
);
System
.
setProperty
(
SysProperties
.
H2_SCRIPT_DIRECTORY
,
old
);
}
}
deleteDb
();
deleteDb
(
seed
);
}
}
@Override
private
String
getDatabaseName
(
int
seed
)
{
public
void
test
()
throws
Exception
{
return
getTestName
()
+
"/db"
+
seed
;
if
(
config
.
networked
)
{
}
return
;
}
private
void
deleteDb
(
int
seed
)
{
int
len
=
getSize
(
2
,
6
);
FileUtils
.
delete
(
getDatabaseName
(
seed
));
exitOnError
=
false
;
for
(
int
a
=
0
;
a
<
len
;
a
++)
{
int
s
=
MathUtils
.
randomInt
(
Integer
.
MAX_VALUE
);
testCase
(
s
);
}
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论