Derby
  1. Derby
  2. DERBY-4651

Hidden assumptions in FromVTI.makeRestriction()

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 10.6.1.0
    • Fix Version/s: 10.6.2.1, 10.7.1.1
    • Component/s: SQL
    • Labels:
      None

      Description

      FromVTI.makeRestriction() has this code to strip away Boolean constants from AND and OR expressions:

      // strip off trailing vacuous constant if present
      if ( andOperator.getRightOperand() instanceof BooleanConstantNode )

      { return makeRestriction( andOperator.getLeftOperand(), columnNameMap ); }

      and

      // strip off trailing vacuous constant if present
      if ( orOperator.getRightOperand() instanceof BooleanConstantNode )

      { return makeRestriction( orOperator.getLeftOperand(), columnNameMap ); }

      The code for AND will only work as expected if the right operand is TRUE. The code for OR only works correctly if the right operand is FALSE.

      I'm not sure if this can ever result in user-visible bugs, since Boolean constants are usually removed before we get to this point in the code. The predicate has probably been transformed to conjunctive normal form, in which Boolean constants in the right operand of an AndNode or an OrNode in fact is always TRUE or FALSE, respectively.

      I think this code either should be changed to work regardless of the value of the constant in the right operand, or the assumption that the predicate is on conjunctive normal form should be documented in the comments (and perhaps also checked in an assert statement).

      1. derby-4651-01-aa-verificationTest.diff
        9 kB
        Rick Hillegas
      2. derby-4651-02-aa-fixBug.diff
        2 kB
        Rick Hillegas
      3. no_cast.diff
        2 kB
        Knut Anders Hatlen

        Issue Links

          Activity

          Knut Anders Hatlen created issue -
          Rick Hillegas made changes -
          Field Original Value New Value
          Attachment derby-4651-01-aa-verificationTest.diff [ 12444328 ]
          Rick Hillegas made changes -
          Assignee Rick Hillegas [ rhillegas ]
          Rick Hillegas made changes -
          Attachment derby-4651-02-aa-fixBug.diff [ 12444332 ]
          Rick Hillegas made changes -
          Link This issue relates to DERBY-4583 [ DERBY-4583 ]
          Knut Anders Hatlen made changes -
          Attachment no_cast.diff [ 12444480 ]
          Knut Anders Hatlen made changes -
          Status Open [ 1 ] Closed [ 6 ]
          Fix Version/s 10.6.1.1 [ 12314973 ]
          Fix Version/s 10.7.0.0 [ 12314971 ]
          Resolution Fixed [ 1 ]
          Kathey Marsden made changes -
          Fix Version/s 10.6.2.0 [ 12315342 ]
          Fix Version/s 10.6.1.1 [ 12314973 ]
          Knut Anders Hatlen made changes -
          Fix Version/s 10.6.2.1 [ 12315343 ]
          Fix Version/s 10.6.2.0 [ 12315342 ]
          Rick Hillegas made changes -
          Fix Version/s 10.7.1.1 [ 12315564 ]
          Fix Version/s 10.7.1.0 [ 12314971 ]
          Gavin made changes -
          Workflow jira [ 12510597 ] Default workflow, editable Closed status [ 12800453 ]

            People

            • Assignee:
              Rick Hillegas
              Reporter:
              Knut Anders Hatlen
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development