Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
245aa770
提交
245aa770
authored
6 年前
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Return Value from Comparison.compareNotNull()
上级
eeace0e1
master
version-1.4.198
无相关合并请求
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
52 行增加
和
51 行删除
+52
-51
Comparison.java
h2/src/main/org/h2/expression/condition/Comparison.java
+4
-6
ConditionIn.java
h2/src/main/org/h2/expression/condition/ConditionIn.java
+7
-9
ConditionInParameter.java
...ain/org/h2/expression/condition/ConditionInParameter.java
+12
-15
ConditionInSelect.java
...c/main/org/h2/expression/condition/ConditionInSelect.java
+29
-21
没有找到文件。
h2/src/main/org/h2/expression/condition/Comparison.java
浏览文件 @
245aa770
...
...
@@ -294,7 +294,7 @@ public class Comparison extends Condition {
return
ValueNull
.
INSTANCE
;
}
}
return
ValueBoolean
.
get
(
compareNotNull
(
database
,
l
,
r
,
compareType
)
);
return
compareNotNull
(
database
,
l
,
r
,
compareType
);
}
/**
...
...
@@ -304,11 +304,9 @@ public class Comparison extends Condition {
* @param l the first value
* @param r the second value
* @param compareType the compare type
* @return true if the comparison indicated by the comparison type evaluates
* to true
* @return result of comparison, either TRUE, FALSE, or NULL
*/
static
boolean
compareNotNull
(
Database
database
,
Value
l
,
Value
r
,
int
compareType
)
{
static
Value
compareNotNull
(
Database
database
,
Value
l
,
Value
r
,
int
compareType
)
{
boolean
result
;
switch
(
compareType
)
{
case
EQUAL:
...
...
@@ -340,7 +338,7 @@ public class Comparison extends Condition {
default
:
throw
DbException
.
throwInternalError
(
"type="
+
compareType
);
}
return
result
;
return
ValueBoolean
.
get
(
result
)
;
}
private
int
getReversedCompareType
(
int
type
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/condition/ConditionIn.java
浏览文件 @
245aa770
...
...
@@ -59,24 +59,22 @@ public class ConditionIn extends Condition {
return
ConditionInParameter
.
getValue
(
database
,
l
,
e
.
getValue
(
session
));
}
}
boolean
result
=
false
;
boolean
hasNull
=
false
;
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
Expression
e
=
valueList
.
get
(
i
);
Value
r
=
e
.
getValue
(
session
);
if
(
r
==
ValueNull
.
INSTANCE
)
{
Value
cmp
;
if
(
r
==
ValueNull
.
INSTANCE
||
(
cmp
=
Comparison
.
compareNotNull
(
database
,
l
,
r
,
Comparison
.
EQUAL
))
==
ValueNull
.
INSTANCE
)
{
hasNull
=
true
;
}
else
{
result
=
Comparison
.
compareNotNull
(
database
,
l
,
r
,
Comparison
.
EQUAL
);
if
(
result
)
{
break
;
}
else
if
(
cmp
==
ValueBoolean
.
TRUE
)
{
return
cmp
;
}
}
}
if
(!
result
&&
hasNull
)
{
if
(
hasNull
)
{
return
ValueNull
.
INSTANCE
;
}
return
ValueBoolean
.
get
(
result
)
;
return
ValueBoolean
.
FALSE
;
}
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/condition/ConditionInParameter.java
浏览文件 @
245aa770
...
...
@@ -66,38 +66,35 @@ public class ConditionInParameter extends Condition {
private
final
Parameter
parameter
;
static
Value
getValue
(
Database
database
,
Value
l
,
Value
value
)
{
boolean
result
=
false
;
boolean
hasNull
=
false
;
if
(
value
==
ValueNull
.
INSTANCE
)
{
hasNull
=
true
;
}
else
if
(
value
.
getType
()
==
Value
.
RESULT_SET
)
{
for
(
ResultInterface
ri
=
value
.
getResult
();
ri
.
next
();)
{
Value
r
=
ri
.
currentRow
()[
0
];
if
(
r
==
ValueNull
.
INSTANCE
)
{
Value
cmp
;
if
(
r
==
ValueNull
.
INSTANCE
||
(
cmp
=
Comparison
.
compareNotNull
(
database
,
l
,
r
,
Comparison
.
EQUAL
))
==
ValueNull
.
INSTANCE
)
{
hasNull
=
true
;
}
else
{
result
=
Comparison
.
compareNotNull
(
database
,
l
,
r
,
Comparison
.
EQUAL
);
if
(
result
)
{
break
;
}
}
else
if
(
cmp
==
ValueBoolean
.
TRUE
)
{
return
cmp
;
}
}
}
else
{
for
(
Value
r
:
((
ValueArray
)
value
.
convertTo
(
Value
.
ARRAY
)).
getList
())
{
if
(
r
==
ValueNull
.
INSTANCE
)
{
Value
cmp
;
if
(
r
==
ValueNull
.
INSTANCE
||
(
cmp
=
Comparison
.
compareNotNull
(
database
,
l
,
r
,
Comparison
.
EQUAL
))
==
ValueNull
.
INSTANCE
)
{
hasNull
=
true
;
}
else
{
result
=
Comparison
.
compareNotNull
(
database
,
l
,
r
,
Comparison
.
EQUAL
);
if
(
result
)
{
break
;
}
}
else
if
(
cmp
==
ValueBoolean
.
TRUE
)
{
return
cmp
;
}
}
}
if
(
!
result
&&
hasNull
)
{
if
(
hasNull
)
{
return
ValueNull
.
INSTANCE
;
}
return
ValueBoolean
.
get
(
result
)
;
return
ValueBoolean
.
FALSE
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/condition/ConditionInSelect.java
浏览文件 @
245aa770
...
...
@@ -21,6 +21,7 @@ import org.h2.value.Value;
import
org.h2.value.ValueArray
;
import
org.h2.value.ValueBoolean
;
import
org.h2.value.ValueNull
;
import
org.h2.value.ValueRow
;
/**
* An 'in' condition with a subquery, as in WHERE ID IN(SELECT ...)
...
...
@@ -88,30 +89,37 @@ public class ConditionInSelect extends Condition {
private
Value
getValueSlow
(
ResultInterface
rows
,
Value
l
)
{
// this only returns the correct result if the result has at least one
// row, and if l is not null
if
(
all
)
{
while
(
rows
.
next
())
{
Value
[]
currentRow
=
rows
.
currentRow
();
Value
r
=
query
.
getColumnCount
()
==
1
?
currentRow
[
0
]
:
ValueRow
.
get
(
currentRow
);
Value
cmp
;
if
(
r
==
ValueNull
.
INSTANCE
||
(
cmp
=
Comparison
.
compareNotNull
(
database
,
l
,
r
,
compareType
))
==
ValueNull
.
INSTANCE
)
{
return
ValueNull
.
INSTANCE
;
}
else
if
(
cmp
==
ValueBoolean
.
FALSE
)
{
return
cmp
;
}
}
return
ValueBoolean
.
TRUE
;
}
else
{
boolean
hasNull
=
false
;
boolean
result
=
all
;
while
(
rows
.
next
())
{
boolean
value
;
Value
[]
currentRow
=
rows
.
currentRow
();
Value
r
=
query
.
getColumnCount
()
==
1
?
currentRow
[
0
]
:
org
.
h2
.
value
.
ValueArray
.
get
(
currentRow
);
if
(
r
==
ValueNull
.
INSTANCE
)
{
value
=
false
;
Value
r
=
query
.
getColumnCount
()
==
1
?
currentRow
[
0
]
:
ValueRow
.
get
(
currentRow
);
Value
cmp
;
if
(
r
==
ValueNull
.
INSTANCE
||
(
cmp
=
Comparison
.
compareNotNull
(
database
,
l
,
r
,
compareType
))
==
ValueNull
.
INSTANCE
)
{
hasNull
=
true
;
}
else
{
value
=
Comparison
.
compareNotNull
(
database
,
l
,
r
,
compareType
)
;
}
else
if
(
cmp
==
ValueBoolean
.
TRUE
)
{
return
cmp
;
}
if
(!
value
&&
all
)
{
result
=
false
;
break
;
}
else
if
(
value
&&
!
all
)
{
result
=
true
;
break
;
}
}
if
(!
result
&&
hasNull
)
{
if
(
hasNull
)
{
return
ValueNull
.
INSTANCE
;
}
return
ValueBoolean
.
get
(
result
);
return
ValueBoolean
.
FALSE
;
}
}
@Override
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论