http://www.w3.org/Bugs/Public/show_bug.cgi?id=10651
Summary: Optimisation avoiding sorts (K2-OrderbyExprWithout-10
& K2-OrderbyExprWithout-40)
Product: XML Query Test Suite
Version: unspecified
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: XML Query Test Suite
AssignedTo: andrew.eisenberg@us.ibm.com
ReportedBy: Probst_Martin@emc.com
QAContact: public-qt-comments@w3.org
K2-OrderbyExprWithout-10 looks like this:
for $a in (1, 4, 2)
let $i := (1, 3, 2)
order by $i
return $i
The test tries to cause an order by with an order spec that is a sequence of
items, and thus expects XPTY0004.
However, an XQuery engine might find out that the order spec expression $i is
constant over the whole tuple sequence. Thus, the engine can evaluate the whole
query without doing any sort, thus avoiding the error at all and yielding (1,
3, 2, 1, 3, 2, 1, 3, 2) as the result. Or actually, those values in any order
because the ordering of the sequence is undefined as the order spec will always
give identical values.
I think that is a legal optimisation according to the dreaded "Errors and
Optimizations" section. While the implementation has to evaluate $i to yield
the return value, in the context of the order by expression it does not need to
evaluate the sequence at all, so it is free to swallow the error and give a
result. Also, apart from legalese, I think this is the kind of optimisation
that section wants to allow.
I suggest changing the query so that the $i part depends on $a, which means the
sort factor for the tuple sequence is not constant over the whole query:
for $a in (1, 4, 2)
let $i := (1, $a, 2)
order by $i
return $i
The same applies to K2-OrderbyExprWithout-40, which is a more complicated
expression but has the exact same problem and solution.
--
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.