[MonetDB-users] Cannot delete added document in XQuery function
Dear All, To be able to create a soap-interface with support for the dynamic management of xml documents I created a XQuery module with some simple document management functions, which I stole from "pathfinder/runtime/xrpc/admin/admin.xq" (the code is found at the end of this mail). To test the functions without soap, I created tree simple xqueries. Now adding and displaying documents works perfectly. However, when I want to delete a document I get: "ERROR = !ERROR: _del_doc(tmp/test.xml): document not found in database (1 such errors)! !ERROR: interpret_params: shred_doc_base(param 1): evaluation error.". Maybe this is because the document is not shredded in an ordinary way, however I do not know of any other function that can insert documents without a physical location. If someone could help me to delete these documents, or point me to another way of inserting documents without a physical location (, or show me the stupid mistake I made :) ), this would be very much appreciated. Best regards, Arthur The module looks as follows: ========================== module namespace cq = "http://db.cs.utwente.nl/cq#"; declare updating function cq:PUT($uri as xs:string, $doc as element()) { if (substring($uri, 1,4) = 'tmp/') then put($doc, $uri) else error('PUT: only relative URIs starting with tmp/ allowed') }; declare function cq:GET($uri as xs:string) { doc($uri) }; declare document management function cq:DELETE($uri as xs:string) { if (substring($uri, 1,4) = 'tmp/') then pf:del-doc($uri) else error('DELETE: only relative URIs starting with tmp/ allowed') }; ========================== The three test files look as follows: ========================== import module namespace cq = "http://db.cs.utwente.nl/cq#" at "/home/db/bunninge/phd/implementation/xquery/try3_module/ca_module.xq"; cq:PUT("tmp/test.xml",<bla/>) ========================== import module namespace cq = "http://db.cs.utwente.nl/cq#" at "/home/db/bunninge/phd/implementation/xquery/try3_module/ca_module.xq"; cq:GET("tmp/test.xml") ========================== import module namespace cq = "http://db.cs.utwente.nl/cq#" at "/home/db/bunninge/phd/implementation/xquery/try3_module/ca_module.xq"; cq:DELETE("tmp/test.xml")
Hi Arthur, with PUT, your node is serialized to disk, in the file "<dbfarm>/<db>/tmp/test.xml" it is not shredded at all, you can see this by using xmldb_print() in a Msever console. So the problem seems to be caused by that _del_doc does not recognize a document that is stored on disk but not shredded... Jennie On Wed, Mar 07, 2007 at 09:18:31PM +0100, Arthur van Bunningen wrote:
Dear All,
To be able to create a soap-interface with support for the dynamic management of xml documents I created a XQuery module with some simple document management functions, which I stole from "pathfinder/runtime/xrpc/admin/admin.xq" (the code is found at the end of this mail).
To test the functions without soap, I created tree simple xqueries. Now adding and displaying documents works perfectly. However, when I want to delete a document I get: "ERROR = !ERROR: _del_doc(tmp/test.xml): document not found in database (1 such errors)! !ERROR: interpret_params: shred_doc_base(param 1): evaluation error.".
Maybe this is because the document is not shredded in an ordinary way, however I do not know of any other function that can insert documents without a physical location.
If someone could help me to delete these documents, or point me to another way of inserting documents without a physical location (, or show me the stupid mistake I made :) ), this would be very much appreciated.
Best regards,
Arthur
The module looks as follows: ========================== module namespace cq = "http://db.cs.utwente.nl/cq#"; declare updating function cq:PUT($uri as xs:string, $doc as element()) { if (substring($uri, 1,4) = 'tmp/') then put($doc, $uri) else error('PUT: only relative URIs starting with tmp/ allowed') };
declare function cq:GET($uri as xs:string) { doc($uri) };
declare document management function cq:DELETE($uri as xs:string) { if (substring($uri, 1,4) = 'tmp/') then pf:del-doc($uri) else error('DELETE: only relative URIs starting with tmp/ allowed') };
========================== The three test files look as follows: ========================== import module namespace cq = "http://db.cs.utwente.nl/cq#" at "/home/db/bunninge/phd/implementation/xquery/try3_module/ca_module.xq"; cq:PUT("tmp/test.xml",<bla/>) ========================== import module namespace cq = "http://db.cs.utwente.nl/cq#" at "/home/db/bunninge/phd/implementation/xquery/try3_module/ca_module.xq"; cq:GET("tmp/test.xml") ========================== import module namespace cq = "http://db.cs.utwente.nl/cq#" at "/home/db/bunninge/phd/implementation/xquery/try3_module/ca_module.xq"; cq:DELETE("tmp/test.xml")
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
Dear Jennie, Thank you for your explanation. Do you know if it is possible to delete a document from the db-farm? Since when I try to simply overwrite the old file by doing a new put-statement with another XML-element with the same name, MonetDB crashes with a segmentation-fault when doing a new get-statement for the same file. In short: cq:PUT("tmp/test.xml",<bla/>) // no problem cq:GET("tmp/test.xml") // returns <?xml version="1.0" encoding="utf-8"?><bla/> cq:PUT("tmp/test.xml",<bladiebloe/>) // no problem (it seems) cq:GET("tmp/test.xml") // Segmentation fault I checked the db-farm directory and after the crash it does contain: <?xml version="1.0" encoding="utf-8"?><bladiebloe/> So that seems to be OK. Thank you for your help. Best regards, Arthur Ying Zhang wrote:
Hi Arthur,
with PUT, your node is serialized to disk, in the file "<dbfarm>/<db>/tmp/test.xml" it is not shredded at all, you can see this by using xmldb_print() in a Msever console. So the problem seems to be caused by that _del_doc does not recognize a document that is stored on disk but not shredded...
Jennie
On Wed, Mar 07, 2007 at 09:18:31PM +0100, Arthur van Bunningen wrote:
Dear All,
To be able to create a soap-interface with support for the dynamic management of xml documents I created a XQuery module with some simple document management functions, which I stole from "pathfinder/runtime/xrpc/admin/admin.xq" (the code is found at the end of this mail).
To test the functions without soap, I created tree simple xqueries. Now adding and displaying documents works perfectly. However, when I want to delete a document I get: "ERROR = !ERROR: _del_doc(tmp/test.xml): document not found in database (1 such errors)! !ERROR: interpret_params: shred_doc_base(param 1): evaluation error.".
Maybe this is because the document is not shredded in an ordinary way, however I do not know of any other function that can insert documents without a physical location.
If someone could help me to delete these documents, or point me to another way of inserting documents without a physical location (, or show me the stupid mistake I made :) ), this would be very much appreciated.
Best regards,
Arthur
The module looks as follows: ========================== module namespace cq = "http://db.cs.utwente.nl/cq#"; declare updating function cq:PUT($uri as xs:string, $doc as element()) { if (substring($uri, 1,4) = 'tmp/') then put($doc, $uri) else error('PUT: only relative URIs starting with tmp/ allowed') };
declare function cq:GET($uri as xs:string) { doc($uri) };
declare document management function cq:DELETE($uri as xs:string) { if (substring($uri, 1,4) = 'tmp/') then pf:del-doc($uri) else error('DELETE: only relative URIs starting with tmp/ allowed') };
========================== The three test files look as follows: ========================== import module namespace cq = "http://db.cs.utwente.nl/cq#" at "/home/db/bunninge/phd/implementation/xquery/try3_module/ca_module.xq"; cq:PUT("tmp/test.xml",<bla/>) ========================== import module namespace cq = "http://db.cs.utwente.nl/cq#" at "/home/db/bunninge/phd/implementation/xquery/try3_module/ca_module.xq"; cq:GET("tmp/test.xml") ========================== import module namespace cq = "http://db.cs.utwente.nl/cq#" at "/home/db/bunninge/phd/implementation/xquery/try3_module/ca_module.xq"; cq:DELETE("tmp/test.xml")
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
Hi Arthur, On Thu, Mar 08, 2007 at 11:17:42AM +0100, Arthur van Bunningen wrote:
Dear Jennie,
Thank you for your explanation. Do you know if it is possible to delete a document from the db-farm? Since when I try to simply overwrite the old file by doing a new put-statement with another XML-element with the same name, MonetDB crashes with a segmentation-fault when doing a new get-statement for the same file.
In short:
cq:PUT("tmp/test.xml",<bla/>) // no problem cq:GET("tmp/test.xml") // returns <?xml version="1.0" encoding="utf-8"?><bla/> cq:PUT("tmp/test.xml",<bladiebloe/>) // no problem (it seems) cq:GET("tmp/test.xml") // Segmentation fault
This is a bug. I tried your query and got the Seg Fault too. I discovered several properties of this bug: 1. it only happens if pf:put and fn:doc are called in a module. The following sequence works fine: xquery>put(<bla/>,"tmp/text.xml") more>xquery>doc("tmp/text.xml") more><?xml version="1.0" encoding="utf-8"?> <bla/> xquery>put(<bladiebloe/>,"tmp/text.xml") xquery>doc("tmp/text.xml")xml") more><?xml version="1.0" encoding="utf-8"?> <bladiebloe/> xquery>doc("tmp/text.xml") more><?xml version="1.0" encoding="utf-8"?> <bladiebloe/> xquery> 2. I think the problem is not only in PUT, but more in the interleaving of PUT and GET. I can do multiple times PUT, and then multiple times GET. They all work fine: $ mapiclnt -lx PUT.xq # cq:PUT("tmp/test.xml", <bladieboe/>) $ mapiclnt -lx PUT1.xq # cq:PUT("tmp/test1.xml", <bladieboe1/>) $ mapiclnt -lx PUT2.xq # cq:PUT("tmp/test2.xml", <bladieboe2/>) $ mapiclnt -lx PUT3.xq # cq:PUT("tmp/test3.xml", <bladieboe3/>) $ mapiclnt -lx GET.xq <?xml version="1.0" encoding="utf-8"?> <bladieboe/> $ mapiclnt -lx GET1.xq <?xml version="1.0" encoding="utf-8"?> <bladieboe1/> $ mapiclnt -lx GET2.xq <?xml version="1.0" encoding="utf-8"?> <bladieboe2/> $ mapiclnt -lx GET3.xq <?xml version="1.0" encoding="utf-8"?> <bladieboe3/> But if I then do a PUT followed by a GET in the same Mserver session, Mserver crashes. 3. Something strange happens in the "tmp" dir. As you said, your second PUT seems to have worked, since the file has been created with the correct contents. After Mserver crashed, the files are still there, in the "tmp" directory. But, if you then restart Mserver, Mserver empties the whole "tmp" directory! # After Mserver crash the files are still in the "tmp" dir: [Thu Mar 8 12:45:54 CET 2007] [andorea:/net/andorea/export/scratch1/zhang/monet/stable/G.64.64.d.debug/var/MonetDB4/dbfarm/demo/tmp] $ ls -l total 16K -rw-rw-rw- 1 zhang ins 52 Mar 8 12:45 test.xml -rw-rw-rw- 1 zhang ins 53 Mar 8 12:45 test1.xml -rw-rw-rw- 1 zhang ins 53 Mar 8 12:45 test2.xml -rw-rw-rw- 1 zhang ins 53 Mar 8 12:45 test3.xml # After restarting Mserver, the dir is empty [Thu Mar 8 12:52:57 CET 2007] [andorea:/net/andorea/export/scratch1/zhang/monet/stable/G.64.64.d.debug/var/MonetDB4/dbfarm/demo/tmp] $ ls -l total 0 So, I'm going to fire a bug. Thanks for dicoverying this! Jennie
I checked the db-farm directory and after the crash it does contain: <?xml version="1.0" encoding="utf-8"?><bladiebloe/> So that seems to be OK.
The module looks as follows: ========================== module namespace cq = "http://db.cs.utwente.nl/cq#"; declare updating function cq:PUT($uri as xs:string, $doc as element()) { if (substring($uri, 1,4) = 'tmp/') then put($doc, $uri) else error('PUT: only relative URIs starting with tmp/ allowed') };
declare function cq:GET($uri as xs:string) { doc($uri) };
declare document management function cq:DELETE($uri as xs:string) { if (substring($uri, 1,4) = 'tmp/') then pf:del-doc($uri) ^^ I copied your module to have a try. But the pathfinder compiler complains about the namespace "pf":
$ pf twente.xq bad usage of XML namespaces: at (16,10-16,24): unknown namespace in qualified function name pf:del-doc # halted in ../../../compiler/semantics/ns.c (ns_resolve), line 837 I need to add the declaration of "pf" in the module: declare namespace pf = 'http://www.pathfinder-xquery.org/';
else error('DELETE: only relative URIs starting with tmp/ allowed') };
========================== The three test files look as follows: ========================== import module namespace cq = "http://db.cs.utwente.nl/cq#" at "/home/db/bunninge/phd/implementation/xquery/try3_module/ca_module.xq"; cq:PUT("tmp/test.xml",<bla/>) ========================== import module namespace cq = "http://db.cs.utwente.nl/cq#" at "/home/db/bunninge/phd/implementation/xquery/try3_module/ca_module.xq"; cq:GET("tmp/test.xml") ========================== import module namespace cq = "http://db.cs.utwente.nl/cq#" at "/home/db/bunninge/phd/implementation/xquery/try3_module/ca_module.xq"; cq:DELETE("tmp/test.xml")
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
participants (2)
-
Arthur van Bunningen
-
Ying Zhang