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

TRUE and FALSE constants are not cleared anyway

上级 7703a00a
...@@ -2443,7 +2443,7 @@ public class Parser { ...@@ -2443,7 +2443,7 @@ public class Parser {
if (database.getMode().prohibitEmptyInPredicate) { if (database.getMode().prohibitEmptyInPredicate) {
throw getSyntaxError(); throw getSyntaxError();
} }
r = ValueExpression.get(ValueBoolean.get(false)); r = ValueExpression.get(ValueBoolean.FALSE);
} else { } else {
if (isSelect()) { if (isSelect()) {
Query query = parseSelect(); Query query = parseSelect();
...@@ -2533,7 +2533,7 @@ public class Parser { ...@@ -2533,7 +2533,7 @@ public class Parser {
} else { } else {
rightFilter.mapAndAddFilter(r); rightFilter.mapAndAddFilter(r);
} }
r = ValueExpression.get(ValueBoolean.get(true)); r = ValueExpression.get(ValueBoolean.TRUE);
} }
} }
} else { } else {
...@@ -3280,11 +3280,11 @@ public class Parser { ...@@ -3280,11 +3280,11 @@ public class Parser {
break; break;
case TRUE: case TRUE:
read(); read();
r = ValueExpression.get(ValueBoolean.get(true)); r = ValueExpression.get(ValueBoolean.TRUE);
break; break;
case FALSE: case FALSE:
read(); read();
r = ValueExpression.get(ValueBoolean.get(false)); r = ValueExpression.get(ValueBoolean.FALSE);
break; break;
case ROWNUM: case ROWNUM:
read(); read();
......
...@@ -100,7 +100,7 @@ public class ConditionAndOr extends Condition { ...@@ -100,7 +100,7 @@ public class ConditionAndOr extends Condition {
if (r == ValueNull.INSTANCE) { if (r == ValueNull.INSTANCE) {
return r; return r;
} }
return ValueBoolean.get(true); return ValueBoolean.TRUE;
} }
case OR: { case OR: {
if (l.getBoolean()) { if (l.getBoolean()) {
...@@ -116,7 +116,7 @@ public class ConditionAndOr extends Condition { ...@@ -116,7 +116,7 @@ public class ConditionAndOr extends Condition {
if (r == ValueNull.INSTANCE) { if (r == ValueNull.INSTANCE) {
return r; return r;
} }
return ValueBoolean.get(false); return ValueBoolean.FALSE;
} }
default: default:
throw DbException.throwInternalError("type=" + andOrType); throw DbException.throwInternalError("type=" + andOrType);
......
...@@ -62,16 +62,16 @@ public class ConditionInSelect extends Condition { ...@@ -62,16 +62,16 @@ public class ConditionInSelect extends Condition {
} }
int dataType = rows.getColumnType(0); int dataType = rows.getColumnType(0);
if (dataType == Value.NULL) { if (dataType == Value.NULL) {
return ValueBoolean.get(false); return ValueBoolean.FALSE;
} }
l = l.convertTo(dataType); l = l.convertTo(dataType);
if (rows.containsDistinct(new Value[] { l })) { if (rows.containsDistinct(new Value[] { l })) {
return ValueBoolean.get(true); return ValueBoolean.TRUE;
} }
if (rows.containsDistinct(new Value[] { ValueNull.INSTANCE })) { if (rows.containsDistinct(new Value[] { ValueNull.INSTANCE })) {
return ValueNull.INSTANCE; return ValueNull.INSTANCE;
} }
return ValueBoolean.get(false); return ValueBoolean.FALSE;
} }
private Value getValueSlow(ResultInterface rows, Value l) { private Value getValueSlow(ResultInterface rows, Value l) {
......
...@@ -330,7 +330,7 @@ public class ExpressionColumn extends Expression { ...@@ -330,7 +330,7 @@ public class ExpressionColumn extends Expression {
if (filter == tf && column.getType() == Value.BOOLEAN) { if (filter == tf && column.getType() == Value.BOOLEAN) {
IndexCondition cond = IndexCondition.get( IndexCondition cond = IndexCondition.get(
Comparison.EQUAL, this, ValueExpression.get( Comparison.EQUAL, this, ValueExpression.get(
ValueBoolean.get(true))); ValueBoolean.TRUE));
filter.addIndexCondition(cond); filter.addIndexCondition(cond);
} }
} }
...@@ -338,7 +338,7 @@ public class ExpressionColumn extends Expression { ...@@ -338,7 +338,7 @@ public class ExpressionColumn extends Expression {
@Override @Override
public Expression getNotIfPossible(Session session) { public Expression getNotIfPossible(Session session) {
return new Comparison(session, Comparison.EQUAL, this, 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 { ...@@ -1048,13 +1048,13 @@ public class Function extends Expression implements FunctionCall {
break; break;
} }
case ARRAY_CONTAINS: { case ARRAY_CONTAINS: {
result = ValueBoolean.get(false); result = ValueBoolean.FALSE;
if (v0.getType() == Value.ARRAY) { if (v0.getType() == Value.ARRAY) {
Value v1 = getNullOrValue(session, args, values, 1); Value v1 = getNullOrValue(session, args, values, 1);
Value[] list = ((ValueArray) v0).getList(); Value[] list = ((ValueArray) v0).getList();
for (Value v : list) { for (Value v : list) {
if (v.equals(v1)) { if (v.equals(v1)) {
result = ValueBoolean.get(true); result = ValueBoolean.TRUE;
break; break;
} }
} }
......
...@@ -176,7 +176,7 @@ public class Parameter extends Expression implements ParameterInterface { ...@@ -176,7 +176,7 @@ public class Parameter extends Expression implements ParameterInterface {
@Override @Override
public Expression getNotIfPossible(Session session) { public Expression getNotIfPossible(Session session) {
return new Comparison(session, Comparison.EQUAL, this, return new Comparison(session, Comparison.EQUAL, this,
ValueExpression.get(ValueBoolean.get(false))); ValueExpression.get(ValueBoolean.FALSE));
} }
public void setColumn(Column column) { public void setColumn(Column column) {
......
...@@ -91,7 +91,7 @@ public class ValueExpression extends Expression { ...@@ -91,7 +91,7 @@ public class ValueExpression extends Expression {
@Override @Override
public Expression getNotIfPossible(Session session) { public Expression getNotIfPossible(Session session) {
return new Comparison(session, Comparison.EQUAL, this, return new Comparison(session, Comparison.EQUAL, this,
ValueExpression.get(ValueBoolean.get(false))); ValueExpression.get(ValueBoolean.FALSE));
} }
@Override @Override
......
...@@ -459,9 +459,9 @@ public class ValueDataType implements DataType { ...@@ -459,9 +459,9 @@ public class ValueDataType implements DataType {
case Value.NULL: case Value.NULL:
return ValueNull.INSTANCE; return ValueNull.INSTANCE;
case BOOLEAN_TRUE: case BOOLEAN_TRUE:
return ValueBoolean.get(true); return ValueBoolean.TRUE;
case BOOLEAN_FALSE: case BOOLEAN_FALSE:
return ValueBoolean.get(false); return ValueBoolean.FALSE;
case INT_NEG: case INT_NEG:
return ValueInt.get(-readVarInt(buff)); return ValueInt.get(-readVarInt(buff));
case Value.ENUM: case Value.ENUM:
......
...@@ -716,9 +716,9 @@ public class Data { ...@@ -716,9 +716,9 @@ public class Data {
case Value.NULL: case Value.NULL:
return ValueNull.INSTANCE; return ValueNull.INSTANCE;
case BOOLEAN_TRUE: case BOOLEAN_TRUE:
return ValueBoolean.get(true); return ValueBoolean.TRUE;
case BOOLEAN_FALSE: case BOOLEAN_FALSE:
return ValueBoolean.get(false); return ValueBoolean.FALSE;
case INT_NEG: case INT_NEG:
return ValueInt.get(-readVarInt()); return ValueInt.get(-readVarInt());
case Value.ENUM: case Value.ENUM:
......
...@@ -1042,12 +1042,12 @@ public abstract class Value { ...@@ -1042,12 +1042,12 @@ public abstract class Value {
s.equalsIgnoreCase("t") || s.equalsIgnoreCase("t") ||
s.equalsIgnoreCase("yes") || s.equalsIgnoreCase("yes") ||
s.equalsIgnoreCase("y")) { s.equalsIgnoreCase("y")) {
return ValueBoolean.get(true); return ValueBoolean.TRUE;
} else if (s.equalsIgnoreCase("false") || } else if (s.equalsIgnoreCase("false") ||
s.equalsIgnoreCase("f") || s.equalsIgnoreCase("f") ||
s.equalsIgnoreCase("no") || s.equalsIgnoreCase("no") ||
s.equalsIgnoreCase("n")) { s.equalsIgnoreCase("n")) {
return ValueBoolean.get(false); return ValueBoolean.FALSE;
} else { } else {
// convert to a number, and if it is not 0 then it is true // convert to a number, and if it is not 0 then it is true
return ValueBoolean.get(new BigDecimal(s).signum() != 0); return ValueBoolean.get(new BigDecimal(s).signum() != 0);
......
...@@ -25,10 +25,14 @@ public class ValueBoolean extends Value { ...@@ -25,10 +25,14 @@ public class ValueBoolean extends Value {
public static final int DISPLAY_SIZE = 5; 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); public static final ValueBoolean TRUE = new ValueBoolean(true);
private static final Object FALSE = new ValueBoolean(false);
/**
* FALSE value.
*/
public static final ValueBoolean FALSE = new ValueBoolean(false);
private final boolean value; private final boolean value;
...@@ -53,7 +57,7 @@ public class ValueBoolean extends Value { ...@@ -53,7 +57,7 @@ public class ValueBoolean extends Value {
@Override @Override
public Value negate() { public Value negate() {
return (ValueBoolean) (value ? FALSE : TRUE); return value ? FALSE : TRUE;
} }
@Override @Override
...@@ -95,7 +99,7 @@ public class ValueBoolean extends Value { ...@@ -95,7 +99,7 @@ public class ValueBoolean extends Value {
* @return the value * @return the value
*/ */
public static ValueBoolean get(boolean b) { public static ValueBoolean get(boolean b) {
return (ValueBoolean) (b ? TRUE : FALSE); return b ? TRUE : FALSE;
} }
@Override @Override
......
...@@ -126,8 +126,8 @@ public class TestDataPage extends TestBase implements DataHandler { ...@@ -126,8 +126,8 @@ public class TestDataPage extends TestBase implements DataHandler {
private void testValues() { private void testValues() {
testValue(ValueNull.INSTANCE); testValue(ValueNull.INSTANCE);
testValue(ValueBoolean.get(false)); testValue(ValueBoolean.FALSE);
testValue(ValueBoolean.get(true)); testValue(ValueBoolean.TRUE);
for (int i = 0; i < 256; i++) { for (int i = 0; i < 256; i++) {
testValue(ValueByte.get((byte) i)); testValue(ValueByte.get((byte) i));
} }
...@@ -205,7 +205,7 @@ public class TestDataPage extends TestBase implements DataHandler { ...@@ -205,7 +205,7 @@ public class TestDataPage extends TestBase implements DataHandler {
} }
} }
testValue(ValueArray.get(new Value[0])); testValue(ValueArray.get(new Value[0]));
testValue(ValueArray.get(new Value[] { ValueBoolean.get(true), testValue(ValueArray.get(new Value[] { ValueBoolean.TRUE,
ValueInt.get(10) })); ValueInt.get(10) }));
SimpleResultSet rs = new SimpleResultSet(); SimpleResultSet rs = new SimpleResultSet();
......
...@@ -151,7 +151,7 @@ public class TestValueMemory extends TestBase implements DataHandler { ...@@ -151,7 +151,7 @@ public class TestValueMemory extends TestBase implements DataHandler {
case Value.NULL: case Value.NULL:
return ValueNull.INSTANCE; return ValueNull.INSTANCE;
case Value.BOOLEAN: case Value.BOOLEAN:
return ValueBoolean.get(false); return ValueBoolean.FALSE;
case Value.BYTE: case Value.BYTE:
return ValueByte.get((byte) random.nextInt()); return ValueByte.get((byte) random.nextInt());
case Value.SHORT: case Value.SHORT:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论