Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
f834f3c5
提交
f834f3c5
authored
1月 15, 2019
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix commit
122fa953
上级
7c87be33
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
91 行增加
和
16 行删除
+91
-16
changelog.html
h2/src/docsrc/html/changelog.html
+2
-0
WindowFrame.java
h2/src/main/org/h2/expression/analysis/WindowFrame.java
+18
-14
window.sql
h2/src/test/org/h2/test/scripts/window.sql
+71
-2
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
f834f3c5
...
@@ -23,6 +23,8 @@ Change Log
...
@@ -23,6 +23,8 @@ Change Log
<ul>
<ul>
<li>
Issue #1604: TestCrashAPI: PreparedStatement.getGeneratedKeys() is already closed
<li>
Issue #1604: TestCrashAPI: PreparedStatement.getGeneratedKeys() is already closed
</li>
</li>
<li>
PR #1667: Detect NULL values and overflow in window frame bounds
</li>
<li>
PR #1664: Allow any expressions in window frames
<li>
PR #1664: Allow any expressions in window frames
</li>
</li>
<li>
Issue #1576: H2 Console should not display precision and scale for data types that don't have them
<li>
Issue #1576: H2 Console should not display precision and scale for data types that don't have them
...
...
h2/src/main/org/h2/expression/analysis/WindowFrame.java
浏览文件 @
f834f3c5
...
@@ -323,7 +323,12 @@ public final class WindowFrame {
...
@@ -323,7 +323,12 @@ public final class WindowFrame {
Value
[]
row
=
orderedRows
.
get
(
currentRow
);
Value
[]
row
=
orderedRows
.
get
(
currentRow
);
Value
currentValue
=
row
[
sortIndex
];
Value
currentValue
=
row
[
sortIndex
];
int
type
=
currentValue
.
getType
();
int
type
=
currentValue
.
getType
();
Value
newValue
;
Value
range
=
getValueOffset
(
bound
,
orderedRows
.
get
(
currentRow
),
session
);
switch
(
type
)
{
switch
(
type
)
{
case
Value
.
NULL
:
newValue
=
ValueNull
.
INSTANCE
;
break
;
case
Value
.
BYTE
:
case
Value
.
BYTE
:
case
Value
.
SHORT
:
case
Value
.
SHORT
:
case
Value
.
INT
:
case
Value
.
INT
:
...
@@ -348,13 +353,8 @@ public final class WindowFrame {
...
@@ -348,13 +353,8 @@ public final class WindowFrame {
case
Value
.
INTERVAL_HOUR_TO_MINUTE
:
case
Value
.
INTERVAL_HOUR_TO_MINUTE
:
case
Value
.
INTERVAL_HOUR_TO_SECOND
:
case
Value
.
INTERVAL_HOUR_TO_SECOND
:
case
Value
.
INTERVAL_MINUTE_TO_SECOND
:
case
Value
.
INTERVAL_MINUTE_TO_SECOND
:
break
;
OpType
opType
=
add
^
(
sortOrder
.
getSortTypes
()[
0
]
&
SortOrder
.
DESCENDING
)
!=
0
?
OpType
.
PLUS
default
:
:
OpType
.
MINUS
;
throw
DbException
.
getInvalidValueException
(
"ORDER BY value for RANGE frame"
,
currentValue
.
getTraceSQL
());
}
Value
range
=
getValueOffset
(
bound
,
orderedRows
.
get
(
currentRow
),
session
);
OpType
opType
=
add
^
(
sortOrder
.
getSortTypes
()[
0
]
&
SortOrder
.
DESCENDING
)
!=
0
?
OpType
.
PLUS
:
OpType
.
MINUS
;
Value
newValue
;
try
{
try
{
newValue
=
new
BinaryOperation
(
opType
,
ValueExpression
.
get
(
currentValue
),
ValueExpression
.
get
(
range
))
newValue
=
new
BinaryOperation
(
opType
,
ValueExpression
.
get
(
currentValue
),
ValueExpression
.
get
(
range
))
.
optimize
(
session
).
getValue
(
session
).
convertTo
(
type
);
.
optimize
(
session
).
getValue
(
session
).
convertTo
(
type
);
...
@@ -366,6 +366,10 @@ public final class WindowFrame {
...
@@ -366,6 +366,10 @@ public final class WindowFrame {
}
}
throw
ex
;
throw
ex
;
}
}
break
;
default
:
throw
DbException
.
getInvalidValueException
(
"ORDER BY value for RANGE frame"
,
currentValue
.
getTraceSQL
());
}
Value
[]
newRow
=
row
.
clone
();
Value
[]
newRow
=
row
.
clone
();
newRow
[
sortIndex
]
=
newValue
;
newRow
[
sortIndex
]
=
newValue
;
return
newRow
;
return
newRow
;
...
...
h2/src/test/org/h2/test/scripts/window.sql
浏览文件 @
f834f3c5
...
@@ -115,8 +115,77 @@ SELECT SUM(ID) OVER (ORDER BY ID ROWS NULL PRECEDING) P FROM TEST;
...
@@ -115,8 +115,77 @@ SELECT SUM(ID) OVER (ORDER BY ID ROWS NULL PRECEDING) P FROM TEST;
SELECT
SUM
(
ID
)
OVER
(
ORDER
BY
ID
RANGE
NULL
PRECEDING
)
P
FROM
TEST
;
SELECT
SUM
(
ID
)
OVER
(
ORDER
BY
ID
RANGE
NULL
PRECEDING
)
P
FROM
TEST
;
>
exception
INVALID_VALUE_2
>
exception
INVALID_VALUE_2
SELECT
SUM
(
V
)
OVER
(
ORDER
BY
V
RANGE
BETWEEN
1
PRECEDING
AND
1
FOLLOWING
)
FROM
VALUES
(
1
),
(
NULL
),
(
2
)
T
(
V
);
SELECT
ARRAY_AGG
(
ID
)
OVER
(
ORDER
BY
V
NULLS
FIRST
RANGE
BETWEEN
1
PRECEDING
AND
UNBOUNDED
FOLLOWING
)
A
,
>
exception
INVALID_VALUE_2
ID
,
V
FROM
VALUES
(
1
,
1
),
(
2
,
NULL
),
(
3
,
2
)
T
(
ID
,
V
)
ORDER
BY
V
NULLS
FIRST
;
>
A
ID
V
>
--------- -- ----
>
[
3
,
1
,
2
]
2
null
>
[
3
,
1
]
1
1
>
[
3
,
1
]
3
2
>
rows
(
ordered
):
3
SELECT
ARRAY_AGG
(
ID
)
OVER
(
ORDER
BY
V
NULLS
LAST
RANGE
BETWEEN
1
PRECEDING
AND
UNBOUNDED
FOLLOWING
)
A
,
ID
,
V
FROM
VALUES
(
1
,
1
),
(
2
,
NULL
),
(
3
,
2
)
T
(
ID
,
V
)
ORDER
BY
V
NULLS
LAST
;
>
A
ID
V
>
--------- -- ----
>
[
2
,
3
,
1
]
1
1
>
[
2
,
3
,
1
]
3
2
>
[
2
]
2
null
>
rows
(
ordered
):
3
SELECT
ARRAY_AGG
(
ID
)
OVER
(
ORDER
BY
V
NULLS
FIRST
RANGE
BETWEEN
1
FOLLOWING
AND
UNBOUNDED
FOLLOWING
)
A
,
ID
,
V
FROM
VALUES
(
1
,
1
),
(
2
,
NULL
),
(
3
,
2
)
T
(
ID
,
V
)
ORDER
BY
V
NULLS
FIRST
;
>
A
ID
V
>
--------- -- ----
>
[
3
,
1
,
2
]
2
null
>
[
3
]
1
1
>
null
3
2
>
rows
(
ordered
):
3
SELECT
ARRAY_AGG
(
ID
)
OVER
(
ORDER
BY
V
NULLS
LAST
RANGE
BETWEEN
1
FOLLOWING
AND
UNBOUNDED
FOLLOWING
)
A
,
ID
,
V
FROM
VALUES
(
1
,
1
),
(
2
,
NULL
),
(
3
,
2
)
T
(
ID
,
V
)
ORDER
BY
V
NULLS
LAST
;
>
A
ID
V
>
------ -- ----
>
[
2
,
3
]
1
1
>
[
2
]
3
2
>
[
2
]
2
null
>
rows
(
ordered
):
3
SELECT
ARRAY_AGG
(
ID
)
OVER
(
ORDER
BY
V
NULLS
FIRST
RANGE
BETWEEN
UNBOUNDED
PRECEDING
AND
1
FOLLOWING
)
A
,
ID
,
V
FROM
VALUES
(
1
,
1
),
(
2
,
NULL
),
(
3
,
2
)
T
(
ID
,
V
)
ORDER
BY
V
NULLS
FIRST
;
>
A
ID
V
>
--------- -- ----
>
[
2
]
2
null
>
[
2
,
1
,
3
]
1
1
>
[
2
,
1
,
3
]
3
2
>
rows
(
ordered
):
3
SELECT
ARRAY_AGG
(
ID
)
OVER
(
ORDER
BY
V
NULLS
LAST
RANGE
BETWEEN
UNBOUNDED
PRECEDING
AND
1
FOLLOWING
)
A
,
ID
,
V
FROM
VALUES
(
1
,
1
),
(
2
,
NULL
),
(
3
,
2
)
T
(
ID
,
V
)
ORDER
BY
V
NULLS
LAST
;
>
A
ID
V
>
--------- -- ----
>
[
1
,
3
]
1
1
>
[
1
,
3
]
3
2
>
[
1
,
3
,
2
]
2
null
>
rows
(
ordered
):
3
SELECT
ARRAY_AGG
(
ID
)
OVER
(
ORDER
BY
V
NULLS
FIRST
RANGE
BETWEEN
UNBOUNDED
PRECEDING
AND
1
PRECEDING
)
A
,
ID
,
V
FROM
VALUES
(
1
,
1
),
(
2
,
NULL
),
(
3
,
2
)
T
(
ID
,
V
)
ORDER
BY
V
NULLS
FIRST
;
>
A
ID
V
>
------ -- ----
>
[
2
]
2
null
>
[
2
]
1
1
>
[
2
,
1
]
3
2
>
rows
(
ordered
):
3
SELECT
ARRAY_AGG
(
ID
)
OVER
(
ORDER
BY
V
NULLS
LAST
RANGE
BETWEEN
UNBOUNDED
PRECEDING
AND
1
PRECEDING
)
A
,
ID
,
V
FROM
VALUES
(
1
,
1
),
(
2
,
NULL
),
(
3
,
2
)
T
(
ID
,
V
)
ORDER
BY
V
NULLS
LAST
;
>
A
ID
V
>
--------- -- ----
>
null
1
1
>
[
1
]
3
2
>
[
1
,
3
,
2
]
2
null
>
rows
(
ordered
):
3
SELECT
SUM
(
V
)
OVER
(
ORDER
BY
V
RANGE
BETWEEN
1
PRECEDING
AND
1
FOLLOWING
)
FROM
VALUES
(
TRUE
)
T
(
V
);
SELECT
SUM
(
V
)
OVER
(
ORDER
BY
V
RANGE
BETWEEN
1
PRECEDING
AND
1
FOLLOWING
)
FROM
VALUES
(
TRUE
)
T
(
V
);
>
exception
INVALID_VALUE_2
>
exception
INVALID_VALUE_2
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论