提交 c59e4336 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

TRUE and FALSE constants are not cleared anyway

上级 7703a00a
......@@ -2443,7 +2443,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();
......@@ -2533,7 +2533,7 @@ public class Parser {
} else {
rightFilter.mapAndAddFilter(r);
}
r = ValueExpression.get(ValueBoolean.get(true));
r = ValueExpression.get(ValueBoolean.TRUE);
}
}
} else {
......@@ -3280,11 +3280,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();
......
......@@ -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);
......
......@@ -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) {
......
......@@ -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));
}
}
......@@ -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;
}
}
......
......@@ -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) {
......
......@@ -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
......
......@@ -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:
......
......@@ -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:
......
......@@ -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);
......
......@@ -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
......
......@@ -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();
......
......@@ -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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论