[ 
https://issues.apache.org/jira/browse/DERBY-6577?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13997580#comment-13997580
 ] 

Knut Anders Hatlen commented on DERBY-6577:
-------------------------------------------

This problem was new in CASE expressions after DERBY-6566, but a similar 
problem can be seen with COALESCE even with 10.10.2.0:

{noformat}
ij> select c, coalesce((c = all (values 'Y')), false) from (values 'Y', 'N') 
v(c);
C|2    
-------
Y|false
N|true 

2 rows selected
{noformat}

I believe the result should be the other way around. It should be (Y, true), 
(N, false).

The underlying bug may be similar to DERBY-6408/DERBY-6409. There, part of the 
problem was that SubqueryList.preprocess() didn't update the list if the 
recursive calls to preprocess() rewrote one of the elements in the list. 
COALESCE, and (after DERBY-6566) CASE, use ValueNodeList.preprocess(), which 
seems to have the same problem that SubqueryList.preprocess() had.

> Quantified comparison returns wrong result in CASE expression
> -------------------------------------------------------------
>
>                 Key: DERBY-6577
>                 URL: https://issues.apache.org/jira/browse/DERBY-6577
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.11.0.0
>            Reporter: Knut Anders Hatlen
>            Assignee: Knut Anders Hatlen
>
> I'm seeing this on head of trunk:
> {noformat}
> ij> select c, c = all (values 'Y'), case when c = all (values 'Y') then true 
> else false end from (values 'Y', 'N') v(c);
> C|2    |3    
> -------------
> Y|true |false
> N|false|true 
> 2 rows selected
> {noformat}
> Column 2 and column 3 should have the same value, but something seems to go 
> wrong when the quantified comparison is used in a CASE expression.
> I'm seeing the expected result on 10.10.2.0, though:
> {noformat}
> ij> select c, c = all (values 'Y'), case when c = all (values 'Y') then true 
> else false end from (values 'Y', 'N') v(c);
> C|2    |3    
> -------------
> Y|true |true 
> N|false|false
> 2 rows selected
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to