Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
c6933120
Unverified
提交
c6933120
authored
12月 21, 2018
作者:
Evgenij Ryazanov
提交者:
GitHub
12月 21, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1612 from katzyn/row
Improve javadoc, documentation, tests and some code for row values
上级
a22f1ea3
da7474a2
显示空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
45 行增加
和
42 行删除
+45
-42
help.csv
h2/src/docsrc/help/help.csv
+7
-3
changelog.html
h2/src/docsrc/html/changelog.html
+2
-0
Database.java
h2/src/main/org/h2/engine/Database.java
+1
-4
Function.java
h2/src/main/org/h2/expression/function/Function.java
+4
-7
TableFunction.java
h2/src/main/org/h2/expression/function/TableFunction.java
+6
-3
ValueArray.java
h2/src/main/org/h2/value/ValueArray.java
+0
-4
ValueCollectionBase.java
h2/src/main/org/h2/value/ValueCollectionBase.java
+5
-1
ValueRow.java
h2/src/main/org/h2/value/ValueRow.java
+0
-4
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+1
-1
TestMetaData.java
h2/src/test/org/h2/test/jdbc/TestMetaData.java
+1
-1
array-contains.sql
...t/org/h2/test/scripts/functions/system/array-contains.sql
+9
-9
table.sql
h2/src/test/org/h2/test/scripts/functions/system/table.sql
+3
-0
testScript.sql
h2/src/test/org/h2/test/scripts/testScript.sql
+3
-3
TestKeywords.java
h2/src/test/org/h2/test/unit/TestKeywords.java
+2
-1
dictionary.txt
h2/src/tools/org/h2/build/doc/dictionary.txt
+1
-1
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
c6933120
...
...
@@ -2542,11 +2542,13 @@ START WITH 1
"Other Grammar","Set clause list","
{ { columnName = { DEFAULT | expression } } [,...] }
| { ( columnName [,...] ) =
( select )
}
| { ( columnName [,...] ) =
{rowValueExpression|(select)}
}
","
List of SET clauses.
","
NAME = 'Test', VALUE = 2
(A, B) = (1, 2)
(A, B) = (SELECT X, Y FROM OTHER T2 WHERE T1.ID = T2.ID)
"
"Other Grammar","String","
...
...
@@ -5211,11 +5213,13 @@ SELECT X, SET(@I, IFNULL(@I, 0)+X) RUNNING_TOTAL FROM SYSTEM_RANGE(1, 10)
"
"Functions (System)","TABLE","
{ TABLE | TABLE_DISTINCT } ( { name dataType = expression } [,...] )
{ TABLE | TABLE_DISTINCT }
( { name dataType = array|rowValueExpression } [,...] )
","
Returns the result set. TABLE_DISTINCT removes duplicate rows.
","
SELECT * FROM TABLE(ID INT=(1, 2), NAME VARCHAR=('Hello', 'World'))
SELECT * FROM TABLE(VALUE INT = ARRAY[1, 2]);
SELECT * FROM TABLE(ID INT=(1, 2), NAME VARCHAR=('Hello', 'World'));
"
"Functions (System)","TRANSACTION_ID","
...
...
h2/src/docsrc/html/changelog.html
浏览文件 @
c6933120
...
...
@@ -21,6 +21,8 @@ Change Log
<h2>
Next Version (unreleased)
</h2>
<ul>
<li>
Issue #1608: ARRAY and row value expression should not be the same
</li>
<li>
Issue #1606: Quantified comparison predicate doesn't work correctly on primary key column
</li>
<li>
Issue #1057: Very slow execution with subquery and connection parameter LAZY_QUERY_EXECUTION=1
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
c6933120
...
...
@@ -428,12 +428,9 @@ public class Database implements DataHandler {
* Compare two values with the current comparison mode. The values may have
* different data types including NULL.
*
* @param v the other value
* @param databaseMode the database mode
* @param compareMode the compare mode
* @param a the first value
* @param b the second value
* @param forEquality perform only check for equality (= or
<>
)
* @param forEquality perform only check for equality (= or
<>
)
* @return 0 if both values are equal, -1 if the first value is smaller, 1
* if the second value is larger, {@link Integer#MIN_VALUE} if order
* is not defined due to NULL comparison
...
...
h2/src/main/org/h2/expression/function/Function.java
浏览文件 @
c6933120
...
...
@@ -61,16 +61,15 @@ import org.h2.util.Utils;
import
org.h2.value.DataType
;
import
org.h2.value.ExtTypeInfo
;
import
org.h2.value.Value
;
import
org.h2.value.ValueArray
;
import
org.h2.value.ValueBoolean
;
import
org.h2.value.ValueBytes
;
import
org.h2.value.ValueCollectionBase
;
import
org.h2.value.ValueDate
;
import
org.h2.value.ValueDouble
;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueLong
;
import
org.h2.value.ValueNull
;
import
org.h2.value.ValueResultSet
;
import
org.h2.value.ValueRow
;
import
org.h2.value.ValueString
;
import
org.h2.value.ValueTime
;
import
org.h2.value.ValueTimestamp
;
...
...
@@ -1092,13 +1091,11 @@ public class Function extends Expression implements FunctionCall {
return
result
;
}
private
Value
[]
getArray
(
Value
v0
)
{
private
static
Value
[]
getArray
(
Value
v0
)
{
int
t
=
v0
.
getType
();
Value
[]
list
;
if
(
t
==
Value
.
ARRAY
)
{
list
=
((
ValueArray
)
v0
).
getList
();
}
else
if
(
t
==
Value
.
ROW
)
{
list
=
((
ValueRow
)
v0
).
getList
();
if
(
t
==
Value
.
ARRAY
||
t
==
Value
.
ROW
)
{
list
=
((
ValueCollectionBase
)
v0
).
getList
();
}
else
{
list
=
null
;
}
...
...
h2/src/main/org/h2/expression/function/TableFunction.java
浏览文件 @
c6933120
...
...
@@ -16,7 +16,7 @@ import org.h2.message.DbException;
import
org.h2.result.LocalResult
;
import
org.h2.table.Column
;
import
org.h2.value.Value
;
import
org.h2.value.Value
Array
;
import
org.h2.value.Value
CollectionBase
;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueNull
;
import
org.h2.value.ValueResultSet
;
...
...
@@ -105,8 +105,11 @@ public class TableFunction extends Function {
if
(
v
==
ValueNull
.
INSTANCE
)
{
list
[
i
]
=
new
Value
[
0
];
}
else
{
ValueArray
array
=
(
ValueArray
)
v
.
convertTo
(
Value
.
ARRAY
);
Value
[]
l
=
array
.
getList
();
int
type
=
v
.
getType
();
if
(
type
!=
Value
.
ARRAY
&&
type
!=
Value
.
ROW
)
{
v
=
v
.
convertTo
(
Value
.
ARRAY
);
}
Value
[]
l
=
((
ValueCollectionBase
)
v
).
getList
();
list
[
i
]
=
l
;
rows
=
Math
.
max
(
rows
,
l
.
length
);
}
...
...
h2/src/main/org/h2/value/ValueArray.java
浏览文件 @
c6933120
...
...
@@ -61,10 +61,6 @@ public class ValueArray extends ValueCollectionBase {
return
(
ValueArray
)
EMPTY
;
}
public
Value
[]
getList
()
{
return
values
;
}
@Override
public
int
getType
()
{
return
Value
.
ARRAY
;
...
...
h2/src/main/org/h2/value/ValueCollectionBase.java
浏览文件 @
c6933120
...
...
@@ -14,7 +14,7 @@ import org.h2.util.MathUtils;
/**
* Base class for ARRAY and ROW values.
*/
abstract
class
ValueCollectionBase
extends
Value
{
public
abstract
class
ValueCollectionBase
extends
Value
{
final
Value
[]
values
;
...
...
@@ -24,6 +24,10 @@ abstract class ValueCollectionBase extends Value {
this
.
values
=
values
;
}
public
Value
[]
getList
()
{
return
values
;
}
@Override
public
int
hashCode
()
{
if
(
hash
!=
0
)
{
...
...
h2/src/main/org/h2/value/ValueRow.java
浏览文件 @
c6933120
...
...
@@ -47,10 +47,6 @@ public class ValueRow extends ValueCollectionBase {
return
(
ValueRow
)
EMPTY
;
}
public
Value
[]
getList
()
{
return
values
;
}
@Override
public
int
getType
()
{
return
Value
.
ROW
;
...
...
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
c6933120
...
...
@@ -440,7 +440,7 @@ public class TestFunctions extends TestDb implements AggregateFunction {
stat
.
execute
(
"create alias dynamic deterministic for \""
+
getClass
().
getName
()
+
".dynamic\""
);
setCount
(
0
);
rs
=
stat
.
executeQuery
(
"call dynamic(
('a', 1)
)[1]"
);
rs
=
stat
.
executeQuery
(
"call dynamic(
ARRAY['a', 1]
)[1]"
);
rs
.
next
();
String
a
=
rs
.
getString
(
1
);
assertEquals
(
"a1"
,
a
);
...
...
h2/src/test/org/h2/test/jdbc/TestMetaData.java
浏览文件 @
c6933120
...
...
@@ -176,7 +176,7 @@ public class TestMetaData extends TestDb {
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table a(x array)"
);
stat
.
execute
(
"insert into a values(
(1, 2)
)"
);
stat
.
execute
(
"insert into a values(
ARRAY[1, 2]
)"
);
rs
=
stat
.
executeQuery
(
"SELECT x[1] FROM a"
);
ResultSetMetaData
rsMeta
=
rs
.
getMetaData
();
assertEquals
(
Types
.
NULL
,
rsMeta
.
getColumnType
(
1
));
...
...
h2/src/test/org/h2/test/scripts/functions/system/array-contains.sql
浏览文件 @
c6933120
...
...
@@ -3,37 +3,37 @@
-- Initial Developer: H2 Group
--
select
array_contains
(
(
4
.
0
,
2
.
0
,
2
.
0
)
,
2
.
0
);
select
array_contains
(
ARRAY
[
4
.
0
,
2
.
0
,
2
.
0
]
,
2
.
0
);
>>
TRUE
select
array_contains
(
(
4
.
0
,
2
.
0
,
2
.
0
)
,
5
.
0
);
select
array_contains
(
ARRAY
[
4
.
0
,
2
.
0
,
2
.
0
]
,
5
.
0
);
>>
FALSE
select
array_contains
(
(
'one'
,
'two'
)
,
'one'
);
select
array_contains
(
ARRAY
[
'one'
,
'two'
]
,
'one'
);
>>
TRUE
select
array_contains
(
(
'one'
,
'two'
)
,
'xxx'
);
select
array_contains
(
ARRAY
[
'one'
,
'two'
]
,
'xxx'
);
>>
FALSE
select
array_contains
(
(
'one'
,
'two'
)
,
null
);
select
array_contains
(
ARRAY
[
'one'
,
'two'
]
,
null
);
>>
FALSE
select
array_contains
(
(
null
,
'two'
)
,
null
);
select
array_contains
(
ARRAY
[
null
,
'two'
]
,
null
);
>>
TRUE
select
array_contains
(
null
,
'one'
);
>>
null
select
array_contains
(
((
1
,
2
),
(
3
,
4
)),
(
1
,
2
)
);
select
array_contains
(
ARRAY
[
ARRAY
[
1
,
2
],
ARRAY
[
3
,
4
]],
ARRAY
[
1
,
2
]
);
>>
TRUE
select
array_contains
(
((
1
,
2
),
(
3
,
4
)),
(
5
,
6
)
);
select
array_contains
(
ARRAY
[
ARRAY
[
1
,
2
],
ARRAY
[
3
,
4
]],
ARRAY
[
5
,
6
]
);
>>
FALSE
CREATE
TABLE
TEST
(
ID
INT
PRIMARY
KEY
AUTO_INCREMENT
,
A
ARRAY
);
>
ok
INSERT
INTO
TEST
(
A
)
VALUES
(
(
1
L
,
2
L
)),
((
3
L
,
4
L
)
);
INSERT
INTO
TEST
(
A
)
VALUES
(
ARRAY
[
1
L
,
2
L
]),
(
ARRAY
[
3
L
,
4
L
]
);
>
update
count
:
2
SELECT
ID
,
ARRAY_CONTAINS
(
A
,
1
L
),
ARRAY_CONTAINS
(
A
,
2
L
),
ARRAY_CONTAINS
(
A
,
3
L
),
ARRAY_CONTAINS
(
A
,
4
L
)
FROM
TEST
;
...
...
h2/src/test/org/h2/test/scripts/functions/system/table.sql
浏览文件 @
c6933120
...
...
@@ -34,6 +34,9 @@ drop table test;
explain
select
*
from
table
(
id
int
=
(
1
,
2
),
name
varchar
=
(
'Hello'
,
'World'
));
>>
SELECT
TABLE
.
ID
,
TABLE
.
NAME
FROM
TABLE
(
ID
INT
=
ROW
(
1
,
2
),
NAME
VARCHAR
=
ROW
(
'Hello'
,
'World'
))
/* function */
explain
select
*
from
table
(
id
int
=
ARRAY
[
1
,
2
],
name
varchar
=
ARRAY
[
'Hello'
,
'World'
]);
>>
SELECT
TABLE
.
ID
,
TABLE
.
NAME
FROM
TABLE
(
ID
INT
=
ARRAY
[
1
,
2
],
NAME
VARCHAR
=
ARRAY
[
'Hello'
,
'World'
])
/* function */
select
*
from
table
(
id
int
=
(
1
,
2
),
name
varchar
=
(
'Hello'
,
'World'
))
x
order
by
id
;
>
ID
NAME
>
-- -----
...
...
h2/src/test/org/h2/test/scripts/testScript.sql
浏览文件 @
c6933120
...
...
@@ -1395,7 +1395,7 @@ drop table test;
create table test(id int primary key, data array);
> ok
insert into test values(1,
(1, 1)), (2, (1, 2)), (3, (1, 1, 1)
);
insert into test values(1,
ARRAY[1, 1]), (2, ARRAY[1, 2]), (3, ARRAY[1, 1, 1]
);
> update count: 3
select * from test order by data;
...
...
@@ -2011,10 +2011,10 @@ select (1, 2);
create table array_test(x array);
> ok
insert into array_test values(
(1, 2, 3)), ((2, 3, 4)
);
insert into array_test values(
ARRAY[1, 2, 3]), (ARRAY[2, 3, 4]
);
> update count: 2
select * from array_test where x =
(1, 2, 3)
;
select * from array_test where x =
ARRAY[1, 2, 3]
;
> X
> ---------
> [1, 2, 3]
...
...
h2/src/test/org/h2/test/unit/TestKeywords.java
浏览文件 @
c6933120
...
...
@@ -41,7 +41,8 @@ public class TestKeywords extends TestBase {
ClassReader
r
=
new
ClassReader
(
Parser
.
class
.
getResourceAsStream
(
"Parser.class"
));
r
.
accept
(
new
ClassVisitor
(
Opcodes
.
ASM6
)
{
@Override
public
FieldVisitor
visitField
(
int
access
,
String
name
,
String
descriptor
,
String
signature
,
Object
value
)
{
public
FieldVisitor
visitField
(
int
access
,
String
name
,
String
descriptor
,
String
signature
,
Object
value
)
{
add
(
set
,
value
);
return
null
;
}
...
...
h2/src/tools/org/h2/build/doc/dictionary.txt
浏览文件 @
c6933120
...
...
@@ -804,4 +804,4 @@ qualification opportunity jumping exploited unacceptable vrs duplicated
queryparser tokenized freeze factorings recompilation unenclosed rfe dsync
econd irst bcef ordinality nord unnest
analyst occupation distributive josaph aor engineer sajeewa isuru randil kevin doctor businessman artist ashan
corrupts splitted disruption unintentional octets preconditions predicates subq
corrupts splitted disruption unintentional octets preconditions predicates subq
objectweb insn opcodes
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论