Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#364 Lazy evaluation of "at" variables

v8.4
closed
Michael Kay
5
2012-10-08
2005-06-14
Michael Kay
No

When lazy evaluation is used for expressions that
reference positional variables (the "at" variable in a
for clause), the current value of the positional
variable is not saved, and it may therefore have the
wrong value when it is finally evaluated. For example
the following query returns "2 2" instead of "1 2":

declare function local:val($i as xs:integer) {
$i+0
};

for $v1 at $i in (1,2) order by $v1 return local:val($i)

Test case qxmp274. Fixed by putting positional
variables in an slot on the stack frame like ordinary
variables, and saving them as part of a Closure.

Michael Kay

Discussion