Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
421d27bb
提交
421d27bb
authored
6 年前
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove Select.groupSelect and pass SelectGroups to table filters instead
上级
ae71212d
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
24 行增加
和
23 行删除
+24
-23
Select.java
h2/src/main/org/h2/command/dml/Select.java
+16
-23
select.sql
h2/src/test/org/h2/test/scripts/dml/select.sql
+8
-0
没有找到文件。
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
421d27bb
...
@@ -118,11 +118,6 @@ public class Select extends Query {
...
@@ -118,11 +118,6 @@ public class Select extends Query {
*/
*/
boolean
[]
groupByExpression
;
boolean
[]
groupByExpression
;
/**
* Select with grouped data for aggregates.
*/
private
Select
groupSelect
;
/**
/**
* Grouped data for aggregates.
* Grouped data for aggregates.
*/
*/
...
@@ -219,10 +214,6 @@ public class Select extends Query {
...
@@ -219,10 +214,6 @@ public class Select extends Query {
return
group
;
return
group
;
}
}
void
setGroupSelect
(
Select
groupSelect
)
{
this
.
groupSelect
=
groupSelect
;
}
/**
/**
* Get the group data if there is currently a group-by active.
* Get the group data if there is currently a group-by active.
*
*
...
@@ -230,9 +221,6 @@ public class Select extends Query {
...
@@ -230,9 +221,6 @@ public class Select extends Query {
* @return the grouped data
* @return the grouped data
*/
*/
public
SelectGroups
getGroupDataIfCurrent
(
boolean
window
)
{
public
SelectGroups
getGroupDataIfCurrent
(
boolean
window
)
{
if
(
groupSelect
!=
null
)
{
return
groupSelect
.
getGroupDataIfCurrent
(
window
);
}
return
groupData
!=
null
&&
(
window
||
groupData
.
isCurrentGroup
())
?
groupData
:
null
;
return
groupData
!=
null
&&
(
window
||
groupData
.
isCurrentGroup
())
?
groupData
:
null
;
}
}
...
@@ -481,13 +469,26 @@ public class Select extends Query {
...
@@ -481,13 +469,26 @@ public class Select extends Query {
private
void
initGroupData
(
int
columnCount
)
{
private
void
initGroupData
(
int
columnCount
)
{
if
(
groupData
==
null
)
{
if
(
groupData
==
null
)
{
groupData
=
SelectGroups
.
getInstance
(
session
,
expressions
,
isGroupQuery
,
groupIndex
);
setGroupData
(
SelectGroups
.
getInstance
(
session
,
expressions
,
isGroupQuery
,
groupIndex
)
);
}
else
{
}
else
{
updateAgg
(
columnCount
,
DataAnalysisOperation
.
STAGE_RESET
);
updateAgg
(
columnCount
,
DataAnalysisOperation
.
STAGE_RESET
);
}
}
groupData
.
reset
();
groupData
.
reset
();
}
}
void
setGroupData
(
final
SelectGroups
groupData
)
{
this
.
groupData
=
groupData
;
topTableFilter
.
visit
(
new
TableFilterVisitor
()
{
@Override
public
void
accept
(
TableFilter
f
)
{
Select
s
=
f
.
getSelect
();
if
(
s
!=
null
)
{
s
.
groupData
=
groupData
;
}
}
});
}
private
void
gatherGroup
(
int
columnCount
,
int
stage
)
{
private
void
gatherGroup
(
int
columnCount
,
int
stage
)
{
long
rowNumber
=
0
;
long
rowNumber
=
0
;
setCurrentRowNumber
(
0
);
setCurrentRowNumber
(
0
);
...
@@ -1346,15 +1347,6 @@ public class Select extends Query {
...
@@ -1346,15 +1347,6 @@ public class Select extends Query {
isGroupSortedQuery
=
true
;
isGroupSortedQuery
=
true
;
}
}
}
}
topTableFilter
.
visit
(
new
TableFilterVisitor
()
{
@Override
public
void
accept
(
TableFilter
f
)
{
Select
s
=
f
.
getSelect
();
if
(
s
!=
null
&&
s
!=
Select
.
this
)
{
s
.
setGroupSelect
(
Select
.
this
);
}
}
});
expressionArray
=
expressions
.
toArray
(
new
Expression
[
0
]);
expressionArray
=
expressions
.
toArray
(
new
Expression
[
0
]);
isPrepared
=
true
;
isPrepared
=
true
;
}
}
...
@@ -1910,7 +1902,8 @@ public class Select extends Query {
...
@@ -1910,7 +1902,8 @@ public class Select extends Query {
LazyResultGroupSorted
(
Expression
[]
expressions
,
int
columnCount
)
{
LazyResultGroupSorted
(
Expression
[]
expressions
,
int
columnCount
)
{
super
(
expressions
,
columnCount
);
super
(
expressions
,
columnCount
);
if
(
groupData
==
null
)
{
if
(
groupData
==
null
)
{
groupData
=
SelectGroups
.
getInstance
(
getSession
(),
Select
.
this
.
expressions
,
isGroupQuery
,
groupIndex
);
setGroupData
(
SelectGroups
.
getInstance
(
getSession
(),
Select
.
this
.
expressions
,
isGroupQuery
,
groupIndex
));
}
else
{
}
else
{
// TODO is this branch possible?
// TODO is this branch possible?
updateAgg
(
columnCount
,
DataAnalysisOperation
.
STAGE_RESET
);
updateAgg
(
columnCount
,
DataAnalysisOperation
.
STAGE_RESET
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/scripts/dml/select.sql
浏览文件 @
421d27bb
...
@@ -603,6 +603,14 @@ FROM (SELECT 1 X), (VALUES (1, 2), (2, 1), (3, 3)) T(A, B);
...
@@ -603,6 +603,14 @@ FROM (SELECT 1 X), (VALUES (1, 2), (2, 1), (3, 3)) T(A, B);
>
1
3
3
>
1
3
3
>
rows
:
3
>
rows
:
3
SELECT
A
,
SUM
(
S
)
OVER
(
ORDER
BY
S
)
FROM
(
SELECT
A
,
SUM
(
B
)
FROM
(
VALUES
(
1
,
2
),
(
1
,
3
),
(
3
,
5
),
(
3
,
10
))
V
(
A
,
B
)
GROUP
BY
A
)
S
(
A
,
S
);
>
A
SUM
(
S
)
OVER
(
ORDER
BY
S
)
>
-
------------------------
>
1
5
>
3
20
>
rows
:
2
SELECT
A
,
B
,
C
FROM
(
SELECT
A
,
B
,
C
FROM
(
VALUES
(
1
,
2
,
3
))
V
(
A
,
B
,
C
));
SELECT
A
,
B
,
C
FROM
(
SELECT
A
,
B
,
C
FROM
(
VALUES
(
1
,
2
,
3
))
V
(
A
,
B
,
C
));
>
A
B
C
>
A
B
C
>
-
-
-
>
-
-
-
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论