Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
0840ef36
提交
0840ef36
authored
16 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
The wrong parameters were bound to subqueries with parameters.
上级
1f062c6d
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
79 行增加
和
33 行删除
+79
-33
Select.java
h2/src/main/org/h2/command/dml/Select.java
+41
-13
SelectOrderBy.java
h2/src/main/org/h2/command/dml/SelectOrderBy.java
+20
-0
TransactionCommand.java
h2/src/main/org/h2/command/dml/TransactionCommand.java
+1
-6
ViewIndex.java
h2/src/main/org/h2/index/ViewIndex.java
+1
-0
TableFilter.java
h2/src/main/org/h2/table/TableFilter.java
+16
-14
没有找到文件。
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
0840ef36
...
...
@@ -853,9 +853,9 @@ public class Select extends Query {
}
public
String
getPlanSQL
()
{
if
(
topTableFilter
==
null
)
{
return
sqlStatement
;
}
// can not use the field sqlStatement because the parameter
// indexes may be incorrect: ? may be in fact ?2 for a subquery
// but indexes may be set manually as well
StringBuffer
buff
=
new
StringBuffer
();
Expression
[]
exprList
=
new
Expression
[
expressions
.
size
()];
expressions
.
toArray
(
exprList
);
...
...
@@ -872,17 +872,25 @@ public class Select extends Query {
}
buff
.
append
(
"\nFROM "
);
TableFilter
filter
=
topTableFilter
;
boolean
join
=
false
;
int
id
=
0
;
do
{
if
(
id
>
0
)
{
buff
.
append
(
"\n"
);
if
(
filter
!=
null
)
{
int
i
=
0
;
do
{
if
(
i
>
0
)
{
buff
.
append
(
"\n"
);
}
buff
.
append
(
filter
.
getPlanSQL
(
i
>
0
));
i
++;
filter
=
filter
.
getJoin
();
}
while
(
filter
!=
null
);
}
else
{
for
(
int
i
=
0
;
i
<
filters
.
size
();
i
++)
{
if
(
i
>
0
)
{
buff
.
append
(
"\n"
);
}
filter
=
(
TableFilter
)
filters
.
get
(
i
);
buff
.
append
(
filter
.
getPlanSQL
(
i
>
0
));
}
buff
.
append
(
filter
.
getPlanSQL
(
join
));
id
++;
join
=
true
;
filter
=
filter
.
getJoin
();
}
while
(
filter
!=
null
);
}
if
(
condition
!=
null
)
{
buff
.
append
(
"\nWHERE "
+
StringUtils
.
unEnclose
(
condition
.
getSQL
()));
}
...
...
@@ -897,6 +905,16 @@ public class Select extends Query {
buff
.
append
(
StringUtils
.
unEnclose
(
g
.
getSQL
()));
}
}
if
(
group
!=
null
)
{
buff
.
append
(
"\nGROUP BY "
);
for
(
int
i
=
0
;
i
<
group
.
size
();
i
++)
{
Expression
g
=
(
Expression
)
group
.
get
(
i
);
if
(
i
>
0
)
{
buff
.
append
(
", "
);
}
buff
.
append
(
StringUtils
.
unEnclose
(
g
.
getSQL
()));
}
}
if
(
having
!=
null
)
{
// could be set in addGlobalCondition
// in this case the query is not run directly, just getPlanSQL is
...
...
@@ -911,6 +929,16 @@ public class Select extends Query {
buff
.
append
(
"\nORDER BY "
);
buff
.
append
(
sort
.
getSQL
(
exprList
,
visibleColumnCount
));
}
if
(
orderList
!=
null
)
{
buff
.
append
(
"\nORDER BY "
);
for
(
int
i
=
0
;
i
<
orderList
.
size
();
i
++)
{
if
(
i
>
0
)
{
buff
.
append
(
", "
);
}
SelectOrderBy
o
=
(
SelectOrderBy
)
orderList
.
get
(
i
);
buff
.
append
(
StringUtils
.
unEnclose
(
o
.
getSQL
()));
}
}
if
(
limit
!=
null
)
{
buff
.
append
(
"\nLIMIT "
);
buff
.
append
(
StringUtils
.
unEnclose
(
limit
.
getSQL
()));
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/SelectOrderBy.java
浏览文件 @
0840ef36
...
...
@@ -39,4 +39,24 @@ public class SelectOrderBy {
* If NULL should be appear at the end.
*/
public
boolean
nullsLast
;
public
String
getSQL
()
{
StringBuffer
buff
=
new
StringBuffer
();
if
(
columnIndexExpr
!=
null
)
{
buff
.
append
(
columnIndexExpr
.
getSQL
());
}
else
{
buff
.
append
(
"="
);
buff
.
append
(
expression
.
getSQL
());
}
if
(
descending
)
{
buff
.
append
(
" DESC"
);
}
if
(
nullsFirst
)
{
buff
.
append
(
" NULLS FIRST"
);
}
else
if
(
nullsLast
)
{
buff
.
append
(
" NULLS LAST"
);
}
return
buff
.
toString
();
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/TransactionCommand.java
浏览文件 @
0840ef36
...
...
@@ -149,12 +149,7 @@ public class TransactionCommand extends Prepared {
break
;
case
SHUTDOWN_IMMEDIATELY:
session
.
getUser
().
checkAdmin
();
session
.
getDatabase
().
setPowerOffCount
(
1
);
try
{
session
.
getDatabase
().
checkPowerOff
();
}
catch
(
SQLException
e
)
{
// ignore
}
session
.
getDatabase
().
shutdownImmediately
();
break
;
case
SHUTDOWN:
{
session
.
getUser
().
checkAdmin
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/ViewIndex.java
浏览文件 @
0840ef36
...
...
@@ -157,6 +157,7 @@ public class ViewIndex extends BaseIndex {
for
(
int
i
=
0
;
originalParameters
!=
null
&&
i
<
originalParameters
.
size
();
i
++)
{
Parameter
orig
=
(
Parameter
)
originalParameters
.
get
(
i
);
Value
value
=
orig
.
getValue
(
session
);
idx
=
orig
.
getIndex
();
Parameter
param
=
(
Parameter
)
paramList
.
get
(
idx
++);
param
.
setValue
(
value
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/TableFilter.java
浏览文件 @
0840ef36
...
...
@@ -510,23 +510,25 @@ public class TableFilter implements ColumnResolver {
buff
.
append
(
' '
);
buff
.
append
(
Parser
.
quoteIdentifier
(
alias
));
}
buff
.
append
(
" /* "
);
StringBuffer
planBuff
=
new
StringBuffer
();
planBuff
.
append
(
index
.
getPlanSQL
());
if
(
indexConditions
.
size
()
>
0
)
{
planBuff
.
append
(
": "
);
for
(
int
i
=
0
;
i
<
indexConditions
.
size
();
i
++)
{
IndexCondition
condition
=
(
IndexCondition
)
indexConditions
.
get
(
i
);
if
(
i
>
0
)
{
planBuff
.
append
(
" AND "
);
if
(
index
!=
null
)
{
buff
.
append
(
" /* "
);
StringBuffer
planBuff
=
new
StringBuffer
();
planBuff
.
append
(
index
.
getPlanSQL
());
if
(
indexConditions
.
size
()
>
0
)
{
planBuff
.
append
(
": "
);
for
(
int
i
=
0
;
i
<
indexConditions
.
size
();
i
++)
{
IndexCondition
condition
=
(
IndexCondition
)
indexConditions
.
get
(
i
);
if
(
i
>
0
)
{
planBuff
.
append
(
" AND "
);
}
planBuff
.
append
(
condition
.
getSQL
());
}
planBuff
.
append
(
condition
.
getSQL
());
}
String
plan
=
planBuff
.
toString
();
plan
=
StringUtils
.
quoteRemarkSQL
(
plan
);
buff
.
append
(
plan
);
buff
.
append
(
" */"
);
}
String
plan
=
planBuff
.
toString
();
plan
=
StringUtils
.
quoteRemarkSQL
(
plan
);
buff
.
append
(
plan
);
buff
.
append
(
" */"
);
if
(
join
)
{
buff
.
append
(
" ON "
);
if
(
joinCondition
==
null
)
{
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论