I went ahead and just tested these in DQ. Some of them were not what I
expected. Test code below summary:
Summary:
1. Two xdmp:document-insert()s on the same URI -> conflict
2. Two xdmp:node-replace()s on the same doc, same node -> conflict
3. Two xdmp:node-replace()s on the same doc, different nodes -> no conflict
4. Two xdmp:node-insert-after()s on the same node -> no conflict
5. Two xdmp:document-add-properties()s on the same doc -> no conflict
6. Two xdmp:document-set-property()s on the same doc, same property -> conflict
7. Two xdmp:document-set-property()s on the same doc, different properties ->
no conflict
8. xdmp:document-insert() and xdmp:document-add-properties() on the same doc ->
no conflict
Example code:
1.
let $doc := <root>hi</root>
let $inserted := xdmp:document-insert("/testdoc.xml", $doc)
return xdmp:document-insert("/testdoc.xml", $doc)
=> conflict
2.
let $doc := <root><message>Hi</message></root>
return xdmp:document-insert("/testdoc.xml", $doc)
;
let $doc := fn:doc("/testdoc.xml")
let $old-node := $doc/root/message
let $new-node := <message>Bye</message>
let $replace-one := xdmp:node-replace($old-node, $new-node)
let $replace-two := xdmp:node-replace($old-node, $new-node)
return ()
=> conflict
3.
let $doc := <root><message>Hi</message><time>yesterday</time></root>
return xdmp:document-insert("/testdoc.xml", $doc)
;
let $doc := fn:doc("/testdoc.xml")
let $old-node-one := $doc/root/message
let $new-node-one := <message>Bye</message>
let $old-node-two := $doc/root/time
let $new-node-two:= <time>today</time>
let $replace-one := xdmp:node-replace($old-node-one, $new-node-one)
let $replace-two := xdmp:node-replace($old-node-two, $new-node-two)
return ()
=> no conflict
4.
let $doc := <root><message>Hi</message></root>
return xdmp:document-insert("/testdoc.xml", $doc)
;
let $doc := fn:doc("/testdoc.xml")
let $node := $doc/root/message
let $insert-node-one := <time>today</time>
let $insert-node-two := <speaker>Bob</speaker>
let $insert-after-one := xdmp:node-insert-after($node, $insert-node-one)
let $insert-after-two:= xdmp:node-insert-after($node, $insert-node-two)
return ()
=> no conflict
5.
let $doc := <root><message>Hi</message></root>
return xdmp:document-insert("/testdoc.xml", $doc)
;
let $add-props-one := xdmp:document-add-properties("/testdoc.xml",
<flag>red</flag>)
let $add-props-two := xdmp:document-add-properties("/testdoc.xml",
<sound>loud</sound>)
return ()
=> no conflict (also adds duplicates is if repeat a property)
6.
let $doc := <root><message>Hi</message></root>
return xdmp:document-insert("/testdoc.xml", $doc)
;
let $add-props-one := xdmp:document-set-property("/testdoc.xml",
<flag>red</flag>)
let $add-props-one := xdmp:document-set-property("/testdoc.xml",
<flag>blue</flag>)
return ()
=> conflict
7.
let $doc := <root><message>Hi</message></root>
return xdmp:document-insert("/testdoc.xml", $doc)
;
let $add-props-one := xdmp:document-set-property("/testdoc.xml",
<flag>red</flag>)
let $add-props-one := xdmp:document-set-property("/testdoc.xml",
<sound>quiet</sound>)
return ()
=> no conflict (also, it set all "flag" props to "red" and all "sound" props to
"quiet" for the doc)
8.
let $doc := <root><message>Hi</message></root>
let $inserted := xdmp:document-insert("/testdoc.xml", $doc)
let $add-props-one := xdmp:document-set-property("/testdoc.xml",
<flag>red</flag>)
return ()
=> no conflict (apparently you can add a doc and set props in the same
transaction)
From: [email protected]
To: [email protected]
Date: Thu, 28 Oct 2010 10:52:17 -0600
Subject: Re: [MarkLogic Dev General] Conflicting updates
So let me see if I've got this right:
1. Two xdmp:document-insert()s on the same URI -> conflict
2. Two xdmp:node-replace()s on the same doc, same node -> conflict
3. Two xdmp:node-replace()s on the same doc, different nodes -> no conflict
4. Two xdmp:node-insert-after()s on the same node -> conflict (because order
would matter?)
5. Two xdmp:document-add-properties()s on the same doc -> conflict
6. Two xdmp:document-set-property()s on the same doc, same property -> conflict
7. Two xdmp:document-set-property()s on the same doc, different properties ->
no conflict
8. xdmp:document-insert() and xdmp:document-add-properties() on the same doc ->
conflict
I suppose I could just set up a test a run through them all to find out.
From: [email protected]
Date: Thu, 28 Oct 2010 08:49:08 -0700
To: [email protected]
Subject: Re: [MarkLogic Dev General] Conflicting updates
Just to clarify, the rule on conflicting updates is that all update actions you
specify as part of a request should be able to be executed in any order with
the same result. If that's not true, it's a conflicting update. There's
various reasons for this, the easiest of which is that XQuery is a functional
language and this is an aspect of that.
It means you can't, for example, add a node and then give it a child node.
Because that's order dependent. Nor can you delete a node and then delete its
parent. Again, order dependent.
You very much can, however, update the same document multiple times in the same
transaction, so long as you're dealing with different parts of the document so
that execution order of updates isn't important.
Writing the same document multiple times in a transaction would be, as Ryan
says, conflicting.
-jh-
On Oct 28, 2010, at 3:08 AM, [email protected] wrote:That error usually means
that two updates are being attempted on a document in the same transaction. I
looked at the code and I'm not seeing two updates so I'm wondering if maybe two
docs are being written with the same URI in the set of documents you are
loading?
From: [email protected]
To: [email protected]
Date: Thu, 28 Oct 2010 12:11:45 +0530
Subject: [MarkLogic Dev General] (no subject)
Hi, I am using the attached files to manipulate the xml data and then insert in
ML DB using record loader. I am getting the following
error:XDMP:OCNFLICTINGUPDATE Please let me know what I am doing wrong
Thnaks,Pragya**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely
for the use of the addressee(s). If you are not the intended recipient, please
notify the sender by e-mail and delete the original message. Further, you are
not
to copy, disclose, or distribute this e-mail or its contents to any other
person and
any such actions are unlawful. This e-mail may contain viruses. Infosys has
taken
every reasonable precaution to minimize this risk, but is not liable for any
damage
you may sustain as a result of any virus in this e-mail. You should carry out
your
own virus checks before opening the e-mail or attachment. Infosys reserves the
right to monitor and review the content of all messages sent to or from this
e-mail
address. Messages sent to or from this e-mail address may be stored on the
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***
_______________________________________________ General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general