Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
ace8433a
提交
ace8433a
authored
11月 07, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Pass StringBuilder to TableFilter.getPlanSQL()
上级
e619227f
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
49 行增加
和
49 行删除
+49
-49
Delete.java
h2/src/main/org/h2/command/dml/Delete.java
+2
-2
Select.java
h2/src/main/org/h2/command/dml/Select.java
+2
-2
Update.java
h2/src/main/org/h2/command/dml/Update.java
+14
-13
Aggregate.java
h2/src/main/org/h2/expression/aggregate/Aggregate.java
+0
-1
TableFilter.java
h2/src/main/org/h2/table/TableFilter.java
+31
-31
没有找到文件。
h2/src/main/org/h2/command/dml/Delete.java
浏览文件 @
ace8433a
...
...
@@ -136,8 +136,8 @@ public class Delete extends Prepared {
@Override
public
String
getPlanSQL
()
{
StringBuilder
buff
=
new
StringBuilder
();
buff
.
append
(
"DELETE "
);
buff
.
append
(
"FROM "
).
append
(
targetTableFilter
.
getPlanSQL
(
false
)
);
buff
.
append
(
"DELETE
FROM
"
);
targetTableFilter
.
getPlanSQL
(
buff
,
false
);
if
(
condition
!=
null
)
{
buff
.
append
(
"\nWHERE "
);
condition
.
getUnenclosedSQL
(
buff
);
...
...
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
ace8433a
...
...
@@ -1345,7 +1345,7 @@ public class Select extends Query {
int
i
=
0
;
do
{
buff
.
appendExceptFirst
(
"\n"
);
buff
.
append
(
filter
.
getPlanSQL
(
i
++
>
0
)
);
filter
.
getPlanSQL
(
buff
.
builder
(),
i
++
>
0
);
filter
=
filter
.
getJoin
();
}
while
(
filter
!=
null
);
}
else
{
...
...
@@ -1354,7 +1354,7 @@ public class Select extends Query {
for
(
TableFilter
f
:
topFilters
)
{
do
{
buff
.
appendExceptFirst
(
"\n"
);
buff
.
append
(
f
.
getPlanSQL
(
i
++
>
0
)
);
f
.
getPlanSQL
(
buff
.
builder
(),
i
++
>
0
);
f
=
f
.
getJoin
();
}
while
(
f
!=
null
);
}
...
...
h2/src/main/org/h2/command/dml/Update.java
浏览文件 @
ace8433a
...
...
@@ -27,7 +27,6 @@ import org.h2.table.Column;
import
org.h2.table.PlanItem
;
import
org.h2.table.Table
;
import
org.h2.table.TableFilter
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.Utils
;
import
org.h2.value.Value
;
import
org.h2.value.ValueNull
;
...
...
@@ -216,23 +215,25 @@ public class Update extends Prepared {
@Override
public
String
getPlanSQL
()
{
StatementBuilder
buff
=
new
StatementBuilder
(
"UPDATE "
);
buff
.
append
(
targetTableFilter
.
getPlanSQL
(
false
)).
append
(
"\nSET\n "
);
for
(
Column
c
:
columns
)
{
Expression
e
=
expressionMap
.
get
(
c
);
buff
.
appendExceptFirst
(
",\n "
);
buff
.
append
(
c
.
getName
()).
append
(
" = "
);
e
.
getSQL
(
buff
.
builder
());
StringBuilder
builder
=
new
StringBuilder
(
"UPDATE "
);
targetTableFilter
.
getPlanSQL
(
builder
,
false
).
append
(
"\nSET\n "
);
for
(
int
i
=
0
,
size
=
columns
.
size
();
i
<
size
;
i
++)
{
if
(
i
>
0
)
{
builder
.
append
(
",\n "
);
}
Column
c
=
columns
.
get
(
i
);
builder
.
append
(
c
.
getName
()).
append
(
" = "
);
expressionMap
.
get
(
c
).
getSQL
(
builder
);
}
if
(
condition
!=
null
)
{
bu
ff
.
append
(
"\nWHERE "
);
condition
.
getUnenclosedSQL
(
bu
ff
.
builder
()
);
bu
ilder
.
append
(
"\nWHERE "
);
condition
.
getUnenclosedSQL
(
bu
ilder
);
}
if
(
limitExpr
!=
null
)
{
bu
ff
.
append
(
"\nLIMIT "
);
limitExpr
.
getUnenclosedSQL
(
bu
ff
.
builder
()
);
bu
ilder
.
append
(
"\nLIMIT "
);
limitExpr
.
getUnenclosedSQL
(
bu
ilder
);
}
return
bu
ff
.
toString
();
return
bu
ilder
.
toString
();
}
@Override
...
...
h2/src/main/org/h2/expression/aggregate/Aggregate.java
浏览文件 @
ace8433a
...
...
@@ -30,7 +30,6 @@ import org.h2.table.ColumnResolver;
import
org.h2.table.Table
;
import
org.h2.table.TableFilter
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.StringUtils
;
import
org.h2.util.ValueHashMap
;
import
org.h2.value.CompareMode
;
import
org.h2.value.DataType
;
...
...
h2/src/main/org/h2/table/TableFilter.java
浏览文件 @
ace8433a
...
...
@@ -747,75 +747,75 @@ public class TableFilter implements ColumnResolver {
}
/**
* Get the query execution plan text to use for this table filter.
* Get the query execution plan text to use for this table filter and append
* it to the specified builder.
*
* @param builder string builder to append to
* @param isJoin if this is a joined table
* @return the
SQL statement snippet
* @return the
specified builder
*/
public
String
getPlanSQL
(
boolean
isJoin
)
{
StringBuilder
buff
=
new
StringBuilder
();
public
StringBuilder
getPlanSQL
(
StringBuilder
builder
,
boolean
isJoin
)
{
if
(
isJoin
)
{
if
(
joinOuter
)
{
bu
ff
.
append
(
"LEFT OUTER JOIN "
);
bu
ilder
.
append
(
"LEFT OUTER JOIN "
);
}
else
{
bu
ff
.
append
(
"INNER JOIN "
);
bu
ilder
.
append
(
"INNER JOIN "
);
}
}
if
(
nestedJoin
!=
null
)
{
StringBuilder
buffNested
=
new
StringBuilder
();
TableFilter
n
=
nestedJoin
;
do
{
buffNested
.
append
(
n
.
getPlanSQL
(
n
!=
nestedJoin
));
buffNested
.
append
(
'\n'
);
n
.
getPlanSQL
(
buffNested
,
n
!=
nestedJoin
).
append
(
'\n'
);
n
=
n
.
getJoin
();
}
while
(
n
!=
null
);
String
nested
=
buffNested
.
toString
();
boolean
enclose
=
!
nested
.
startsWith
(
"("
);
if
(
enclose
)
{
bu
ff
.
append
(
"(\n"
);
bu
ilder
.
append
(
"(\n"
);
}
StringUtils
.
indent
(
bu
ff
,
nested
,
4
,
false
);
StringUtils
.
indent
(
bu
ilder
,
nested
,
4
,
false
);
if
(
enclose
)
{
bu
ff
.
append
(
')'
);
bu
ilder
.
append
(
')'
);
}
if
(
isJoin
)
{
bu
ff
.
append
(
" ON "
);
bu
ilder
.
append
(
" ON "
);
if
(
joinCondition
==
null
)
{
// need to have a ON expression,
// otherwise the nesting is unclear
bu
ff
.
append
(
"1=1"
);
bu
ilder
.
append
(
"1=1"
);
}
else
{
joinCondition
.
getUnenclosedSQL
(
bu
ff
);
joinCondition
.
getUnenclosedSQL
(
bu
ilder
);
}
}
return
bu
ff
.
toString
()
;
return
bu
ilder
;
}
if
(
table
.
isView
()
&&
((
TableView
)
table
).
isRecursive
())
{
bu
ff
.
append
(
table
.
getSchema
().
getSQL
()).
append
(
'.'
).
append
(
Parser
.
quoteIdentifier
(
table
.
getName
()));
bu
ilder
.
append
(
table
.
getSchema
().
getSQL
()).
append
(
'.'
).
append
(
Parser
.
quoteIdentifier
(
table
.
getName
()));
}
else
{
bu
ff
.
append
(
table
.
getSQL
());
bu
ilder
.
append
(
table
.
getSQL
());
}
if
(
table
.
isView
()
&&
((
TableView
)
table
).
isInvalid
())
{
throw
DbException
.
get
(
ErrorCode
.
VIEW_IS_INVALID_2
,
table
.
getName
(),
"not compiled"
);
}
if
(
alias
!=
null
)
{
bu
ff
.
append
(
' '
).
append
(
Parser
.
quoteIdentifier
(
alias
));
bu
ilder
.
append
(
' '
).
append
(
Parser
.
quoteIdentifier
(
alias
));
}
if
(
indexHints
!=
null
)
{
bu
ff
.
append
(
" USE INDEX ("
);
bu
ilder
.
append
(
" USE INDEX ("
);
boolean
first
=
true
;
for
(
String
index
:
indexHints
.
getAllowedIndexes
())
{
if
(!
first
)
{
bu
ff
.
append
(
", "
);
bu
ilder
.
append
(
", "
);
}
else
{
first
=
false
;
}
bu
ff
.
append
(
Parser
.
quoteIdentifier
(
index
));
bu
ilder
.
append
(
Parser
.
quoteIdentifier
(
index
));
}
bu
ff
.
append
(
")"
);
bu
ilder
.
append
(
")"
);
}
if
(
index
!=
null
)
{
bu
ff
.
append
(
'\n'
);
bu
ilder
.
append
(
'\n'
);
StatementBuilder
planBuff
=
new
StatementBuilder
();
if
(
joinBatch
!=
null
)
{
IndexLookupBatch
lookupBatch
=
joinBatch
.
getLookupBatch
(
joinFilterId
);
...
...
@@ -842,28 +842,28 @@ public class TableFilter implements ColumnResolver {
if
(
plan
.
indexOf
(
'\n'
)
>=
0
)
{
plan
+=
"\n"
;
}
StringUtils
.
indent
(
bu
ff
,
"/* "
+
plan
+
" */"
,
4
,
false
);
StringUtils
.
indent
(
bu
ilder
,
"/* "
+
plan
+
" */"
,
4
,
false
);
}
if
(
isJoin
)
{
bu
ff
.
append
(
"\n ON "
);
bu
ilder
.
append
(
"\n ON "
);
if
(
joinCondition
==
null
)
{
// need to have a ON expression, otherwise the nesting is
// unclear
bu
ff
.
append
(
"1=1"
);
bu
ilder
.
append
(
"1=1"
);
}
else
{
joinCondition
.
getUnenclosedSQL
(
bu
ff
);
joinCondition
.
getUnenclosedSQL
(
bu
ilder
);
}
}
if
(
filterCondition
!=
null
)
{
bu
ff
.
append
(
'\n'
);
bu
ilder
.
append
(
'\n'
);
String
condition
=
StringUtils
.
unEnclose
(
filterCondition
.
getSQL
());
condition
=
"/* WHERE "
+
StringUtils
.
quoteRemarkSQL
(
condition
)
+
"\n*/"
;
StringUtils
.
indent
(
bu
ff
,
condition
,
4
,
false
);
StringUtils
.
indent
(
bu
ilder
,
condition
,
4
,
false
);
}
if
(
scanCount
>
0
)
{
bu
ff
.
append
(
"\n /* scanCount: "
).
append
(
scanCount
).
append
(
" */"
);
bu
ilder
.
append
(
"\n /* scanCount: "
).
append
(
scanCount
).
append
(
" */"
);
}
return
bu
ff
.
toString
()
;
return
bu
ilder
;
}
/**
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论