Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
96c8f626
Unverified
提交
96c8f626
authored
2月 05, 2019
作者:
Evgenij Ryazanov
提交者:
GitHub
2月 05, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1720 from katzyn/window
Fix issue with window query with VALUES and move QUALIFY after WINDOW
上级
11f00203
8e5b3055
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
67 行增加
和
18 行删除
+67
-18
help.csv
h2/src/docsrc/help/help.csv
+1
-1
changelog.html
h2/src/docsrc/html/changelog.html
+6
-0
Parser.java
h2/src/main/org/h2/command/Parser.java
+5
-5
Select.java
h2/src/main/org/h2/command/dml/Select.java
+22
-0
MVMap.java
h2/src/main/org/h2/mvstore/MVMap.java
+8
-5
select.sql
h2/src/test/org/h2/test/scripts/dml/select.sql
+18
-0
row_number.sql
.../test/org/h2/test/scripts/functions/window/row_number.sql
+6
-6
dictionary.txt
h2/src/tools/org/h2/build/doc/dictionary.txt
+1
-1
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
96c8f626
...
...
@@ -11,8 +11,8 @@ selectExpression [,...]
[ FROM tableExpression [,...] ]
[ WHERE expression ]
[ GROUP BY expression [,...] ] [ HAVING expression ]
[ QUALIFY expression ]
[ WINDOW { { windowName AS windowSpecification } [,...] } ]
[ QUALIFY expression ]
[ { UNION [ ALL ] | EXCEPT | MINUS | INTERSECT } select ]
[ ORDER BY order [,...] ]
[ LIMIT expression [ OFFSET expression ] [ SAMPLE_SIZE rowCountInt ] ]
...
...
h2/src/docsrc/html/changelog.html
浏览文件 @
96c8f626
...
...
@@ -21,6 +21,12 @@ Change Log
<h2>
Next Version (unreleased)
</h2>
<ul>
<li>
Issue #1718: Window function and values clause don't work well together
</li>
<li>
PR #1717: Backward compatibility patch for #1592
</li>
<li>
PR #1716: Improve documentation of some DML commands
</li>
<li>
Issue #1715: Postgres mode: Domain "regproc" already exists
</li>
<li>
PR #1714: Assorted changes
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
96c8f626
...
...
@@ -2750,11 +2750,6 @@ public class Parser {
Expression
condition
=
readExpression
();
command
.
setHaving
(
condition
);
}
if
(
readIf
(
QUALIFY
))
{
command
.
setWindowQuery
();
Expression
condition
=
readExpression
();
command
.
setQualify
(
condition
);
}
if
(
readIf
(
WINDOW
))
{
do
{
int
index
=
parseIndex
;
...
...
@@ -2766,6 +2761,11 @@ public class Parser {
}
}
while
(
readIf
(
COMMA
));
}
if
(
readIf
(
QUALIFY
))
{
command
.
setWindowQuery
();
Expression
condition
=
readExpression
();
command
.
setQualify
(
condition
);
}
command
.
setParameterList
(
parameters
);
currentSelect
=
oldSelect
;
currentPrepared
=
oldPrepared
;
...
...
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
96c8f626
...
...
@@ -44,6 +44,7 @@ import org.h2.table.IndexColumn;
import
org.h2.table.JoinBatch
;
import
org.h2.table.Table
;
import
org.h2.table.TableFilter
;
import
org.h2.table.TableFilter.TableFilterVisitor
;
import
org.h2.table.TableType
;
import
org.h2.table.TableView
;
import
org.h2.util.ColumnNamer
;
...
...
@@ -117,6 +118,11 @@ public class Select extends Query {
*/
boolean
[]
groupByExpression
;
/**
* Select with grouped data for aggregates.
*/
private
Select
groupSelect
;
/**
* Grouped data for aggregates.
*/
...
...
@@ -213,6 +219,10 @@ public class Select extends Query {
return
group
;
}
void
setGroupSelect
(
Select
groupSelect
)
{
this
.
groupSelect
=
groupSelect
;
}
/**
* Get the group data if there is currently a group-by active.
*
...
...
@@ -220,6 +230,9 @@ public class Select extends Query {
* @return the grouped data
*/
public
SelectGroups
getGroupDataIfCurrent
(
boolean
window
)
{
if
(
groupSelect
!=
null
)
{
return
groupSelect
.
getGroupDataIfCurrent
(
window
);
}
return
groupData
!=
null
&&
(
window
||
groupData
.
isCurrentGroup
())
?
groupData
:
null
;
}
...
...
@@ -1333,6 +1346,15 @@ public class Select extends Query {
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
]);
isPrepared
=
true
;
}
...
...
h2/src/main/org/h2/mvstore/MVMap.java
浏览文件 @
96c8f626
...
...
@@ -1306,7 +1306,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
int
unsavedMemory
=
replacement
.
getMemory
();
while
(
path
!=
null
)
{
Page
parent
=
path
.
page
;
// condition below sould always be true, but older versions (up to 1.4.197)
// condition below s
h
ould always be true, but older versions (up to 1.4.197)
// may create single-childed (with no keys) internal nodes, which we skip here
if
(
parent
.
getKeyCount
()
>
0
)
{
Page
child
=
replacement
;
...
...
@@ -1717,8 +1717,10 @@ public class MVMap<K, V> extends AbstractMap<K, V>
index
=
pos
.
index
;
pos
=
pos
.
parent
;
keyCount
=
p
.
getKeyCount
();
// condition below sould always be false, but older versions (up to 1.4.197)
// may create single-childed (with no keys) internal nodes, which we skip here
// condition below should always be false, but older
// versions (up to 1.4.197) may create
// single-childed (with no keys) internal nodes,
// which we skip here
}
while
(
keyCount
==
0
&&
pos
!=
null
);
if
(
keyCount
<=
1
)
{
...
...
@@ -1726,8 +1728,9 @@ public class MVMap<K, V> extends AbstractMap<K, V>
assert
index
<=
1
;
p
=
p
.
getChildPage
(
1
-
index
);
}
else
{
// if root happens to be such single-childed (with no keys) internal node,
// then just replace it with empty leaf
// if root happens to be such single-childed
// (with no keys) internal node, then just
// replace it with empty leaf
p
=
Page
.
createEmptyLeaf
(
this
);
}
break
;
...
...
h2/src/test/org/h2/test/scripts/dml/select.sql
浏览文件 @
96c8f626
...
...
@@ -584,3 +584,21 @@ SELECT COUNT(*) C FROM TEST QUALIFY C < 1;
DROP
TABLE
TEST
;
>
ok
SELECT
A
,
ROW_NUMBER
()
OVER
(
ORDER
BY
B
)
R
FROM
(
VALUES
(
1
,
2
),
(
2
,
1
),
(
3
,
3
))
T
(
A
,
B
);
>
A
R
>
-
-
>
1
2
>
2
1
>
3
3
>
rows
:
3
SELECT
X
,
A
,
ROW_NUMBER
()
OVER
(
ORDER
BY
B
)
R
FROM
(
SELECT
1
X
),
(
VALUES
(
1
,
2
),
(
2
,
1
),
(
3
,
3
))
T
(
A
,
B
);
>
X
A
R
>
-
-
-
>
1
1
2
>
1
2
1
>
1
3
3
>
rows
:
3
h2/src/test/org/h2/test/scripts/functions/window/row_number.sql
浏览文件 @
96c8f626
...
...
@@ -84,12 +84,12 @@ SELECT *,
>
rows
:
9
SELECT
*
,
ROW_NUMBER
()
OVER
(
PARTITION
BY
CATEGORY
ORDER
BY
ID
)
RN
,
RANK
()
OVER
(
PARTITION
BY
CATEGORY
ORDER
BY
ID
)
RK
,
DENSE_RANK
()
OVER
(
PARTITION
BY
CATEGORY
ORDER
BY
ID
)
DR
,
ROUND
(
PERCENT_RANK
()
OVER
(
PARTITION
BY
CATEGORY
ORDER
BY
ID
)
,
2
)
PR
,
ROUND
(
CUME_DIST
()
OVER
(
PARTITION
BY
CATEGORY
ORDER
BY
ID
)
,
2
)
CD
FROM
TEST
QUALIFY
ROW_NUMBER
()
OVER
(
PARTITION
BY
CATEGORY
ORDER
BY
ID
)
=
2
;
ROW_NUMBER
()
OVER
W
RN
,
RANK
()
OVER
W
RK
,
DENSE_RANK
()
OVER
W
DR
,
ROUND
(
PERCENT_RANK
()
OVER
W
,
2
)
PR
,
ROUND
(
CUME_DIST
()
OVER
W
,
2
)
CD
FROM
TEST
WINDOW
W
AS
(
PARTITION
BY
CATEGORY
ORDER
BY
ID
)
QUALIFY
ROW_NUMBER
()
OVER
W
=
2
;
>
ID
CATEGORY
VALUE
RN
RK
DR
PR
CD
>
-- -------- ----- -- -- -- --- ----
>
2
1
12
2
2
2
0
.
5
0
.
67
...
...
h2/src/tools/org/h2/build/doc/dictionary.txt
浏览文件 @
96c8f626
...
...
@@ -806,4 +806,4 @@ econd irst bcef ordinality nord unnest
analyst occupation distributive josaph aor engineer sajeewa isuru randil kevin doctor businessman artist ashan
corrupts splitted disruption unintentional octets preconditions predicates subq objectweb insn opcodes
preserves masking holder unboxing avert iae transformed subtle reevaluate exclusions subclause ftbl rgr
presorted inclusion contexts aax mwd percentile cont interpolate mwa hypothetical regproc
presorted inclusion contexts aax mwd percentile cont interpolate mwa hypothetical regproc
childed
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论