Changes

Jump to navigation Jump to search
169 bytes added ,  10:19, 21 July 2022
no edit summary
{| class="wikitable"
|-valign="top"
! Query
! Description
|-valign="top"
| <code>//item</code>
| Read lock of the currently opened database
|-valign="top"
| <code>doc('factbook')</code>
| Read lock of the {{Code|factbook}} database
|-valign="top"
| <code>collection('documents/path/to/docs')</code>
| Read lock of the {{Code|documents}} database
|-valign="top"
| <code>delete nodes db:get('test')//*[@type = 'misc']</code>
| Write lock of the {{Code|test}} database
|-valign="top"
| <code>declare variables $db external;<br/>db:get($db)</code>
| Read lock of the database externally bound to {{Code|$db}}.
|-valign="top"
| <code>for $db in ('db1', 'db2')<br/>return db:get($db)</code>
| Read lock of {{Code|db1}} and {{Code|db2}}, as the query is [[XQuery Optimizations#Loop Unrolling|unrolled at compile time]].
|-valign="top"
| <code>let $db := 'test'<br/>return insert nodes <test/> into db:get($db)</code>
| Read lock of {{Code|test}}, as the [[XQuery Optimizations#Variable_Inlining|variable is inlined]] at compile time.
|-valign="top"
| <code>sum(1 to 100)</code>
| No lock required
|-valign="top"
| <code>declare variable $SIMULATE := true();<br/>if($SIMULATE) then <doc/> else db:get('doc')</code>
| No lock required, as the query is simplified to {{Code|<doc/>}} at compile time.
{| class="wikitable"
|-valign="top"
! Query
! Description
|-valign="top"
| <code>db:get(doc('test')/reference/text())</code>
| The name of the database to be opened will only be known at evaluation time.
|-valign="top"
| <code>(1 to 100) ! db:get(concat('db', .))</code>
| The {{Option|UNROLLLIMIT}} can be increased to generate 100 {{Code|db:get}} function calls and corresponding locks.
Bureaucrats, editor, reviewer, Administrators
13,551

edits

Navigation menu