db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Hillegas (JIRA)" <j...@apache.org>
Subject [jira] Updated: (DERBY-4651) Hidden assumptions in FromVTI.makeRestriction()
Date Wed, 12 May 2010 18:58:42 GMT

     [ https://issues.apache.org/jira/browse/DERBY-4651?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Rick Hillegas updated DERBY-4651:
---------------------------------

    Attachment: derby-4651-02-aa-fixBug.diff

Attaching derby-4651-02-aa-fixBug.diff. This patch adds some defensive logic so that boolean
constants are short-circuited only when they have no effect on the result.

Committed at subversion revision 943633. Ported to the 10.6 branch at subversion revision
943634.

As a consequence of this patch, Knut's problem scenario will raise an exception rather than
return wrong results. As I said, I have not been able to figure out how to create Knut's scenario
but it may arise when we re-enable boolean literals. At that time, we may want to handle this
situation more gracefully. For instance, we may want to add two need kinds of Restriction
subclasses to model the boolean literals.

Touches the following file:

M      java/engine/org/apache/derby/impl/sql/compile/FromVTI.java


> 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
>            Assignee: Rick Hillegas
>            Priority: Minor
>         Attachments: derby-4651-01-aa-verificationTest.diff, derby-4651-02-aa-fixBug.diff
>
>
> 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.


Mime
View raw message