Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
db7af664
提交
db7af664
authored
2月 12, 2019
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Do not concatenate strings with builders in TestOptimizerHints
上级
0a6aa17d
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
15 行增加
和
14 行删除
+15
-14
TestOptimizerHints.java
h2/src/test/org/h2/test/db/TestOptimizerHints.java
+15
-14
没有找到文件。
h2/src/test/org/h2/test/db/TestOptimizerHints.java
浏览文件 @
db7af664
...
@@ -12,7 +12,6 @@ import java.sql.Statement;
...
@@ -12,7 +12,6 @@ import java.sql.Statement;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestDb
;
import
org.h2.test.TestDb
;
import
org.h2.util.StatementBuilder
;
/**
/**
* Test for optimizer hint SET FORCE_JOIN_ORDER.
* Test for optimizer hint SET FORCE_JOIN_ORDER.
...
@@ -111,13 +110,15 @@ public class TestOptimizerHints extends TestDb {
...
@@ -111,13 +110,15 @@ public class TestOptimizerHints extends TestDb {
}
}
private
void
checkPlanComma
(
Statement
s
,
String
...
t
)
throws
SQLException
{
private
void
checkPlanComma
(
Statement
s
,
String
...
t
)
throws
SQLException
{
St
atementBuilder
from
=
new
StatementBuilder
(
);
St
ringBuilder
builder
=
new
StringBuilder
(
"select 1 from "
);
for
(
String
table
:
t
)
{
for
(
int
i
=
0
,
l
=
t
.
length
;
i
<
l
;
i
++
)
{
from
.
appendExceptFirst
(
", "
);
if
(
i
>
0
)
{
from
.
append
(
table
);
builder
.
append
(
", "
);
}
}
String
plan
=
plan
(
s
,
"select 1 from "
+
from
.
toString
()
+
" where t1.id = t2.t1_id "
builder
.
append
(
t
[
i
]);
+
"and t2.id = t4.t2_id and t3.id = t4.t3_id"
);
}
builder
.
append
(
" where t1.id = t2.t1_id and t2.id = t4.t2_id and t3.id = t4.t3_id"
);
String
plan
=
plan
(
s
,
builder
.
toString
());
int
prev
=
plan
.
indexOf
(
"FROM PUBLIC."
+
t
[
0
].
toUpperCase
());
int
prev
=
plan
.
indexOf
(
"FROM PUBLIC."
+
t
[
0
].
toUpperCase
());
for
(
int
i
=
1
;
i
<
t
.
length
;
i
++)
{
for
(
int
i
=
1
;
i
<
t
.
length
;
i
++)
{
int
next
=
plan
.
indexOf
(
"INNER JOIN PUBLIC."
+
t
[
i
].
toUpperCase
());
int
next
=
plan
.
indexOf
(
"INNER JOIN PUBLIC."
+
t
[
i
].
toUpperCase
());
...
@@ -128,22 +129,22 @@ public class TestOptimizerHints extends TestDb {
...
@@ -128,22 +129,22 @@ public class TestOptimizerHints extends TestDb {
private
void
checkPlanJoin
(
Statement
s
,
boolean
on
,
boolean
left
,
private
void
checkPlanJoin
(
Statement
s
,
boolean
on
,
boolean
left
,
String
...
t
)
throws
SQLException
{
String
...
t
)
throws
SQLException
{
St
atementBuilder
from
=
new
StatementBuilder
(
);
St
ringBuilder
builder
=
new
StringBuilder
(
"select 1 from "
);
for
(
int
i
=
0
;
i
<
t
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
t
.
length
;
i
++)
{
if
(
i
!=
0
)
{
if
(
i
!=
0
)
{
if
(
left
)
{
if
(
left
)
{
from
.
append
(
" left join "
);
builder
.
append
(
" left join "
);
}
else
{
}
else
{
from
.
append
(
" inner join "
);
builder
.
append
(
" inner join "
);
}
}
}
}
from
.
append
(
t
[
i
]);
builder
.
append
(
t
[
i
]);
if
(
on
&&
i
!=
0
)
{
if
(
on
&&
i
!=
0
)
{
from
.
append
(
" on 1=1 "
);
builder
.
append
(
" on 1=1 "
);
}
}
}
}
String
plan
=
plan
(
s
,
"select 1 from "
+
from
.
toString
()
+
" where t1.id = t2.t1_id "
builder
.
append
(
" where t1.id = t2.t1_id and t2.id = t4.t2_id and t3.id = t4.t3_id"
);
+
"and t2.id = t4.t2_id and t3.id = t4.t3_id"
);
String
plan
=
plan
(
s
,
builder
.
toString
()
);
int
prev
=
plan
.
indexOf
(
"FROM PUBLIC."
+
t
[
0
].
toUpperCase
());
int
prev
=
plan
.
indexOf
(
"FROM PUBLIC."
+
t
[
0
].
toUpperCase
());
for
(
int
i
=
1
;
i
<
t
.
length
;
i
++)
{
for
(
int
i
=
1
;
i
<
t
.
length
;
i
++)
{
int
next
=
plan
.
indexOf
(
int
next
=
plan
.
indexOf
(
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论