Uploaded image for project: 'Phoenix'
  1. Phoenix
  2. PHOENIX-1956

SELECT (FALSE OR FALSE) RETURNS TRUE

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.2.3, 4.4.0, 4.3.2
    • None
    • None

    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);
          }
      

      Attachments

        1. PHOENIX-1956.patch
          3 kB
          James R. Taylor

        Activity

          People

            jamestaylor James R. Taylor
            rajeshbabu Rajeshbabu Chintaguntla
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: