On 12/07/2012 13:29, Dmitry Yemanov wrote: > 12.07.2012 19:44, Paul Vinkenoog wrote: >> So... have we implemented the DT and CTE features correctly? > I believe it has nothing to do with our implementation of DTs and CTEs. > Create a view with gen_id and and select that field thrice - you will > get the same result. And views are here for a few decades ;-) > > The "problem" is kinda conceptual. In regular selects and joins, only > persistent fields compose an in-memory tuple, expressions are a separate > thing and they are always evaluated per reference. If you reference them > thrice, you will have three subsequent executions. > > DT/CTE and views has the same problem, but by different reason.
DT/CTE generates BLR which is impossible to run correctly. Views are merged in a way who makes it run incorrectly. It's easy to change them both to run correct. What's not very easy is to not broke any optimization. Manually, you can do, for example: select u, u from (select gen_uuid() u from rdb$database union all select null from rdb$database where 1 = 0); This creates a context and a map, so the expressions now become fields which are mapped once. Adriano ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel