Dmitry, > 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.
This seems to be wrong. First, in the original example: select u, u, u from (select gen_uuid() u from rdb$database) there is only one instance of the expression -- there are 3 references to the *resolved* expression. Had the SQL been select u1, u2, u3 from (select gen_uuid() u1, gen_uuid() u2, gen_uuid() u3 from rdb$database) Then I would agree that there are 3 references. Sean P.S. This subject would extend to how the engine currently considers all functions as "variant" (the answer changes with each call), where most functions/UDFs are "invariant". This causes optimization problems in cases where the SQL reads: SELECT ... FROM ... WHERE ColumnA = COS( :Param) In this case, the result of the COS() function is a fixed value and thus the optimizer should use any ColumnA index, but it doesn't. In reality, the SQL should be treated the same as this: SELECT ... FROM ... WHERE ColumnA =:Param ------------------------------------------------------------------------------ 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