Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
6e8f8506
提交
6e8f8506
authored
2月 27, 2011
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Array literals with zero or one element were not be parsed correctly.
上级
d2353456
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
60 行增加
和
15 行删除
+60
-15
help.csv
h2/src/docsrc/help/help.csv
+5
-2
changelog.html
h2/src/docsrc/html/changelog.html
+4
-1
roadmap.html
h2/src/docsrc/html/roadmap.html
+1
-0
Parser.java
h2/src/main/org/h2/command/Parser.java
+20
-11
ExpressionList.java
h2/src/main/org/h2/expression/ExpressionList.java
+5
-0
ValueArray.java
h2/src/main/org/h2/value/ValueArray.java
+7
-1
test-1.3.txt
h2/src/test/org/h2/test/test-1.3.txt
+18
-0
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
6e8f8506
...
...
@@ -1506,11 +1506,14 @@ ID=1 AND NAME='Hi'
"
"Other Grammar","Array","
(
expression [,...
] )
(
[ expression, [ expression [,...] ]
] )
","
An array of values.
An array of values. An empty array is '()'. Trailing commas are ignored.
An array with one element must contain a comma to be parsed as an array.
","
(1, 2)
(1, )
()
"
"Other Grammar","Boolean","
...
...
h2/src/docsrc/html/changelog.html
浏览文件 @
6e8f8506
...
...
@@ -18,7 +18,10 @@ Change Log
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
Issue 290: Conditions using subqueries were sometimes evaluated before much simpler conditions,
<ul><li>
Array literals with zero or one element were not be parsed correctly.
Now trailing commas are ignored (as in Java). Expressions of the form '(1)' are still parsed as the value 1.
An empty array is '()'. An array with one element must contain a comma to be parsed as an array, as in '(1,)'.
</li><li>
Issue 290: Conditions using subqueries were sometimes evaluated before much simpler conditions,
which was very bad for performance. This includes subqueries returning a value, EXISTS subqueries,
and IN(SELECT ..) subqueries.
</li><li>
Issue 288: Some queries with right outer joins or nested joins could throw a NullPointerException.
...
...
h2/src/docsrc/html/roadmap.html
浏览文件 @
6e8f8506
...
...
@@ -561,6 +561,7 @@ See also <a href="build.html#providing_patches">Providing Patches</a>.
</li><li>
Optimization for large lists for column IN(1, 2, 3, 4,...) - currently an list is used, could potentially use a hash set
(maybe only for a part of the values - the ones that can be evaluated).
</li><li>
Compatibility for ARRAY data type (Oracle: VARRAY(n) of VARCHAR(m); HSQLDB: VARCHAR(n) ARRAY; Postgres: VARCHAR(n)[]).
</li><li>
PostgreSQL compatible array literal syntax: ARRAY[['breakfast', 'consulting'], ['meeting', 'lunch']]
</li></ul>
<h2>
Not Planned
</h2>
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
6e8f8506
...
...
@@ -2482,19 +2482,28 @@ public class Parser {
break
;
case
OPEN:
read
();
r
=
readExpression
();
if
(
readIf
(
","
))
{
ArrayList
<
Expression
>
list
=
New
.
arrayList
();
list
.
add
(
r
);
do
{
r
=
readExpression
();
if
(
readIf
(
")"
))
{
r
=
ExpressionList
.
EMPTY
;
}
else
{
r
=
readExpression
(
);
if
(
readIf
(
","
))
{
ArrayList
<
Expression
>
list
=
New
.
arrayList
();
list
.
add
(
r
);
}
while
(
readIf
(
","
));
Expression
[]
array
=
new
Expression
[
list
.
size
()];
list
.
toArray
(
array
);
r
=
new
ExpressionList
(
array
);
while
(!
readIf
(
")"
))
{
r
=
readExpression
();
list
.
add
(
r
);
if
(!
readIf
(
","
))
{
read
(
")"
);
break
;
}
}
Expression
[]
array
=
new
Expression
[
list
.
size
()];
list
.
toArray
(
array
);
r
=
new
ExpressionList
(
array
);
}
else
{
read
(
")"
);
}
}
read
(
")"
);
break
;
case
TRUE:
read
();
...
...
h2/src/main/org/h2/expression/ExpressionList.java
浏览文件 @
6e8f8506
...
...
@@ -20,6 +20,8 @@ import org.h2.value.ValueArray;
*/
public
class
ExpressionList
extends
Expression
{
public
static
final
ExpressionList
EMPTY
=
new
ExpressionList
(
new
Expression
[
0
]);
private
Expression
[]
list
;
public
ExpressionList
(
Expression
[]
list
)
{
...
...
@@ -83,6 +85,9 @@ public class ExpressionList extends Expression {
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
e
.
getSQL
());
}
if
(
list
.
length
==
1
)
{
buff
.
append
(
','
);
}
return
buff
.
append
(
')'
).
toString
();
}
...
...
h2/src/main/org/h2/value/ValueArray.java
浏览文件 @
6e8f8506
...
...
@@ -15,6 +15,9 @@ import org.h2.util.StatementBuilder;
* Implementation of the ARRAY data type.
*/
public
class
ValueArray
extends
Value
{
private
static
final
ValueArray
EMPTY
=
new
ValueArray
(
new
Value
[
0
]);
private
final
Value
[]
values
;
private
int
hash
;
...
...
@@ -30,7 +33,7 @@ public class ValueArray extends Value {
* @return the value
*/
public
static
ValueArray
get
(
Value
[]
list
)
{
return
new
ValueArray
(
list
);
return
list
.
length
==
0
?
EMPTY
:
new
ValueArray
(
list
);
}
public
int
hashCode
()
{
...
...
@@ -104,6 +107,9 @@ public class ValueArray extends Value {
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
v
.
getSQL
());
}
if
(
values
.
length
==
1
)
{
buff
.
append
(
','
);
}
return
buff
.
append
(
')'
).
toString
();
}
...
...
h2/src/test/org/h2/test/test-1.3.txt
浏览文件 @
6e8f8506
--- special grammar and test cases ---------------------------------------------------------------------------------------------
select () empty;
> EMPTY
> -----
> ()
> rows: 1
select (1,) one_element;
> ONE_ELEMENT
> -----------
> (1)
> rows: 1
select (1) one;
> ONE
> ---
> 1
> rows: 1
create table test(id int);
> ok
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论