Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
4357cfdd
提交
4357cfdd
authored
12月 19, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Partially revert
99c866a3
and use parentheses instead
上级
41355dd0
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
42 行增加
和
18 行删除
+42
-18
Parser.java
h2/src/main/org/h2/command/Parser.java
+8
-12
Aggregate.java
h2/src/main/org/h2/expression/aggregate/Aggregate.java
+9
-0
Comparison.java
h2/src/main/org/h2/expression/condition/Comparison.java
+19
-0
any.sql
h2/src/test/org/h2/test/scripts/functions/aggregate/any.sql
+6
-6
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
4357cfdd
...
...
@@ -1405,22 +1405,18 @@ public class Parser {
return
prep
;
}
private
boolean
isSelect
Deep
()
{
private
boolean
isSelect
()
{
int
start
=
lastParseIndex
;
while
(
readIf
(
OPEN_PAREN
))
{
// need to read ahead, it could be a nested union:
// ((select 1) union (select 1))
}
boolean
select
=
is
Select
(
);
boolean
select
=
is
Token
(
SELECT
)
||
isToken
(
FROM
)
||
isToken
(
WITH
);
parseIndex
=
start
;
read
();
return
select
;
}
private
boolean
isSelect
()
{
return
isToken
(
SELECT
)
||
isToken
(
FROM
)
||
isToken
(
WITH
);
}
private
Prepared
parseMerge
()
{
int
start
=
lastParseIndex
;
read
(
"INTO"
);
...
...
@@ -1434,7 +1430,7 @@ public class Parser {
command
.
setTargetTableFilter
(
targetTableFilter
);
Table
table
=
command
.
getTargetTable
();
if
(
readIf
(
OPEN_PAREN
))
{
if
(
isSelect
Deep
())
{
if
(
isSelect
())
{
command
.
setQuery
(
parseSelect
());
read
(
CLOSE_PAREN
);
return
command
;
...
...
@@ -1464,7 +1460,7 @@ public class Parser {
if
(
readIf
(
OPEN_PAREN
))
{
/* a select query is supplied */
if
(
isSelect
Deep
())
{
if
(
isSelect
())
{
command
.
setQuery
(
parseSelect
());
read
(
CLOSE_PAREN
);
}
...
...
@@ -1619,7 +1615,7 @@ public class Parser {
private
Insert
parseInsertGivenTable
(
Insert
command
,
Table
table
)
{
Column
[]
columns
=
null
;
if
(
readIf
(
OPEN_PAREN
))
{
if
(
isSelect
Deep
())
{
if
(
isSelect
())
{
command
.
setQuery
(
parseSelect
());
read
(
CLOSE_PAREN
);
return
command
;
...
...
@@ -1672,7 +1668,7 @@ public class Parser {
Table
table
=
readTableOrView
();
command
.
setTable
(
table
);
if
(
readIf
(
OPEN_PAREN
))
{
if
(
isSelect
Deep
())
{
if
(
isSelect
())
{
command
.
setQuery
(
parseSelect
());
read
(
CLOSE_PAREN
);
return
command
;
...
...
@@ -1709,7 +1705,7 @@ public class Parser {
Table
table
;
String
alias
=
null
;
label:
if
(
readIf
(
OPEN_PAREN
))
{
if
(
isSelect
Deep
())
{
if
(
isSelect
())
{
Query
query
=
parseSelectUnion
();
read
(
CLOSE_PAREN
);
query
.
setParameterList
(
new
ArrayList
<>(
parameters
));
...
...
@@ -2825,7 +2821,7 @@ public class Parser {
}
r
=
ValueExpression
.
get
(
ValueBoolean
.
FALSE
);
}
else
{
if
(
isSelect
Deep
())
{
if
(
isSelect
())
{
Query
query
=
parseSelect
();
r
=
new
ConditionInSelect
(
database
,
r
,
query
,
false
,
Comparison
.
EQUAL
);
...
...
h2/src/main/org/h2/expression/aggregate/Aggregate.java
浏览文件 @
4357cfdd
...
...
@@ -266,6 +266,15 @@ public class Aggregate extends AbstractAggregate {
this
.
groupConcatSeparator
=
separator
;
}
/**
* Returns the type of this aggregate.
*
* @return the type of this aggregate
*/
public
AggregateType
getAggregateType
()
{
return
type
;
}
private
void
sortWithOrderBy
(
Value
[]
array
)
{
final
SortOrder
sortOrder
=
orderBySort
;
if
(
sortOrder
!=
null
)
{
...
...
h2/src/main/org/h2/expression/condition/Comparison.java
浏览文件 @
4357cfdd
...
...
@@ -14,6 +14,8 @@ import org.h2.expression.ExpressionColumn;
import
org.h2.expression.ExpressionVisitor
;
import
org.h2.expression.Parameter
;
import
org.h2.expression.ValueExpression
;
import
org.h2.expression.aggregate.Aggregate
;
import
org.h2.expression.aggregate.Aggregate.AggregateType
;
import
org.h2.index.IndexCondition
;
import
org.h2.message.DbException
;
import
org.h2.table.Column
;
...
...
@@ -130,6 +132,7 @@ public class Comparison extends Condition {
@Override
public
StringBuilder
getSQL
(
StringBuilder
builder
)
{
boolean
encloseRight
=
false
;
builder
.
append
(
'('
);
switch
(
compareType
)
{
case
IS_NULL:
...
...
@@ -143,9 +146,25 @@ public class Comparison extends Condition {
left
.
getSQL
(
builder
).
append
(
", "
);
right
.
getSQL
(
builder
).
append
(
')'
);
break
;
case
EQUAL:
case
BIGGER_EQUAL:
case
BIGGER:
case
SMALLER_EQUAL:
case
SMALLER:
case
NOT_EQUAL:
if
(
right
instanceof
Aggregate
&&
((
Aggregate
)
right
).
getAggregateType
()
==
AggregateType
.
ANY
)
{
encloseRight
=
true
;
}
//$FALL-THROUGH$
default
:
left
.
getSQL
(
builder
).
append
(
' '
).
append
(
getCompareOperator
(
compareType
)).
append
(
' '
);
if
(
encloseRight
)
{
builder
.
append
(
'('
);
}
right
.
getSQL
(
builder
);
if
(
encloseRight
)
{
builder
.
append
(
')'
);
}
}
return
builder
.
append
(
')'
);
}
...
...
h2/src/test/org/h2/test/scripts/functions/aggregate/any.sql
浏览文件 @
4357cfdd
...
...
@@ -20,14 +20,14 @@ SELECT A, ANY(B < 2), SOME(B > 3), BOOL_OR(B = 1), ANY(B = 1) FILTER (WHERE A =
DROP
TABLE
TEST
;
>
ok
SELECT
TRUE
=
ANY
((
SELECT
TRUE
));
>
TRUE
=
ANY
((
SELECT
TRUE
FROM
SYSTEM_RANGE
(
1
,
1
)
/* PUBLIC.RANGE_INDEX */
/* scanCount: 2 */
))
>
---------------------------------------------------------------------------------------------
SELECT
TRUE
=
(
ANY
((
SELECT
TRUE
)
));
>
TRUE
=
(
ANY
((
SELECT
TRUE
FROM
SYSTEM_RANGE
(
1
,
1
)
/* PUBLIC.RANGE_INDEX */
/* scanCount: 2 */
)
))
>
---------------------------------------------------------------------------------------------
--
>
TRUE
>
rows
:
1
SELECT
TRUE
=
ANY
((
SELECT
FALSE
));
>
TRUE
=
ANY
((
SELECT
FALSE
FROM
SYSTEM_RANGE
(
1
,
1
)
/* PUBLIC.RANGE_INDEX */
/* scanCount: 2 */
))
>
----------------------------------------------------------------------------------------------
SELECT
TRUE
=
(
ANY
((
SELECT
FALSE
)
));
>
TRUE
=
(
ANY
((
SELECT
FALSE
FROM
SYSTEM_RANGE
(
1
,
1
)
/* PUBLIC.RANGE_INDEX */
/* scanCount: 2 */
)
))
>
----------------------------------------------------------------------------------------------
--
>
FALSE
>
rows
:
1
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论