Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
024e80c3
提交
024e80c3
authored
13 年前
作者:
noelgrandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add ARRAY_CONTAINS function
上级
81625085
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
46 行增加
和
1 行删除
+46
-1
help.csv
h2/src/docsrc/help/help.csv
+8
-0
Function.java
h2/src/main/org/h2/expression/Function.java
+16
-1
help.csv
h2/src/main/org/h2/res/help.csv
+4
-0
testSimple.in.txt
h2/src/test/org/h2/test/testSimple.in.txt
+18
-0
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
024e80c3
...
...
@@ -3360,6 +3360,14 @@ Returns the length of an array.
CALL ARRAY_LENGTH(('Hello', 'World'))
"
"Functions (System)","ARRAY_CONTAINS","
ARRAY_CONTAINS(arrayExpression, value)
","
Returns a boolean true if the array contains the value.
","
CALL ARRAY_CONTAINS(('Hello', 'World'), 'Hello')
"
"Functions (System)","AUTOCOMMIT","
AUTOCOMMIT()
","
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/Function.java
浏览文件 @
024e80c3
...
...
@@ -96,7 +96,7 @@ public class Function extends Expression implements FunctionCall {
CASE
=
206
,
NEXTVAL
=
207
,
CURRVAL
=
208
,
ARRAY_GET
=
209
,
CSVREAD
=
210
,
CSVWRITE
=
211
,
MEMORY_FREE
=
212
,
MEMORY_USED
=
213
,
LOCK_MODE
=
214
,
SCHEMA
=
215
,
SESSION_ID
=
216
,
ARRAY_LENGTH
=
217
,
LINK_SCHEMA
=
218
,
GREATEST
=
219
,
LEAST
=
220
,
CANCEL_SESSION
=
221
,
SET
=
222
,
TABLE
=
223
,
TABLE_DISTINCT
=
224
,
FILE_READ
=
225
,
TRANSACTION_ID
=
226
,
TRUNCATE_VALUE
=
227
,
NVL2
=
228
,
DECODE
=
229
;
FILE_READ
=
225
,
TRANSACTION_ID
=
226
,
TRUNCATE_VALUE
=
227
,
NVL2
=
228
,
DECODE
=
229
,
ARRAY_CONTAINS
=
230
;
public
static
final
int
ROW_NUMBER
=
300
;
...
...
@@ -320,6 +320,7 @@ public class Function extends Expression implements FunctionCall {
addFunctionNotDeterministic
(
"NEXTVAL"
,
NEXTVAL
,
VAR_ARGS
,
Value
.
LONG
);
addFunctionNotDeterministic
(
"CURRVAL"
,
CURRVAL
,
VAR_ARGS
,
Value
.
LONG
);
addFunction
(
"ARRAY_GET"
,
ARRAY_GET
,
2
,
Value
.
STRING
);
addFunction
(
"ARRAY_CONTAINS"
,
ARRAY_CONTAINS
,
2
,
Value
.
BOOLEAN
,
false
,
true
,
false
);
addFunction
(
"CSVREAD"
,
CSVREAD
,
VAR_ARGS
,
Value
.
RESULT_SET
,
false
,
false
,
true
);
addFunction
(
"CSVWRITE"
,
CSVWRITE
,
VAR_ARGS
,
Value
.
INT
,
false
,
false
,
false
);
addFunctionNotDeterministic
(
"MEMORY_FREE"
,
MEMORY_FREE
,
0
,
Value
.
INT
);
...
...
@@ -873,6 +874,20 @@ public class Function extends Expression implements FunctionCall {
}
break
;
}
case
ARRAY_CONTAINS:
{
result
=
ValueBoolean
.
get
(
false
);
if
(
v0
.
getType
()
==
Value
.
ARRAY
)
{
Value
v1
=
argList
[
1
].
getValue
(
session
);
Value
[]
list
=
((
ValueArray
)
v0
).
getList
();
for
(
Value
v
:
list
)
{
if
(
v
.
equals
(
v1
))
{
result
=
ValueBoolean
.
get
(
true
);
break
;
}
}
}
break
;
}
case
CANCEL_SESSION:
{
result
=
ValueBoolean
.
get
(
cancelStatement
(
session
,
v0
.
getInt
()));
break
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/res/help.csv
浏览文件 @
024e80c3
...
...
@@ -1231,6 +1231,10 @@ Returns one element of an array."
ARRAY_LENGTH(arrayExpression)
","
Returns the length of an array."
"Functions (System)","ARRAY_CONTAINS","
ARRAY_CONTAINS(arrayExpression, value)
","
Returns true if the array contains the value."
"Functions (System)","AUTOCOMMIT","
AUTOCOMMIT()
","
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/testSimple.in.txt
浏览文件 @
024e80c3
...
...
@@ -16,6 +16,24 @@ select decode('3', 2.0, 2.0, 3, 3.0);
> 3.0;
select decode(4.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 9.0);
> 4.0;
select array_contains((4.0, 2.0, 2.0), 2.0);
> TRUE;
select array_contains((4.0, 2.0, 2.0), 5.0);
> FALSE;
select array_contains(('one', 'two'), 'one');
> TRUE;
select array_contains(('one', 'two'), 'xxx');
> FALSE;
select array_contains(('one', 'two'), null);
> FALSE;
select array_contains((null, 'two'), null);
> TRUE;
select array_contains(null, 'one');
> FALSE;
select array_contains(((1, 2), (3, 4)), (1, 2));
> TRUE;
select array_contains(((1, 2), (3, 4)), (5, 6));
> FALSE;
select * from (select group_concat(distinct 1) from system_range(1, 3));
> 1;
select sum(mod(x, 2) = 1) from system_range(1, 10);
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论