Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
9ce14802
Unverified
提交
9ce14802
authored
5月 20, 2018
作者:
Noel Grandin
提交者:
GitHub
5月 20, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1144 from devnied/fix-recursive-schema
Add missing schema name with recursive view
上级
fdcd54e3
f95cb15d
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
45 行增加
和
4 行删除
+45
-4
Select.java
h2/src/main/org/h2/command/dml/Select.java
+4
-1
TableFilter.java
h2/src/main/org/h2/table/TableFilter.java
+1
-1
with.sql
h2/src/test/org/h2/test/scripts/dml/with.sql
+40
-2
没有找到文件。
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
9ce14802
...
...
@@ -13,6 +13,7 @@ import java.util.Map;
import
org.h2.api.ErrorCode
;
import
org.h2.api.Trigger
;
import
org.h2.command.CommandInterface
;
import
org.h2.command.Parser
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Database
;
import
org.h2.engine.Session
;
...
...
@@ -1158,7 +1159,9 @@ public class Select extends Query {
// since using a with statement will re-create the common table expression
// views.
}
else
{
buff
.
append
(
"WITH RECURSIVE "
).
append
(
t
.
getName
()).
append
(
'('
);
buff
.
append
(
"WITH RECURSIVE "
)
.
append
(
t
.
getSchema
().
getSQL
()).
append
(
'.'
).
append
(
Parser
.
quoteIdentifier
(
t
.
getName
()))
.
append
(
'('
);
buff
.
resetCount
();
for
(
Column
c
:
t
.
getColumns
())
{
buff
.
appendExceptFirst
(
","
);
...
...
h2/src/main/org/h2/table/TableFilter.java
浏览文件 @
9ce14802
...
...
@@ -778,7 +778,7 @@ public class TableFilter implements ColumnResolver {
return
buff
.
toString
();
}
if
(
table
.
isView
()
&&
((
TableView
)
table
).
isRecursive
())
{
buff
.
append
(
table
.
get
Name
(
));
buff
.
append
(
table
.
get
Schema
().
getSQL
()).
append
(
'.'
).
append
(
Parser
.
quoteIdentifier
(
table
.
getName
()
));
}
else
{
buff
.
append
(
table
.
getSQL
());
}
...
...
h2/src/test/org/h2/test/scripts/dml/with.sql
浏览文件 @
9ce14802
...
...
@@ -6,7 +6,14 @@ explain with recursive r(n) as (
(
select
1
)
union
all
(
select
n
+
1
from
r
where
n
<
3
)
)
select
n
from
r
;
>>
WITH
RECURSIVE
R
(
N
)
AS
(
(
SELECT
1
FROM
SYSTEM_RANGE
(
1
,
1
)
/* PUBLIC.RANGE_INDEX */
)
UNION
ALL
(
SELECT
(
N
+
1
)
FROM
PUBLIC
.
R
/* PUBLIC.R.tableScan */
WHERE
N
<
3
)
)
SELECT
N
FROM
R
R
/* null */
>>
WITH
RECURSIVE
PUBLIC
.
R
(
N
)
AS
(
(
SELECT
1
FROM
SYSTEM_RANGE
(
1
,
1
)
/* PUBLIC.RANGE_INDEX */
)
UNION
ALL
(
SELECT
(
N
+
1
)
FROM
PUBLIC
.
R
/* PUBLIC.R.tableScan */
WHERE
N
<
3
)
)
SELECT
N
FROM
PUBLIC
.
R
R
/* null */
explain
with
recursive
"r"
(
n
)
as
(
(
select
1
)
union
all
(
select
n
+
1
from
"r"
where
n
<
3
)
)
select
n
from
"r"
;
>>
WITH
RECURSIVE
PUBLIC
.
"r"
(
N
)
AS
(
(
SELECT
1
FROM
SYSTEM_RANGE
(
1
,
1
)
/* PUBLIC.RANGE_INDEX */
)
UNION
ALL
(
SELECT
(
N
+
1
)
FROM
PUBLIC
.
"r"
/* PUBLIC."r".tableScan */
WHERE
N
<
3
)
)
SELECT
N
FROM
PUBLIC
.
"r"
"r"
/* null */
select
sum
(
n
)
from
(
with
recursive
r
(
n
)
as
(
...
...
@@ -16,6 +23,14 @@ select sum(n) from (
);
>>
6
select
sum
(
n
)
from
(
with
recursive
"r"
(
n
)
as
(
(
select
1
)
union
all
(
select
n
+
1
from
"r"
where
n
<
3
)
)
select
n
from
"r"
);
>>
6
select
sum
(
n
)
from
(
select
0
)
join
(
with
recursive
r
(
n
)
as
(
(
select
1
)
union
all
(
select
n
+
1
from
r
where
n
<
3
)
...
...
@@ -44,3 +59,26 @@ with
>
-
-- -- --
>
0
-
1
1
10
>
rows
:
1
CREATE
SCHEMA
SCH
;
>
ok
CREATE
FORCE
VIEW
TABLE_EXPRESSION
SCH
.
R1
(
N
)
AS
(
SELECT
1
)
UNION
ALL
(
SELECT
(
N
+
1
)
FROM
SCH
.
R1
WHERE
N
<
3
);
>
ok
CREATE
VIEW
SCH
.
R2
(
N
)
AS
(
SELECT
1
)
UNION
ALL
(
SELECT
(
N
+
1
)
FROM
SCH
.
R1
WHERE
N
<
3
);
>
ok
SELECT
*
FROM
SCH
.
R2
;
>
N
>
-
>
1
>
2
>
3
>
rows
:
3
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论