> -----Original Message-----
> From: Arno Brinkman [mailto:fbsupp...@abvisie.nl] 
> Sent: MiƩrcoles, 28 de Octubre de 2015 21:27
> 
> I've to dig deep in my memory (ooh boy), but i think the 
> stream flag NULL is 
> not treated proper in this case.
> 
> Thinking i've fixed something simular or even this in the 
> past, but seems 
> not :-/

After reading Adriano's mail, I stopped looking at v2.5.
:-)

I think the case can be summarized and optimized:

given
T = table
V = the result of a selectable proc, view or derived table,
if T left join V produces a null record in V caused by a non-matching outer
join,
then coalesce() in V should produce null immediately, no need to evaluate
the arguments. 

A test for a solution might be

select coalesce(C.f, B.f, A.f)
from A left join 
   (B left join C on ...)
on ...

and inserting a few records that let one join (or the two joins) produce
nulls in the right side.

> Simplified test case:
> 
> SELECT
>   dt.*
> FROM
>   RDB$DATABASE
>   LEFT JOIN (SELECT COALESCE(RDB$SECURITY_CLASS, 'NO WAY') AS 
> COALESCE_RET, 
> 'YES THIS TO' AS CONST_RET FROM RDB$DATABASE WHERE 1=1) dt ON (1 = 0);

Strange, I get NULL and NULL in v2.5 and v3.

C.


------------------------------------------------------------------------------
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to