[
https://issues.apache.org/jira/browse/DERBY-6569?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13995111#comment-13995111
]
Knut Anders Hatlen commented on DERBY-6569:
-------------------------------------------
So there seems to be more methods that have to be overridden in
CachedValueNode. For example, if I take the test case for DERBY-4594 and
replace COALESCE with NULLIF, I get an assert failure with the patch:
{noformat}
ij> SELECT R.report_id, ER.entity_id FROM reports AS R LEFT JOIN entity_reports
AS ER ON R.report_id = ER.report_id WHERE R.details LIKE '%Details%' AND
NULLIF(er.entity_id, 0) != 1;
ERROR XJ001: Java exception: 'ASSERT FAILED sourceResultSetNumber expected to
be >= 0 for ER.ENTITY_ID: org.apache.derby.shared.common.sanity.AssertFailure'.
{noformat}
Probably it's because the categorize() method isn't overridden, as that's what
originally was the problem with CoalesceFunctionNode in DERBY-4594.
> NULLIF may return incorrect results if first operand calls non-deterministic
> function
> -------------------------------------------------------------------------------------
>
> Key: DERBY-6569
> URL: https://issues.apache.org/jira/browse/DERBY-6569
> Project: Derby
> Issue Type: Bug
> Components: SQL
> Affects Versions: 10.10.2.0
> Reporter: Knut Anders Hatlen
> Assignee: Knut Anders Hatlen
> Attachments: d6569-1a.diff
>
>
> The SQL standard doesn't allow non-deterministic function calls in the
> operands of NULLIF. Derby does however allow such calls, but the results may
> not be as one might expect.
> Take an expression such as NULLIF(expr, 1). It shouldn't ever return 1. If
> expr is 1, it should return NULL, and if expr is not 1, it should return expr.
> If expr contains a call to a non-deterministic function, it may actually end
> up returning 1 sometimes:
> {noformat}
> ij> SELECT NULLIF(INT(RANDOM()*2), 1) FROM SYS.SYSTABLES;
> 1
> -----------
> 1
> 1
> 1
> NULL
> NULL
> NULL
> NULL
> 0
> 1
> NULL
> NULL
> 0
> 0
> NULL
> 0
> 1
> 0
> NULL
> 1
> 0
> NULL
> NULL
> NULL
> 23 rows selected
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.2#6252)