[Monetdb-developers] [XQ] Mixing update/docmgmt/query

Ying Zhang Y.Zhang at cwi.nl
Tue Mar 18 15:54:59 CET 2008

On Mar 18, 2008, at 15:38 , Keulen, M. van (Maurice) wrote:

> Jan Rittinger wrote:
>> On 03/18/2008 02:43 PM, Keulen, M. van (Maurice) wrote with  
>> possible deletions:
>>> Hi,
>>> I know that the XQUF prohibits it, but for writing robust  
>>> functions, it is often necessary to mix query and update/docmgmt  
>>> functionality. Some examples:
>> Hi Maurice,
>> I don't think what you suggest is necessary. If you want to query  
>> with side effects -- which is certainly not what XQuery was  
>> initially introduced for -- and you want to simulate XQueryP then  
>> you can *always* use updating queries and return your results in a  
>> special result document.
> What you mean is to do the updates and instead of returning the  
> query result, store it in the database as well ... and then use a  
> second query to retrieve the result? That only works if I am sure  
> that the first query is completed before the second one starts.  
> Furthermore, an update and a docmgmt operation also do not mix, so  
> you need three queries:
> 	• (docmgmt) one to make sure that there is a document in the  
> database for the result (if not, it adds it)
> 	• (update) one to do the updates and insert the result in the  
> result document
> 	• (query) one to get the result document
> A lot of overhead if you ask me.
> Furthermore, I access the database by sending SOAP-messages to the  
> XRPC-interface ... in other words: asynchronous communication. So,  
> waiting for a query to complete is hard ... and you cannot send  
> different queries in one SOAP-message (only multiple calls for the  
> same query, but with other parameters).
> Jennie: my SOAP-messages do not come from MonetDB/XQuery, but from  
> outside (i.e., some scripting language).

Then, an order can only be guaranteed if you, in your scripts, send a  
message, wait for result, and send the next message.  In all other  
cases, unfortunately, no guarantee, as an xrpc server immediately  
start handling a request when it's received.


>>>     * Expression that queries/updates document, but if the  
>>> document does
>>>       not exist, adds an empty version of it:
>>>       let $name := "foo.xml"
>>>       let $emptydoc := <root/>
>>>       let $doc := if (empty(pf:documents()[.=$name])) then
>>>       (put($emptydoc,$name),$emptydoc) else doc("foo.xml")
>>>       return $doc//bar
>> Here you expect, that the document management stuff is done just in  
>> time and thus with side effects! Your query fails if the document  
>> management stuff is done after the query part.
> No, not true. If "foo.xml" is not in the database yet, I want to add  
> it, but simply continue with $emptydoc. The query does not depend on  
> the document to be added immediately.
>>>     * Expression that adds to a log-file:
>>>       let $log := doc("log.xml")
>>>       let $expr := ...some expression...
>>>       return (do insert <entry>...{$expr}...<entry> as last into  
>>> $log,$expr)
>> You can also return a ``nested'' sequence and query the result to  
>> split up your query result and the log files. In my eyes you once  
>> more try to ``cheat'' to have more than a single result stream.
> What do you mean by "nested" sequence? Due to the typing rules, an  
> expression is either an updating expression (without query result)  
> or not (with query result). This implies I cannot within one query  
> do an update and return a result. This is exactly the thing I want  
> to do. I do not want two result streams, I just want a query to have  
> one query result but with side-effects to the database.
> Maurice.
> -- 
> ----------------------------------------------------------------------
> Dr.Ir. M. van Keulen - Assistant Professor, Data Management Technology
> Univ. of Twente, Dept of EEMCS, POBox 217, 7500 AE Enschede,  
> Netherlands
> Email: m.vankeulen at utwente.nl, Phone: +31 534893688, Fax: +31  
> 534892927
> Room: ZI 3039, WWW: http://www.cs.utwente.nl/~keulen
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________
> Monetdb-developers mailing list
> Monetdb-developers at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/monetdb-developers

More information about the developers-list mailing list