Project

Profile

Help

Bug #2556

closed

Incorrect copying of subexpressions during FLWOR optimization

Added by Michael Kay almost 9 years ago. Updated almost 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Internals
Sprint/Milestone:
-
Start date:
2015-12-21
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

This arose from investigation of bug #2547, though it is not directly related. Discovered from code inspection, there are no known symptoms, but the code is clearly incorrect.

In FLWORExpression.optimize(), there are particular conditions under which the variable declared in a "let" clause is inlined (that is, references to the declared variable V are replaced by the expression E to which it is bound). In all cases the expression E is first copied.

  • But there are many situations where this copy is unnecessary, for example in the simple case of let $V := E return $V, which can be replaced by E without first copying E.

  • And there are some situations where the copy is insufficient, for example in the case of let $V := $A return $V+$V+$V, where the resulting expression $A+$A+$A should contain three different references to the same variable rather than three copies of the same variable. (Not much is likely to go wrong if there are three copies of the same variable reference in a simple case like this. But the expression tree is no longer a well formed tree, and subsequent processes walking the tree could trip up on this.)

Please register to edit this issue

Also available in: Atom PDF