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

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

From: <bugzilla@wiggum.w3.org>
Date: Mon, 02 Apr 2007 16:51:38 +0000
To: public-qt-comments@w3.org
Message-Id: <E1HYPko-0004Mp-HA@wiggum.w3.org>


------- Comment #6 from hrennau@yahoo.de  2007-04-02 16:51 -------
You write:

"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."

And in another comment:

"It can still be difficult to enforce the order in which such functions are

The enforcement of  (a) execution and ( b) order of execution is of vital
importance when writing standalone queries of extended functionality, e.g.
standalone queries opening, using and closing JDBC connections. Don't you think
that query authors need a reliable, standards based pattern, rather than an
implementation specfic feature? I suppose that the pattern described beneath is
in fact reliable; the only constraint on the enforced functions is that they do
not have the return type empty-sequence(). If I am wrong and the pattern is not
reliable - cordial thanks to you or any implementor correcting my error.

(a) To enforce the silent execution of functions, wrap the  function calls in a
call to “silentExec” (see below)

(b) Let S1 be a sequence of function calls to be silently executed, and S2 the
part of the query to be evaluated after execution of S1. To achieve this, use
the pattern 
        if (local:silentExec(S1)) then error() else S2

(c) Example:
if (local:silentExec(local:initQuery(), java:initEnv))) 
then error((), "NEVER") else

Sketch of local:silentExec (can certainly be improved, e.g. using an
appropriate theorem):

declare function local:silentExec($items as item()*) as node()* {
   let $obscure as xs:integer := sum(for $item at $pos in $items return 
            case $i as node() return $i/root()/comment()[1]
            default $i return xs:string($i)
      comment {"NEVER"} 
         [9999999 eq sum(for $digit in string($obscure) return number($digit) *
Received on Monday, 2 April 2007 16:51:40 UTC

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