Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
6ac4d3c8
提交
6ac4d3c8
authored
2月 10, 2018
作者:
andrei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
IndexCursor inList
上级
e0619d3a
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
25 行增加
和
21 行删除
+25
-21
IndexCursor.java
h2/src/main/org/h2/index/IndexCursor.java
+3
-4
TestFuzzOptimizations.java
h2/src/test/org/h2/test/synth/TestFuzzOptimizations.java
+22
-17
没有找到文件。
h2/src/main/org/h2/index/IndexCursor.java
浏览文件 @
6ac4d3c8
...
@@ -148,6 +148,9 @@ public class IndexCursor implements Cursor {
...
@@ -148,6 +148,9 @@ public class IndexCursor implements Cursor {
}
}
}
}
}
}
if
(
inColumn
!=
null
)
{
start
=
table
.
getTemplateRow
();
}
}
}
/**
/**
...
@@ -326,7 +329,6 @@ public class IndexCursor implements Cursor {
...
@@ -326,7 +329,6 @@ public class IndexCursor implements Cursor {
while
(
inResult
.
next
())
{
while
(
inResult
.
next
())
{
Value
v
=
inResult
.
currentRow
()[
0
];
Value
v
=
inResult
.
currentRow
()[
0
];
if
(
v
!=
ValueNull
.
INSTANCE
)
{
if
(
v
!=
ValueNull
.
INSTANCE
)
{
v
=
inColumn
.
convert
(
v
);
if
(
inResultTested
==
null
)
{
if
(
inResultTested
==
null
)
{
inResultTested
=
new
HashSet
<>();
inResultTested
=
new
HashSet
<>();
}
}
...
@@ -342,9 +344,6 @@ public class IndexCursor implements Cursor {
...
@@ -342,9 +344,6 @@ public class IndexCursor implements Cursor {
private
void
find
(
Value
v
)
{
private
void
find
(
Value
v
)
{
v
=
inColumn
.
convert
(
v
);
v
=
inColumn
.
convert
(
v
);
int
id
=
inColumn
.
getColumnId
();
int
id
=
inColumn
.
getColumnId
();
if
(
start
==
null
)
{
start
=
table
.
getTemplateRow
();
}
start
.
setValue
(
id
,
v
);
start
.
setValue
(
id
,
v
);
cursor
=
index
.
find
(
tableFilter
,
start
,
start
);
cursor
=
index
.
find
(
tableFilter
,
start
,
start
);
}
}
...
...
h2/src/test/org/h2/test/synth/TestFuzzOptimizations.java
浏览文件 @
6ac4d3c8
...
@@ -10,6 +10,7 @@ import java.sql.PreparedStatement;
...
@@ -10,6 +10,7 @@ import java.sql.PreparedStatement;
import
java.sql.ResultSet
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Random
;
import
java.util.Random
;
...
@@ -107,33 +108,37 @@ public class TestFuzzOptimizations extends TestBase {
...
@@ -107,33 +108,37 @@ public class TestFuzzOptimizations extends TestBase {
ArrayList
<
String
>
params
=
New
.
arrayList
();
ArrayList
<
String
>
params
=
New
.
arrayList
();
String
condition
=
getRandomCondition
(
random
,
params
,
columns
,
String
condition
=
getRandomCondition
(
random
,
params
,
columns
,
compares
,
values
);
compares
,
values
);
// System.out.println(condition + " " + params);
String
message
=
"seed: "
+
seed
+
" "
+
condition
;
PreparedStatement
prep0
=
conn
.
prepareStatement
(
executeAndCompare
(
condition
,
params
,
message
);
"select * from test0 where "
+
condition
+
" order by 1, 2, 3"
);
PreparedStatement
prep1
=
conn
.
prepareStatement
(
"select * from test1 where "
+
condition
+
" order by 1, 2, 3"
);
for
(
int
j
=
0
;
j
<
params
.
size
();
j
++)
{
prep0
.
setString
(
j
+
1
,
params
.
get
(
j
));
prep1
.
setString
(
j
+
1
,
params
.
get
(
j
));
}
ResultSet
rs0
=
prep0
.
executeQuery
();
ResultSet
rs1
=
prep1
.
executeQuery
();
assertEquals
(
"seed: "
+
seed
+
" "
+
condition
,
rs0
,
rs1
);
if
(
params
.
size
()
>
0
)
{
if
(
params
.
size
()
>
0
)
{
for
(
int
j
=
0
;
j
<
params
.
size
();
j
++)
{
for
(
int
j
=
0
;
j
<
params
.
size
();
j
++)
{
String
value
=
values
[
random
.
nextInt
(
values
.
length
-
2
)];
String
value
=
values
[
random
.
nextInt
(
values
.
length
-
2
)];
params
.
set
(
j
,
value
);
params
.
set
(
j
,
value
);
prep0
.
setString
(
j
+
1
,
value
);
prep1
.
setString
(
j
+
1
,
value
);
}
}
assertEquals
(
"seed: "
+
seed
+
" "
+
condition
,
rs0
,
rs1
);
executeAndCompare
(
condition
,
params
,
message
);
}
}
}
}
executeAndCompare
(
"a >=0 and b in(?, 2) and a in(1, ?, null)"
,
Arrays
.
asList
(
"10"
,
"2"
),
"seed=-6191135606105920350L"
);
db
.
execute
(
"drop table test0, test1"
);
db
.
execute
(
"drop table test0, test1"
);
}
}
private
void
executeAndCompare
(
String
condition
,
List
<
String
>
params
,
String
message
)
throws
SQLException
{
PreparedStatement
prep0
=
conn
.
prepareStatement
(
"select * from test0 where "
+
condition
+
" order by 1, 2, 3"
);
PreparedStatement
prep1
=
conn
.
prepareStatement
(
"select * from test1 where "
+
condition
+
" order by 1, 2, 3"
);
for
(
int
j
=
0
;
j
<
params
.
size
();
j
++)
{
prep0
.
setString
(
j
+
1
,
params
.
get
(
j
));
prep1
.
setString
(
j
+
1
,
params
.
get
(
j
));
}
ResultSet
rs0
=
prep0
.
executeQuery
();
ResultSet
rs1
=
prep1
.
executeQuery
();
assertEquals
(
message
,
rs0
,
rs1
);
}
private
String
getRandomCondition
(
Random
random
,
ArrayList
<
String
>
params
,
private
String
getRandomCondition
(
Random
random
,
ArrayList
<
String
>
params
,
String
[]
columns
,
String
[]
compares
,
String
[]
values
)
{
String
[]
columns
,
String
[]
compares
,
String
[]
values
)
{
int
comp
=
1
+
random
.
nextInt
(
4
);
int
comp
=
1
+
random
.
nextInt
(
4
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论