Description
SELECT (FALSE OR FALSE) AS B FROM SYSTEM.CATALOG LIMIT 1;
------------
B
------------
true
------------
1 row selected (0.026 seconds)
But actually it should return false.
When a child of the expression is false boolean literal it will be removed from the list. When children is empty we are returning true literal expression but we should return false literal.
Here is the code from ExpressionCompiler.
private Expression orExpression(List<Expression> children) throws SQLException { Iterator<Expression> iterator = children.iterator(); Determinism determinism = Determinism.ALWAYS; while (iterator.hasNext()) { Expression child = iterator.next(); if (child.getDataType() != PBoolean.INSTANCE) { throw TypeMismatchException.newException(PBoolean.INSTANCE, child.getDataType(), child.toString()); } if (LiteralExpression.isFalse(child)) { iterator.remove(); } if (LiteralExpression.isTrue(child)) { return child; } determinism = determinism.combine(child.getDeterminism()); } if (children.size() == 0) { return LiteralExpression.newConstant(true, determinism); } if (children.size() == 1) { return children.get(0); } return new OrExpression(children); }