phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rajeshbabu Chintaguntla (JIRA)" <j...@apache.org>
Subject [jira] [Created] (PHOENIX-1956) SELECT (FALSE OR FALSE) RETURNS TRUE
Date Fri, 08 May 2015 13:09:00 GMT
Rajeshbabu Chintaguntla created PHOENIX-1956:
------------------------------------------------

             Summary: SELECT (FALSE OR FALSE) RETURNS TRUE
                 Key: PHOENIX-1956
                 URL: https://issues.apache.org/jira/browse/PHOENIX-1956
             Project: Phoenix
          Issue Type: Bug
            Reporter: Rajeshbabu Chintaguntla
            Assignee: Rajeshbabu Chintaguntla
             Fix For: 5.0.0, 4.4.0


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.
{code}
    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);
    }
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message