Hi all,

If I do this:

  select u, u, u
  from (select gen_uuid() u from rdb$database)

...I get three different UUID's.

I would have expected the derived table to be evaluated once. The subquery 
returns a single row with one column. Selecting this column three times should 
get me three times the same value, IMO.

The standard says about derived tables:

  4.14.2 Types of tables
  (...)
  A derived table is a table derived directly or indirectly from one or more
  other tables by the evaluation of a <query expression> whose result has an
  element type that is a row type. The values of a derived table are derived
  from the values of the underlying tables when the <query expression> is
  evaluated.

Although this is not 100% explicit, it suggests that the DT result set is 
determined only once. Executing <query expression> again and again for each 
column selected from the DT seems a waste of resources as well as a serious 
limitation of its usability with non-deterministic functions.

The same goes for CTE's.

So... have we implemented the DT and CTE features correctly? And if so, can 
somebody point me to some authoritative sources?


Kind regards,
Paul Vinkenoog

------------------------------------------------------------------------------
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

Reply via email to