[
https://issues.apache.org/jira/browse/TRAFODION-3190?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16693931#comment-16693931
]
ASF GitHub Bot commented on TRAFODION-3190:
-------------------------------------------
Github user DaveBirdsall commented on a diff in the pull request:
https://github.com/apache/trafodion/pull/1741#discussion_r235216010
--- Diff: core/sql/exp/exp_bool.cpp ---
@@ -96,7 +96,7 @@ ex_expr::exp_return_type ex_branch_clause::eval(char
*op_data[],
switch (getOperType())
{
case ITM_AND:
- if (*(Lng32 *)op_data[1] == 0)
+ if (*(Lng32 *)op_data[1] == 0 || *(Lng32 *)op_data[1] == -1) //
null treated as false
--- End diff --
I don't believe this is correct. Consider the query, "select a from t1x
where not(b = 0 and c = 0)". When B and C are both null, both equal predicates
evaluate to null, and the AND evaluates to null. The NOT then also evaluates to
null. The WHERE clause should treat the result of the NOT as false. But with
this fix, the result of the AND will be false, making the NOT true. There needs
to be three cases here for ITM_AND: If the first operand is false, then the AND
is false. If the first operand is true, then the result is the second operand.
If the first operand is null, then if the second operand is false, the result
is false otherwise the result is null. Similar logic needs to be added to the
ITM_OR case.
> expression involving NULL treated as TRUE.
> ------------------------------------------
>
> Key: TRAFODION-3190
> URL: https://issues.apache.org/jira/browse/TRAFODION-3190
> Project: Apache Trafodion
> Issue Type: Bug
> Components: -exe
> Affects Versions: 2.2.0
> Reporter: Wenjun Zhu
> Assignee: Wenjun Zhu
> Priority: Minor
> Fix For: 2.3
>
>
> expression involving NULL should be treated as FALSE, not TRUE.
>
> like this:
>
> {code:java}
> select case when cast(null as int) > 0 then 1/0 else 0 end from dual;{code}
>
> should output 0, not a Division by zero error.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)