Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
a585517a
提交
a585517a
authored
8月 26, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve test coverage, remove unnecessary code.
上级
33cf7b9d
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
19 行增加
和
8 行删除
+19
-8
ConditionIn.java
h2/src/main/org/h2/expression/ConditionIn.java
+8
-6
TestOptimizations.java
h2/src/test/org/h2/test/db/TestOptimizations.java
+11
-2
没有找到文件。
h2/src/main/org/h2/expression/ConditionIn.java
浏览文件 @
a585517a
...
@@ -37,6 +37,13 @@ public class ConditionIn extends Condition {
...
@@ -37,6 +37,13 @@ public class ConditionIn extends Condition {
private
Value
min
,
max
;
private
Value
min
,
max
;
private
int
queryLevel
;
private
int
queryLevel
;
/**
* Create a new IN(..) condition.
*
* @param database the database
* @param left the expression before IN
* @param values the value list (at least one element)
*/
public
ConditionIn
(
Database
database
,
Expression
left
,
ObjectArray
<
Expression
>
values
)
{
public
ConditionIn
(
Database
database
,
Expression
left
,
ObjectArray
<
Expression
>
values
)
{
this
.
database
=
database
;
this
.
database
=
database
;
this
.
left
=
left
;
this
.
left
=
left
;
...
@@ -45,9 +52,6 @@ public class ConditionIn extends Condition {
...
@@ -45,9 +52,6 @@ public class ConditionIn extends Condition {
public
Value
getValue
(
Session
session
)
throws
SQLException
{
public
Value
getValue
(
Session
session
)
throws
SQLException
{
Value
l
=
left
.
getValue
(
session
);
Value
l
=
left
.
getValue
(
session
);
if
(
valueList
.
size
()
==
0
)
{
return
ValueBoolean
.
get
(
false
);
}
if
(
l
==
ValueNull
.
INSTANCE
)
{
if
(
l
==
ValueNull
.
INSTANCE
)
{
return
l
;
return
l
;
}
}
...
@@ -80,9 +84,6 @@ public class ConditionIn extends Condition {
...
@@ -80,9 +84,6 @@ public class ConditionIn extends Condition {
}
}
public
Expression
optimize
(
Session
session
)
throws
SQLException
{
public
Expression
optimize
(
Session
session
)
throws
SQLException
{
if
(
valueList
.
size
()
==
0
)
{
return
ValueExpression
.
get
(
ValueBoolean
.
get
(
false
));
}
left
=
left
.
optimize
(
session
);
left
=
left
.
optimize
(
session
);
boolean
constant
=
left
.
isConstant
();
boolean
constant
=
left
.
isConstant
();
if
(
constant
&&
left
==
ValueExpression
.
getNull
())
{
if
(
constant
&&
left
==
ValueExpression
.
getNull
())
{
...
@@ -152,6 +153,7 @@ public class ConditionIn extends Condition {
...
@@ -152,6 +153,7 @@ public class ConditionIn extends Condition {
}
}
}
}
filter
.
addIndexCondition
(
IndexCondition
.
getInList
(
l
,
valueList
));
filter
.
addIndexCondition
(
IndexCondition
.
getInList
(
l
,
valueList
));
return
;
}
}
if
(!
SysProperties
.
OPTIMIZE_IN
)
{
if
(!
SysProperties
.
OPTIMIZE_IN
)
{
return
;
return
;
...
...
h2/src/test/org/h2/test/db/TestOptimizations.java
浏览文件 @
a585517a
...
@@ -460,11 +460,20 @@ public class TestOptimizations extends TestBase {
...
@@ -460,11 +460,20 @@ public class TestOptimizations extends TestBase {
deleteDb
(
"optimizations"
);
deleteDb
(
"optimizations"
);
Connection
conn
=
getConnection
(
"optimizations"
);
Connection
conn
=
getConnection
(
"optimizations"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
PreparedStatement
prep
;
ResultSet
rs
;
assertFalse
(
stat
.
executeQuery
(
"select * from dual where x in()"
).
next
());
assertFalse
(
stat
.
executeQuery
(
"select * from dual where null in(1)"
).
next
());
assertFalse
(
stat
.
executeQuery
(
"select * from dual where null in(null)"
).
next
());
assertFalse
(
stat
.
executeQuery
(
"select * from dual where null in(null, 1)"
).
next
());
assertFalse
(
stat
.
executeQuery
(
"select * from dual where 1+x in(3, 4)"
).
next
());
assertFalse
(
stat
.
executeQuery
(
"select * from dual d1, dual d2 where d1.x in(3, 4)"
).
next
());
stat
.
execute
(
"create table test(id int primary key, name varchar)"
);
stat
.
execute
(
"create table test(id int primary key, name varchar)"
);
stat
.
execute
(
"insert into test values(1, 'Hello')"
);
stat
.
execute
(
"insert into test values(1, 'Hello')"
);
stat
.
execute
(
"insert into test values(2, 'World')"
);
stat
.
execute
(
"insert into test values(2, 'World')"
);
PreparedStatement
prep
;
ResultSet
rs
;
prep
=
conn
.
prepareStatement
(
"select * from test t1 where t1.id in(?)"
);
prep
=
conn
.
prepareStatement
(
"select * from test t1 where t1.id in(?)"
);
prep
.
setInt
(
1
,
1
);
prep
.
setInt
(
1
,
1
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论