[FS] for clause normalization

The normalization of FLWOR clauses seems wrong.
Specifically, the 'for' normalization in 4.8.1 following the
sentence:
   Therefore, a ForClause is normalized to nested for expressions:
appears to be incorrect.

Consider:

for $i in 0 to 9 for $j in 0 to 9 stable order by $j return 10*$i+j

This yields the tuple sequence:
(i=0,j=0), (i=0, j=1), (i=0, j=2) ...
so the sorted result should be:
0, 10, 20, ..., 1, 11, 21, ...

The "normalized" expression is:
for $i in 0 to 9 (for $j in 0 to 9 stable order by $j return 10*$i+j)

This performs 10 independents sorts, none of which change the order,
so the result is as if there was no order by clause:
0, 1, 2, ..., 10, 11, 12, ...
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

Received on Tuesday, 15 June 2004 02:38:54 UTC