Github user anoopsharma00 commented on a diff in the pull request:
https://github.com/apache/trafodion/pull/1705#discussion_r213022025
--- Diff: core/sql/exp/exp_comp.cpp ---
@@ -116,9 +116,9 @@ ex_expr::exp_return_type
ex_comp_clause::processNulls(char *op_data[],
// then move boolean unknown value to result and return.
if (getOperand(i)->getNullFlag() && (!op_data[i])) // missing value
{
- // move null value to result.
- *(Lng32 *)op_data[2 * MAX_OPERANDS] = -1;
- return ex_expr::EXPR_NULL;
+ // move null value to result.
+ *(Lng32 *)op_data[2 * MAX_OPERANDS] = 0;
+ return ex_expr::EXPR_NULL;
}
}
--- End diff --
this change is not correct.
3-valued boolean logic requires that comparison of null to another value
during intermediate operations should make the result null and not false.
The place where null becomes false is at the very end of that expression.
As an example, with the changed logic, this expression will return
incorrect result.
select * from t where not (a = 1);
if a is null, the where predicate will become true which is incorrect.
With the original 3-valued result, the where pred will become false and not
return any result.
---