W3C home > Mailing lists > Public > public-qt-comments@w3.org > March 2007

[Bug 4441] [XQuery] 2.3.4 Optimization rules unclear?

From: <bugzilla@wiggum.w3.org>
Date: Sat, 31 Mar 2007 14:12:39 +0000
CC:
To: public-qt-comments@w3.org
Message-Id: <E1HXeJr-0003Of-98@wiggum.w3.org>

http://www.w3.org/Bugs/Public/show_bug.cgi?id=4441





------- Comment #1 from mike@saxonica.com  2007-03-31 14:12 -------
Personal response:

The rules (in particular, the sentence that you cite) make it clear that the
processor does not need to call local:prepareEnvironment in this situation,
because the result of the call (unless it fails) has no effect on the final
result of the query.

My guess from the name of your function is that local:prepareEnvironment() is
designed to have side-effects. This is also suggested by your phrase "when the
query writer wants to enforce the evaluation of a function the return value of
which will not be used afterwards".

XQuery doesn't say very much about the semantics of calls to external
functions, and doesn't mention what happens if they have side-effects. The XSLT
2.0 spec (perhaps in the light of field experience with 1.0) has a number of
warnings and caveats on this subject, saying that they are not prohibited but
warning that since the order of execution is not well-defined, the results are
unpredictable.

The WG tried to place as few constraints as possible on optimizers. It would be
most unreasonable in my view to say that the rewrite (count(X) lt 1) => false()
is not allowed when X has a static cardinality of exactly one.

XQuery doesn't provide any mechanism to force evaluation of expressions whose
result is not used. It's open to implementors to provide such mechanisms using
the extensibility features in the language.

Michael Kay
Received on Saturday, 31 March 2007 14:12:44 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:45:32 UTC