You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Rick Hillegas (JIRA)" <ji...@apache.org> on 2010/05/11 15:24:42 UTC

[jira] Commented: (DERBY-4651) Hidden assumptions in FromVTI.makeRestriction()

    [ https://issues.apache.org/jira/browse/DERBY-4651?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12866143#action_12866143 ] 

Rick Hillegas commented on DERBY-4651:
--------------------------------------

Thanks for looking closely at the code, Knut. The improvement you suggest sounds like a good idea, if only because the code is puzzling. I believe that the vacuous trailing constants are added by the normalization logic and are always TRUE in the case of ANDs and FALSE in the case of ORs. In any event, I don't think any rows will be incorrectly qualified. That is because the qualification is redundantly enforced by Derby after the table function returns each row.

> Hidden assumptions in FromVTI.makeRestriction()
> -----------------------------------------------
>
>                 Key: DERBY-4651
>                 URL: https://issues.apache.org/jira/browse/DERBY-4651
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.6.1.0
>            Reporter: Knut Anders Hatlen
>            Priority: Minor
>
> 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).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.