Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
254d695b
Unverified
提交
254d695b
authored
3月 18, 2018
作者:
Noel Grandin
提交者:
GitHub
3月 18, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #987 from katzyn/misc
ValueBoolean constants are not cleared and may be used directly
上级
58969d77
c59e4336
显示空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
42 行增加
和
31 行删除
+42
-31
Parser.java
h2/src/main/org/h2/command/Parser.java
+4
-4
ConditionAndOr.java
h2/src/main/org/h2/expression/ConditionAndOr.java
+2
-2
ConditionInSelect.java
h2/src/main/org/h2/expression/ConditionInSelect.java
+3
-3
ExpressionColumn.java
h2/src/main/org/h2/expression/ExpressionColumn.java
+2
-2
Function.java
h2/src/main/org/h2/expression/Function.java
+2
-2
Parameter.java
h2/src/main/org/h2/expression/Parameter.java
+1
-1
ValueExpression.java
h2/src/main/org/h2/expression/ValueExpression.java
+1
-1
ValueDataType.java
h2/src/main/org/h2/mvstore/db/ValueDataType.java
+2
-2
Data.java
h2/src/main/org/h2/store/Data.java
+2
-2
Value.java
h2/src/main/org/h2/value/Value.java
+2
-2
ValueBoolean.java
h2/src/main/org/h2/value/ValueBoolean.java
+9
-5
TestClearReferences.java
h2/src/test/org/h2/test/unit/TestClearReferences.java
+8
-1
TestDataPage.java
h2/src/test/org/h2/test/unit/TestDataPage.java
+3
-3
TestValueMemory.java
h2/src/test/org/h2/test/unit/TestValueMemory.java
+1
-1
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
254d695b
...
...
@@ -2435,7 +2435,7 @@ public class Parser {
if
(
database
.
getMode
().
prohibitEmptyInPredicate
)
{
throw
getSyntaxError
();
}
r
=
ValueExpression
.
get
(
ValueBoolean
.
get
(
false
)
);
r
=
ValueExpression
.
get
(
ValueBoolean
.
FALSE
);
}
else
{
if
(
isSelect
())
{
Query
query
=
parseSelect
();
...
...
@@ -2525,7 +2525,7 @@ public class Parser {
}
else
{
rightFilter
.
mapAndAddFilter
(
r
);
}
r
=
ValueExpression
.
get
(
ValueBoolean
.
get
(
true
)
);
r
=
ValueExpression
.
get
(
ValueBoolean
.
TRUE
);
}
}
}
else
{
...
...
@@ -3269,11 +3269,11 @@ public class Parser {
break
;
case
TRUE:
read
();
r
=
ValueExpression
.
get
(
ValueBoolean
.
get
(
true
)
);
r
=
ValueExpression
.
get
(
ValueBoolean
.
TRUE
);
break
;
case
FALSE:
read
();
r
=
ValueExpression
.
get
(
ValueBoolean
.
get
(
false
)
);
r
=
ValueExpression
.
get
(
ValueBoolean
.
FALSE
);
break
;
case
ROWNUM:
read
();
...
...
h2/src/main/org/h2/expression/ConditionAndOr.java
浏览文件 @
254d695b
...
...
@@ -100,7 +100,7 @@ public class ConditionAndOr extends Condition {
if
(
r
==
ValueNull
.
INSTANCE
)
{
return
r
;
}
return
ValueBoolean
.
get
(
true
)
;
return
ValueBoolean
.
TRUE
;
}
case
OR:
{
if
(
l
.
getBoolean
())
{
...
...
@@ -116,7 +116,7 @@ public class ConditionAndOr extends Condition {
if
(
r
==
ValueNull
.
INSTANCE
)
{
return
r
;
}
return
ValueBoolean
.
get
(
false
)
;
return
ValueBoolean
.
FALSE
;
}
default
:
throw
DbException
.
throwInternalError
(
"type="
+
andOrType
);
...
...
h2/src/main/org/h2/expression/ConditionInSelect.java
浏览文件 @
254d695b
...
...
@@ -62,16 +62,16 @@ public class ConditionInSelect extends Condition {
}
int
dataType
=
rows
.
getColumnType
(
0
);
if
(
dataType
==
Value
.
NULL
)
{
return
ValueBoolean
.
get
(
false
)
;
return
ValueBoolean
.
FALSE
;
}
l
=
l
.
convertTo
(
dataType
);
if
(
rows
.
containsDistinct
(
new
Value
[]
{
l
}))
{
return
ValueBoolean
.
get
(
true
)
;
return
ValueBoolean
.
TRUE
;
}
if
(
rows
.
containsDistinct
(
new
Value
[]
{
ValueNull
.
INSTANCE
}))
{
return
ValueNull
.
INSTANCE
;
}
return
ValueBoolean
.
get
(
false
)
;
return
ValueBoolean
.
FALSE
;
}
private
Value
getValueSlow
(
ResultInterface
rows
,
Value
l
)
{
...
...
h2/src/main/org/h2/expression/ExpressionColumn.java
浏览文件 @
254d695b
...
...
@@ -330,7 +330,7 @@ public class ExpressionColumn extends Expression {
if
(
filter
==
tf
&&
column
.
getType
()
==
Value
.
BOOLEAN
)
{
IndexCondition
cond
=
IndexCondition
.
get
(
Comparison
.
EQUAL
,
this
,
ValueExpression
.
get
(
ValueBoolean
.
get
(
true
)
));
ValueBoolean
.
TRUE
));
filter
.
addIndexCondition
(
cond
);
}
}
...
...
@@ -338,7 +338,7 @@ public class ExpressionColumn extends Expression {
@Override
public
Expression
getNotIfPossible
(
Session
session
)
{
return
new
Comparison
(
session
,
Comparison
.
EQUAL
,
this
,
ValueExpression
.
get
(
ValueBoolean
.
get
(
false
)
));
ValueExpression
.
get
(
ValueBoolean
.
FALSE
));
}
}
h2/src/main/org/h2/expression/Function.java
浏览文件 @
254d695b
...
...
@@ -1048,13 +1048,13 @@ public class Function extends Expression implements FunctionCall {
break
;
}
case
ARRAY_CONTAINS:
{
result
=
ValueBoolean
.
get
(
false
)
;
result
=
ValueBoolean
.
FALSE
;
if
(
v0
.
getType
()
==
Value
.
ARRAY
)
{
Value
v1
=
getNullOrValue
(
session
,
args
,
values
,
1
);
Value
[]
list
=
((
ValueArray
)
v0
).
getList
();
for
(
Value
v
:
list
)
{
if
(
v
.
equals
(
v1
))
{
result
=
ValueBoolean
.
get
(
true
)
;
result
=
ValueBoolean
.
TRUE
;
break
;
}
}
...
...
h2/src/main/org/h2/expression/Parameter.java
浏览文件 @
254d695b
...
...
@@ -176,7 +176,7 @@ public class Parameter extends Expression implements ParameterInterface {
@Override
public
Expression
getNotIfPossible
(
Session
session
)
{
return
new
Comparison
(
session
,
Comparison
.
EQUAL
,
this
,
ValueExpression
.
get
(
ValueBoolean
.
get
(
false
)
));
ValueExpression
.
get
(
ValueBoolean
.
FALSE
));
}
public
void
setColumn
(
Column
column
)
{
...
...
h2/src/main/org/h2/expression/ValueExpression.java
浏览文件 @
254d695b
...
...
@@ -91,7 +91,7 @@ public class ValueExpression extends Expression {
@Override
public
Expression
getNotIfPossible
(
Session
session
)
{
return
new
Comparison
(
session
,
Comparison
.
EQUAL
,
this
,
ValueExpression
.
get
(
ValueBoolean
.
get
(
false
)
));
ValueExpression
.
get
(
ValueBoolean
.
FALSE
));
}
@Override
...
...
h2/src/main/org/h2/mvstore/db/ValueDataType.java
浏览文件 @
254d695b
...
...
@@ -459,9 +459,9 @@ public class ValueDataType implements DataType {
case
Value
.
NULL
:
return
ValueNull
.
INSTANCE
;
case
BOOLEAN_TRUE:
return
ValueBoolean
.
get
(
true
)
;
return
ValueBoolean
.
TRUE
;
case
BOOLEAN_FALSE:
return
ValueBoolean
.
get
(
false
)
;
return
ValueBoolean
.
FALSE
;
case
INT_NEG:
return
ValueInt
.
get
(-
readVarInt
(
buff
));
case
Value
.
ENUM
:
...
...
h2/src/main/org/h2/store/Data.java
浏览文件 @
254d695b
...
...
@@ -716,9 +716,9 @@ public class Data {
case
Value
.
NULL
:
return
ValueNull
.
INSTANCE
;
case
BOOLEAN_TRUE:
return
ValueBoolean
.
get
(
true
)
;
return
ValueBoolean
.
TRUE
;
case
BOOLEAN_FALSE:
return
ValueBoolean
.
get
(
false
)
;
return
ValueBoolean
.
FALSE
;
case
INT_NEG:
return
ValueInt
.
get
(-
readVarInt
());
case
Value
.
ENUM
:
...
...
h2/src/main/org/h2/value/Value.java
浏览文件 @
254d695b
...
...
@@ -1042,12 +1042,12 @@ public abstract class Value {
s
.
equalsIgnoreCase
(
"t"
)
||
s
.
equalsIgnoreCase
(
"yes"
)
||
s
.
equalsIgnoreCase
(
"y"
))
{
return
ValueBoolean
.
get
(
true
)
;
return
ValueBoolean
.
TRUE
;
}
else
if
(
s
.
equalsIgnoreCase
(
"false"
)
||
s
.
equalsIgnoreCase
(
"f"
)
||
s
.
equalsIgnoreCase
(
"no"
)
||
s
.
equalsIgnoreCase
(
"n"
))
{
return
ValueBoolean
.
get
(
false
)
;
return
ValueBoolean
.
FALSE
;
}
else
{
// convert to a number, and if it is not 0 then it is true
return
ValueBoolean
.
get
(
new
BigDecimal
(
s
).
signum
()
!=
0
);
...
...
h2/src/main/org/h2/value/ValueBoolean.java
浏览文件 @
254d695b
...
...
@@ -25,10 +25,14 @@ public class ValueBoolean extends Value {
public
static
final
int
DISPLAY_SIZE
=
5
;
/**
*
Of type Object so that Tomcat doesn't set it to null
.
*
TRUE value
.
*/
private
static
final
Object
TRUE
=
new
ValueBoolean
(
true
);
private
static
final
Object
FALSE
=
new
ValueBoolean
(
false
);
public
static
final
ValueBoolean
TRUE
=
new
ValueBoolean
(
true
);
/**
* FALSE value.
*/
public
static
final
ValueBoolean
FALSE
=
new
ValueBoolean
(
false
);
private
final
boolean
value
;
...
...
@@ -53,7 +57,7 @@ public class ValueBoolean extends Value {
@Override
public
Value
negate
()
{
return
(
ValueBoolean
)
(
value
?
FALSE
:
TRUE
)
;
return
value
?
FALSE
:
TRUE
;
}
@Override
...
...
@@ -95,7 +99,7 @@ public class ValueBoolean extends Value {
* @return the value
*/
public
static
ValueBoolean
get
(
boolean
b
)
{
return
(
ValueBoolean
)
(
b
?
TRUE
:
FALSE
)
;
return
b
?
TRUE
:
FALSE
;
}
@Override
...
...
h2/src/test/org/h2/test/unit/TestClearReferences.java
浏览文件 @
254d695b
...
...
@@ -50,6 +50,13 @@ public class TestClearReferences extends TestBase {
"org.h2.value.Value.softCache"
,
};
/**
* Path to main sources. In IDE project may be located either in the root
* directory of repository or in the h2 subdirectory.
*/
private
final
String
SOURCE_PATH
=
new
File
(
"h2/src/main/org/h2/Driver.java"
).
exists
()
?
"h2/src/main/"
:
"src/main/"
;
private
boolean
hasError
;
/**
...
...
@@ -113,7 +120,7 @@ public class TestClearReferences extends TestBase {
String
className
=
file
.
getAbsolutePath
().
replace
(
'\\'
,
'/'
);
className
=
className
.
substring
(
className
.
lastIndexOf
(
"org/h2"
));
String
packageName
=
className
.
substring
(
0
,
className
.
lastIndexOf
(
'/'
));
if
(!
new
File
(
"src/main/"
+
packageName
).
exists
())
{
if
(!
new
File
(
SOURCE_PATH
+
packageName
).
exists
())
{
return
;
}
className
=
className
.
replace
(
'/'
,
'.'
);
...
...
h2/src/test/org/h2/test/unit/TestDataPage.java
浏览文件 @
254d695b
...
...
@@ -126,8 +126,8 @@ public class TestDataPage extends TestBase implements DataHandler {
private
void
testValues
()
{
testValue
(
ValueNull
.
INSTANCE
);
testValue
(
ValueBoolean
.
get
(
false
)
);
testValue
(
ValueBoolean
.
get
(
true
)
);
testValue
(
ValueBoolean
.
FALSE
);
testValue
(
ValueBoolean
.
TRUE
);
for
(
int
i
=
0
;
i
<
256
;
i
++)
{
testValue
(
ValueByte
.
get
((
byte
)
i
));
}
...
...
@@ -205,7 +205,7 @@ public class TestDataPage extends TestBase implements DataHandler {
}
}
testValue
(
ValueArray
.
get
(
new
Value
[
0
]));
testValue
(
ValueArray
.
get
(
new
Value
[]
{
ValueBoolean
.
get
(
true
)
,
testValue
(
ValueArray
.
get
(
new
Value
[]
{
ValueBoolean
.
TRUE
,
ValueInt
.
get
(
10
)
}));
SimpleResultSet
rs
=
new
SimpleResultSet
();
...
...
h2/src/test/org/h2/test/unit/TestValueMemory.java
浏览文件 @
254d695b
...
...
@@ -151,7 +151,7 @@ public class TestValueMemory extends TestBase implements DataHandler {
case
Value
.
NULL
:
return
ValueNull
.
INSTANCE
;
case
Value
.
BOOLEAN
:
return
ValueBoolean
.
get
(
false
)
;
return
ValueBoolean
.
FALSE
;
case
Value
.
BYTE
:
return
ValueByte
.
get
((
byte
)
random
.
nextInt
());
case
Value
.
SHORT
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论