Product Documentation

c-treeACE V10.0 Release Notes

Previous Topic

Next Topic

Correct SQL OR Clause Handling with Outer Joins and Nullable Columns

The following query returned no results from a data set that should have returned several rows:

SELECT id from qtable q

LEFT OUTER JOIN users u on q.id = u.usr_id

LEFT OUTER JOIN groups g on q.id = g.group_id

WHERE u.stat = 0 OR g.stat = 0;

The same query without the OR clause returned expected results.

An optimization within the OR operator logic contains a restrict node and based on the nullability of the restrict expressions, either a simple <> relational operator is used or a searched case. The nullability check for a field was based on whether the table column was nullable or not. However, if the restrict was on a field that is from the right branch of an outer join, then it could be null even if the table column is not nullable.

There is now an added check if the join is an outer join and if the expression is from the RHS of the join the nullability is set accordingly.

TOCIndex