Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
d6670d61
提交
d6670d61
authored
11月 22, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add ANY aggregate and use standard names in documentation
上级
138b31ca
显示空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
79 行增加
和
44 行删除
+79
-44
help.csv
h2/src/docsrc/help/help.csv
+6
-6
Aggregate.java
h2/src/main/org/h2/expression/aggregate/Aggregate.java
+17
-16
AggregateData.java
h2/src/main/org/h2/expression/aggregate/AggregateData.java
+2
-2
AggregateDataDefault.java
...ain/org/h2/expression/aggregate/AggregateDataDefault.java
+4
-4
TestScript.java
h2/src/test/org/h2/test/scripts/TestScript.java
+2
-2
any.sql
h2/src/test/org/h2/test/scripts/functions/aggregate/any.sql
+21
-0
bool-and.sql
...test/org/h2/test/scripts/functions/aggregate/bool-and.sql
+0
-4
bool-or.sql
.../test/org/h2/test/scripts/functions/aggregate/bool-or.sql
+0
-4
every.sql
...rc/test/org/h2/test/scripts/functions/aggregate/every.sql
+21
-0
testScript.sql
h2/src/test/org/h2/test/scripts/testScript.sql
+6
-6
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
d6670d61
...
...
@@ -3444,26 +3444,26 @@ Aggregates are only allowed in select statements.
BIT_OR(ID)
"
"Functions (Aggregate)","
BOOL_AND
","
BOOL_AND
(boolean)
"Functions (Aggregate)","
EVERY
","
{EVERY|BOOL_AND}
(boolean)
[FILTER (WHERE expression)] [OVER windowNameOrSpecification]
","
Returns true if all expressions are true.
If no rows are selected, the result is NULL.
Aggregates are only allowed in select statements.
","
BOOL_AND
(ID>10)
EVERY
(ID>10)
"
"Functions (Aggregate)","
BOOL_OR
","
BOOL_OR
(boolean)
"Functions (Aggregate)","
ANY
","
{ANY|SOME|BOOL_OR}
(boolean)
[FILTER (WHERE expression)] [OVER windowNameOrSpecification]
","
Returns true if any expression is true.
If no rows are selected, the result is NULL.
Aggregates are only allowed in select statements.
","
BOOL_OR
(NAME LIKE 'W%')
ANY
(NAME LIKE 'W%')
"
"Functions (Aggregate)","COUNT","
...
...
h2/src/main/org/h2/expression/aggregate/Aggregate.java
浏览文件 @
d6670d61
...
...
@@ -105,14 +105,14 @@ public class Aggregate extends AbstractAggregate {
VAR_SAMP
,
/**
* The aggregate type for
BOOL_OR
(expression).
* The aggregate type for
ANY
(expression).
*/
BOOL_OR
,
ANY
,
/**
* The aggregate type for
BOOL_AND
(expression).
* The aggregate type for
EVERY
(expression).
*/
BOOL_AND
,
EVERY
,
/**
* The aggregate type for BOOL_OR(expression).
...
...
@@ -209,12 +209,13 @@ public class Aggregate extends AbstractAggregate {
addAggregate
(
"VAR_SAMP"
,
AggregateType
.
VAR_SAMP
);
addAggregate
(
"VAR"
,
AggregateType
.
VAR_SAMP
);
addAggregate
(
"VARIANCE"
,
AggregateType
.
VAR_SAMP
);
addAggregate
(
"BOOL_OR"
,
AggregateType
.
BOOL_OR
);
// HSQLDB compatibility, but conflicts with x > EVERY(...)
addAggregate
(
"SOME"
,
AggregateType
.
BOOL_OR
);
addAggregate
(
"BOOL_AND"
,
AggregateType
.
BOOL_AND
);
// HSQLDB compatibility, but conflicts with x > SOME(...)
addAggregate
(
"EVERY"
,
AggregateType
.
BOOL_AND
);
addAggregate
(
"ANY"
,
AggregateType
.
ANY
);
addAggregate
(
"SOME"
,
AggregateType
.
ANY
);
// PostgreSQL compatibility
addAggregate
(
"BOOL_OR"
,
AggregateType
.
ANY
);
addAggregate
(
"EVERY"
,
AggregateType
.
EVERY
);
// PostgreSQL compatibility
addAggregate
(
"BOOL_AND"
,
AggregateType
.
EVERY
);
addAggregate
(
"SELECTIVITY"
,
AggregateType
.
SELECTIVITY
);
addAggregate
(
"HISTOGRAM"
,
AggregateType
.
HISTOGRAM
);
addAggregate
(
"BIT_OR"
,
AggregateType
.
BIT_OR
);
...
...
@@ -652,8 +653,8 @@ public class Aggregate extends AbstractAggregate {
displaySize
=
ValueDouble
.
DISPLAY_SIZE
;
scale
=
0
;
break
;
case
BOOL_AND
:
case
BOOL_OR
:
case
EVERY
:
case
ANY
:
dataType
=
Value
.
BOOLEAN
;
precision
=
ValueBoolean
.
PRECISION
;
displaySize
=
ValueBoolean
.
DISPLAY_SIZE
;
...
...
@@ -779,11 +780,11 @@ public class Aggregate extends AbstractAggregate {
case
VAR_SAMP:
text
=
"VAR_SAMP"
;
break
;
case
BOOL_AND
:
text
=
"
BOOL_AND
"
;
case
EVERY
:
text
=
"
EVERY
"
;
break
;
case
BOOL_OR
:
text
=
"
BOOL_OR
"
;
case
ANY
:
text
=
"
ANY
"
;
break
;
case
BIT_AND:
text
=
"BIT_AND"
;
...
...
h2/src/main/org/h2/expression/aggregate/AggregateData.java
浏览文件 @
d6670d61
...
...
@@ -40,8 +40,8 @@ abstract class AggregateData {
case
MAX:
case
BIT_OR:
case
BIT_AND:
case
BOOL_OR
:
case
BOOL_AND
:
case
ANY
:
case
EVERY
:
return
new
AggregateDataDefault
(
aggregateType
);
case
SUM:
case
AVG:
...
...
h2/src/main/org/h2/expression/aggregate/AggregateDataDefault.java
浏览文件 @
d6670d61
...
...
@@ -83,7 +83,7 @@ class AggregateDataDefault extends AggregateData {
}
break
;
}
case
BOOL_AND
:
case
EVERY
:
v
=
v
.
convertTo
(
Value
.
BOOLEAN
);
if
(
value
==
null
)
{
value
=
v
;
...
...
@@ -91,7 +91,7 @@ class AggregateDataDefault extends AggregateData {
value
=
ValueBoolean
.
get
(
value
.
getBoolean
()
&&
v
.
getBoolean
());
}
break
;
case
BOOL_OR
:
case
ANY
:
v
=
v
.
convertTo
(
Value
.
BOOLEAN
);
if
(
value
==
null
)
{
value
=
v
;
...
...
@@ -127,8 +127,8 @@ class AggregateDataDefault extends AggregateData {
case
MAX:
case
BIT_OR:
case
BIT_AND:
case
BOOL_OR
:
case
BOOL_AND
:
case
ANY
:
case
EVERY
:
v
=
value
;
break
;
case
AVG:
...
...
h2/src/test/org/h2/test/scripts/TestScript.java
浏览文件 @
d6670d61
...
...
@@ -161,8 +161,8 @@ public class TestScript extends TestDb {
for
(
String
s
:
new
String
[]
{
"help"
})
{
testScript
(
"other/"
+
s
+
".sql"
);
}
for
(
String
s
:
new
String
[]
{
"array-agg"
,
"avg"
,
"bit-and"
,
"bit-or"
,
"count"
,
"envelope"
,
"group-concat"
,
"histogram"
,
"max"
,
"median"
,
"min"
,
"mode"
,
"selectivity"
,
"stddev-pop"
,
for
(
String
s
:
new
String
[]
{
"a
ny"
,
"a
rray-agg"
,
"avg"
,
"bit-and"
,
"bit-or"
,
"count"
,
"envelope"
,
"
every"
,
"
group-concat"
,
"histogram"
,
"max"
,
"median"
,
"min"
,
"mode"
,
"selectivity"
,
"stddev-pop"
,
"stddev-samp"
,
"sum"
,
"var-pop"
,
"var-samp"
})
{
testScript
(
"functions/aggregate/"
+
s
+
".sql"
);
}
...
...
h2/src/test/org/h2/test/scripts/functions/aggregate/any.sql
0 → 100644
浏览文件 @
d6670d61
-- Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
--
CREATE
TABLE
TEST
(
A
INT
,
B
INT
);
>
ok
INSERT
INTO
TEST
VALUES
(
1
,
1
),
(
1
,
3
),
(
2
,
1
),
(
2
,
5
),
(
3
,
4
);
>
update
count
:
5
SELECT
A
,
ANY
(
B
<
2
),
SOME
(
B
>
3
),
BOOL_OR
(
B
=
1
),
ANY
(
B
=
1
)
FILTER
(
WHERE
A
=
1
)
FROM
TEST
GROUP
BY
A
;
>
A
ANY
(
B
<
2
)
ANY
(
B
>
3
)
ANY
(
B
=
1
)
ANY
(
B
=
1
)
FILTER
(
WHERE
(
A
=
1
))
>
-
---------- ---------- ---------- ---------------------------------
>
1
TRUE
FALSE
TRUE
TRUE
>
2
TRUE
TRUE
TRUE
null
>
3
FALSE
TRUE
FALSE
null
>
rows
:
3
DROP
TABLE
TEST
;
>
ok
h2/src/test/org/h2/test/scripts/functions/aggregate/bool-and.sql
deleted
100644 → 0
浏览文件 @
138b31ca
-- Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
--
h2/src/test/org/h2/test/scripts/functions/aggregate/bool-or.sql
deleted
100644 → 0
浏览文件 @
138b31ca
-- Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
--
h2/src/test/org/h2/test/scripts/functions/aggregate/every.sql
0 → 100644
浏览文件 @
d6670d61
-- Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
--
CREATE
TABLE
TEST
(
A
INT
,
B
INT
);
>
ok
INSERT
INTO
TEST
VALUES
(
1
,
1
),
(
1
,
3
),
(
2
,
1
),
(
2
,
5
),
(
3
,
4
);
>
update
count
:
5
SELECT
A
,
EVERY
(
B
<
5
),
BOOL_AND
(
B
>
1
),
EVERY
(
B
>=
1
)
FILTER
(
WHERE
A
=
1
)
FROM
TEST
GROUP
BY
A
;
>
A
EVERY
(
B
<
5
)
EVERY
(
B
>
1
)
EVERY
(
B
>=
1
)
FILTER
(
WHERE
(
A
=
1
))
>
-
------------ ------------ ------------------------------------
>
1
TRUE
FALSE
TRUE
>
2
FALSE
FALSE
null
>
3
TRUE
TRUE
null
>
rows
:
3
DROP
TABLE
TEST
;
>
ok
h2/src/test/org/h2/test/scripts/testScript.sql
浏览文件 @
d6670d61
...
...
@@ -6582,8 +6582,8 @@ select * from s;
>
rows
:
1
select
some
(
y
>
10
),
every
(
y
>
10
),
min
(
y
),
max
(
y
)
from
t
;
>
BOOL_OR
(
Y
>
10
.
0
)
BOOL_AND
(
Y
>
10
.
0
)
MIN
(
Y
)
MAX
(
Y
)
>
-------------
---- ---
--------------- ------ ------
>
ANY
(
Y
>
10
.
0
)
EVERY
(
Y
>
10
.
0
)
MIN
(
Y
)
MAX
(
Y
)
>
-------------
--------------- ------ ------
>
null
null
null
null
>
rows
:
1
...
...
@@ -6640,8 +6640,8 @@ stddev_pop(distinct y) s_py, stddev_samp(distinct y) s_sy, var_pop(distinct y) v
>
rows
:
1
select
some
(
y
>
10
),
every
(
y
>
10
),
min
(
y
),
max
(
y
)
from
t
;
>
BOOL_OR
(
Y
>
10
.
0
)
BOOL_AND
(
Y
>
10
.
0
)
MIN
(
Y
)
MAX
(
Y
)
>
-------------
---- ---
--------------- ------ ------
>
ANY
(
Y
>
10
.
0
)
EVERY
(
Y
>
10
.
0
)
MIN
(
Y
)
MAX
(
Y
)
>
-------------
--------------- ------ ------
>
TRUE
FALSE
4
.
0
16
.
0
>
rows
:
1
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论