Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
0a8c8b08
提交
0a8c8b08
authored
10 年前
作者:
noelgrandin@gmail.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add support for PostgreSQL STRING_AGG function. Patch by Fred Aquiles.
上级
64040855
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
29 行增加
和
10 行删除
+29
-10
changelog.html
h2/src/docsrc/html/changelog.html
+2
-1
Parser.java
h2/src/main/org/h2/command/Parser.java
+19
-9
Aggregate.java
h2/src/main/org/h2/expression/Aggregate.java
+2
-0
testScript.sql
h2/src/test/org/h2/test/testScript.sql
+6
-0
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
0a8c8b08
...
...
@@ -58,7 +58,8 @@ Change Log
</li><li>
Concurrent CREATE TABLE... IF NOT EXISTS in the presence of MULTI_THREAD=TRUE could
throw an exception.
</li><li>
Fix bug in MVStore when creating lots of temporary tables, where we could run out of
transaction IDs.
transaction IDs.
</li><li>
Add support for PostgreSQL STRING_AGG function. Patch by Fred Aquiles.
</li></ul>
<h2>
Version 1.4.186 Beta (2015-03-02)
</h2>
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/Parser.java
浏览文件 @
0a8c8b08
...
...
@@ -2270,7 +2270,7 @@ public class Parser {
}
}
private
Expression
readAggregate
(
int
aggregateType
)
{
private
Expression
readAggregate
(
int
aggregateType
,
String
aggregateName
)
{
if
(
currentSelect
==
null
)
{
throw
getSyntaxError
();
}
...
...
@@ -2293,14 +2293,24 @@ public class Parser {
}
}
}
else
if
(
aggregateType
==
Aggregate
.
GROUP_CONCAT
)
{
boolean
distinct
=
readIf
(
"DISTINCT"
);
Aggregate
agg
=
new
Aggregate
(
Aggregate
.
GROUP_CONCAT
,
Aggregate
agg
=
null
;
if
(
equalsToken
(
"GROUP_CONCAT"
,
aggregateName
))
{
boolean
distinct
=
readIf
(
"DISTINCT"
);
agg
=
new
Aggregate
(
Aggregate
.
GROUP_CONCAT
,
readExpression
(),
currentSelect
,
distinct
);
if
(
readIf
(
"ORDER"
))
{
read
(
"BY"
);
agg
.
setGroupConcatOrder
(
parseSimpleOrderList
());
}
if
(
readIf
(
"SEPARATOR"
))
{
if
(
readIf
(
"ORDER"
))
{
read
(
"BY"
);
agg
.
setGroupConcatOrder
(
parseSimpleOrderList
());
}
if
(
readIf
(
"SEPARATOR"
))
{
agg
.
setGroupConcatSeparator
(
readExpression
());
}
}
else
if
(
equalsToken
(
"STRING_AGG"
,
aggregateName
))
{
// PostgreSQL compatibility: string_agg(expression, delimiter)
agg
=
new
Aggregate
(
Aggregate
.
GROUP_CONCAT
,
readExpression
(),
currentSelect
,
false
);
read
(
","
);
agg
.
setGroupConcatSeparator
(
readExpression
());
}
r
=
agg
;
...
...
@@ -2382,7 +2392,7 @@ public class Parser {
}
int
agg
=
getAggregateType
(
name
);
if
(
agg
>=
0
)
{
return
readAggregate
(
agg
);
return
readAggregate
(
agg
,
name
);
}
Function
function
=
Function
.
getFunction
(
database
,
name
);
if
(
function
==
null
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/Aggregate.java
浏览文件 @
0a8c8b08
...
...
@@ -163,6 +163,8 @@ public class Aggregate extends Expression {
addAggregate
(
"MAX"
,
MAX
);
addAggregate
(
"AVG"
,
AVG
);
addAggregate
(
"GROUP_CONCAT"
,
GROUP_CONCAT
);
// PostgreSQL compatibility: string_agg(expression, delimiter)
addAggregate
(
"STRING_AGG"
,
GROUP_CONCAT
);
addAggregate
(
"STDDEV_SAMP"
,
STDDEV_SAMP
);
addAggregate
(
"STDDEV"
,
STDDEV_SAMP
);
addAggregate
(
"STDDEV_POP"
,
STDDEV_POP
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/testScript.sql
浏览文件 @
0a8c8b08
...
...
@@ -8188,6 +8188,12 @@ SELECT GROUP_CONCAT(ID ORDER BY ID) FROM TEST;
>
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
>
rows
(
ordered
):
1
SELECT
STRING_AGG
(
ID
,
';'
)
FROM
TEST
;
>
GROUP_CONCAT
(
ID
SEPARATOR
';'
)
>
------------------------------
>
1
;
2
;
3
;
4
;
5
;
6
;
7
;
8
;
9
>
rows
:
1
SELECT
DISTINCT
NAME
FROM
TEST
;
>
NAME
>
--------
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论