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