Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
001cd637
提交
001cd637
authored
2月 06, 2019
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix window definition lookup in some queries
上级
f2c645a3
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
38 行增加
和
10 行删除
+38
-10
Parser.java
h2/src/main/org/h2/command/Parser.java
+5
-5
MergeUsing.java
h2/src/main/org/h2/command/dml/MergeUsing.java
+1
-1
Select.java
h2/src/main/org/h2/command/dml/Select.java
+17
-1
Window.java
h2/src/main/org/h2/expression/analysis/Window.java
+8
-3
select.sql
h2/src/test/org/h2/test/scripts/dml/select.sql
+7
-0
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
001cd637
...
@@ -1335,7 +1335,7 @@ public class Parser {
...
@@ -1335,7 +1335,7 @@ public class Parser {
}
}
private
Prepared
parseHelp
()
{
private
Prepared
parseHelp
()
{
Select
select
=
new
Select
(
session
);
Select
select
=
new
Select
(
session
,
null
);
select
.
setWildcard
();
select
.
setWildcard
();
Table
table
=
database
.
getSchema
(
"INFORMATION_SCHEMA"
).
resolveTableOrView
(
session
,
"HELP"
);
Table
table
=
database
.
getSchema
(
"INFORMATION_SCHEMA"
).
resolveTableOrView
(
session
,
"HELP"
);
Function
function
=
Function
.
getFunction
(
database
,
"UPPER"
);
Function
function
=
Function
.
getFunction
(
database
,
"UPPER"
);
...
@@ -1535,7 +1535,7 @@ public class Parser {
...
@@ -1535,7 +1535,7 @@ public class Parser {
TableFilter
sourceTableFilter
=
readSimpleTableFilter
(
0
,
null
);
TableFilter
sourceTableFilter
=
readSimpleTableFilter
(
0
,
null
);
command
.
setSourceTableFilter
(
sourceTableFilter
);
command
.
setSourceTableFilter
(
sourceTableFilter
);
Select
preparedQuery
=
new
Select
(
session
);
Select
preparedQuery
=
new
Select
(
session
,
null
);
preparedQuery
.
setWildcard
();
preparedQuery
.
setWildcard
();
TableFilter
filter
=
new
TableFilter
(
session
,
sourceTableFilter
.
getTable
(),
TableFilter
filter
=
new
TableFilter
(
session
,
sourceTableFilter
.
getTable
(),
sourceTableFilter
.
getTableAlias
(),
rightsChecked
,
preparedQuery
,
0
,
null
);
sourceTableFilter
.
getTableAlias
(),
rightsChecked
,
preparedQuery
,
0
,
null
);
...
@@ -2689,7 +2689,7 @@ public class Parser {
...
@@ -2689,7 +2689,7 @@ public class Parser {
}
else
if
(
readIf
(
TABLE
))
{
}
else
if
(
readIf
(
TABLE
))
{
int
start
=
lastParseIndex
;
int
start
=
lastParseIndex
;
Table
table
=
readTableOrView
();
Table
table
=
readTableOrView
();
Select
command
=
new
Select
(
session
);
Select
command
=
new
Select
(
session
,
currentSelect
);
TableFilter
filter
=
new
TableFilter
(
session
,
table
,
null
,
rightsChecked
,
TableFilter
filter
=
new
TableFilter
(
session
,
table
,
null
,
rightsChecked
,
command
,
orderInFrom
++,
null
);
command
,
orderInFrom
++,
null
);
command
.
addTableFilter
(
filter
,
true
);
command
.
addTableFilter
(
filter
,
true
);
...
@@ -2703,7 +2703,7 @@ public class Parser {
...
@@ -2703,7 +2703,7 @@ public class Parser {
}
else
{
}
else
{
throw
getSyntaxError
();
throw
getSyntaxError
();
}
}
Select
command
=
new
Select
(
session
);
Select
command
=
new
Select
(
session
,
currentSelect
);
int
start
=
lastParseIndex
;
int
start
=
lastParseIndex
;
Select
oldSelect
=
currentSelect
;
Select
oldSelect
=
currentSelect
;
Prepared
oldPrepared
=
currentPrepared
;
Prepared
oldPrepared
=
currentPrepared
;
...
@@ -5867,7 +5867,7 @@ public class Parser {
...
@@ -5867,7 +5867,7 @@ public class Parser {
}
}
private
Select
parseValues
()
{
private
Select
parseValues
()
{
Select
command
=
new
Select
(
session
);
Select
command
=
new
Select
(
session
,
currentSelect
);
currentSelect
=
command
;
currentSelect
=
command
;
TableFilter
filter
=
parseValuesTable
(
0
);
TableFilter
filter
=
parseValuesTable
(
0
);
command
.
setWildcard
();
command
.
setWildcard
();
...
...
h2/src/main/org/h2/command/dml/MergeUsing.java
浏览文件 @
001cd637
...
@@ -419,7 +419,7 @@ public class MergeUsing extends Prepared {
...
@@ -419,7 +419,7 @@ public class MergeUsing extends Prepared {
}
}
// setup the targetMatchQuery - for detecting if the target row exists
// setup the targetMatchQuery - for detecting if the target row exists
targetMatchQuery
=
new
Select
(
session
);
targetMatchQuery
=
new
Select
(
session
,
null
);
ArrayList
<
Expression
>
expressions
=
new
ArrayList
<>(
1
);
ArrayList
<
Expression
>
expressions
=
new
ArrayList
<>(
1
);
expressions
.
add
(
new
ExpressionColumn
(
session
.
getDatabase
(),
targetTable
.
getSchema
().
getName
(),
expressions
.
add
(
new
ExpressionColumn
(
session
.
getDatabase
(),
targetTable
.
getSchema
().
getName
(),
targetTableFilter
.
getTableAlias
(),
"_ROWID_"
));
targetTableFilter
.
getTableAlias
(),
"_ROWID_"
));
...
...
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
001cd637
...
@@ -78,6 +78,11 @@ public class Select extends Query {
...
@@ -78,6 +78,11 @@ public class Select extends Query {
private
final
ArrayList
<
TableFilter
>
filters
=
Utils
.
newSmallArrayList
();
private
final
ArrayList
<
TableFilter
>
filters
=
Utils
.
newSmallArrayList
();
private
final
ArrayList
<
TableFilter
>
topFilters
=
Utils
.
newSmallArrayList
();
private
final
ArrayList
<
TableFilter
>
topFilters
=
Utils
.
newSmallArrayList
();
/**
* Parent select for selects in table filters.
*/
private
Select
parentSelect
;
/**
/**
* WHERE condition.
* WHERE condition.
*/
*/
...
@@ -146,8 +151,9 @@ public class Select extends Query {
...
@@ -146,8 +151,9 @@ public class Select extends Query {
private
HashMap
<
String
,
Window
>
windows
;
private
HashMap
<
String
,
Window
>
windows
;
public
Select
(
Session
session
)
{
public
Select
(
Session
session
,
Select
parentSelect
)
{
super
(
session
);
super
(
session
);
this
.
parentSelect
=
parentSelect
;
}
}
@Override
@Override
...
@@ -1956,4 +1962,14 @@ public class Select extends Query {
...
@@ -1956,4 +1962,14 @@ public class Select extends Query {
return
row
;
return
row
;
}
}
}
}
/**
* Returns parent select, or null.
*
* @return parent select, or null
*/
public
Select
getParentSelect
()
{
return
parentSelect
;
}
}
}
h2/src/main/org/h2/expression/analysis/Window.java
浏览文件 @
001cd637
...
@@ -8,6 +8,7 @@ package org.h2.expression.analysis;
...
@@ -8,6 +8,7 @@ package org.h2.expression.analysis;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.command.dml.Select
;
import
org.h2.command.dml.SelectOrderBy
;
import
org.h2.command.dml.SelectOrderBy
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.expression.Expression
;
import
org.h2.expression.Expression
;
...
@@ -104,9 +105,13 @@ public final class Window {
...
@@ -104,9 +105,13 @@ public final class Window {
private
void
resolveWindows
(
ColumnResolver
resolver
)
{
private
void
resolveWindows
(
ColumnResolver
resolver
)
{
if
(
parent
!=
null
)
{
if
(
parent
!=
null
)
{
Window
p
=
resolver
.
getSelect
().
getWindow
(
parent
);
Select
select
=
resolver
.
getSelect
();
if
(
p
==
null
)
{
Window
p
;
throw
DbException
.
get
(
ErrorCode
.
WINDOW_NOT_FOUND_1
,
parent
);
while
((
p
=
select
.
getWindow
(
parent
))
==
null
)
{
select
=
select
.
getParentSelect
();
if
(
select
==
null
)
{
throw
DbException
.
get
(
ErrorCode
.
WINDOW_NOT_FOUND_1
,
parent
);
}
}
}
p
.
resolveWindows
(
resolver
);
p
.
resolveWindows
(
resolver
);
if
(
partitionBy
==
null
)
{
if
(
partitionBy
==
null
)
{
...
...
h2/src/test/org/h2/test/scripts/dml/select.sql
浏览文件 @
001cd637
...
@@ -611,6 +611,13 @@ SELECT A, SUM(S) OVER (ORDER BY S) FROM
...
@@ -611,6 +611,13 @@ SELECT A, SUM(S) OVER (ORDER BY S) FROM
>
3
20
>
3
20
>
rows
:
2
>
rows
:
2
SELECT
A
,
SUM
(
A
)
OVER
W
SUM
FROM
(
VALUES
1
,
2
)
T
(
A
)
WINDOW
W
AS
(
ORDER
BY
A
);
>
A
SUM
>
-
---
>
1
1
>
2
3
>
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
>
-
-
-
>
-
-
-
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论