Actions
Bug #2664
closedXQuery optimize leads to stackoverflow
Start date:
2016-03-06
Due date:
% Done:
100%
Estimated time:
Legacy ID:
Applies to branch:
9.7
Fix Committed on Branch:
9.7
Fixed in Maintenance Release:
Platforms:
Description
In Saxon-HE 9.7.0.2J, the following xquery (ran with @java -cp saxon9he.jar net.sf.saxon.Query test.xqy@)
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method "text";
declare context item := doc('test.xml'); (: error occurs with or without this line :)
for $x in distinct-values(doc('test.xml')/report//section//title)
where count(/report//section[title=string($x)]) > 1
return $x
causes a stackoverflow error when ran against the following xml
<report>
<title>Main title</title>
<section>
<title>sec1</title>
</section>
<section>
<title>sec1</title>
<section>
<title>sec21</title>
</section>
</section>
</report>
The error does not occur in the following three variants:
loop uses default context
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method "text";
declare context item := doc('test.xml');
for $x in distinct-values(/report//section//title)
where count(doc('test.xml')/report//section[title=string($x)]) > 1
return $x
loop and where uses explicit context
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method "text";
declare context item := doc('test.xml');
for $x in distinct-values(doc('test.xml')/report//section//title)
where count(doc('test.xml')/report//section[title=string($x)]) > 1
return $x
both loop and where uses default context
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method "text";
declare context item := doc('test.xml');
for $x in distinct-values(/report//section//title)
where count(/report//section[title=string($x)]) > 1
return $x
The original query and xml as well as the complete stack trace is attached.
Files
Please register to edit this issue
Actions