Changes

Jump to navigation Jump to search
605 bytes added ,  13:33, 20 July 2022
no edit summary
===Commands===
Database locking works All commands come with all commandsa detector for local locks. Global locking is applief applied if the glob syntax is used:
* {{Code|DROP DB new*}}: drop Drop all databases starting with "the prefix string {{Code|new"}}.
===XQuery===
Deciding which databases will be accessed With {{Announce|Version 10}}, [[BaseX 10#Compilation|lock detection was improved]] by a complex XQuery expression is a non-trivial tasksplitting compilation into multiple steps. Database detection works for the following types of queries:
* Local locks can be applied if it is possible at compile time to associate names of databases with database operations: {| class="wikitable"|-! Query! Description|-| {{Code|//item}}, read-locking | Read lock of the currently opened database opened by a client* |-| {{Code|doc('factbook')}}, read-locking | Read lock of "the {{Code|factbook"}} database|-* | {{Code|collection('dbdocuments/path/to/docs')}}, read| Read lock of the {{Code|documents}} database|-locking of "db"* | {{Code|delete nodes db:get('test')//*[string-length(local-name(.)) > 5]}}, write-locking | Write lock of "the {{Code|test"}} database|-* | {{Code|fn:sum(1 to 100)}} | ''no lock''|-| {{Code|for $db in ('db1', 'db2') return db:pre(no $db)}}| Read lockof {{Code|db1}} and {{Code|db2}}, as query is [[XQuery Optimization#Loop Unrolling|unrolled at compile time]].|-| {{Code|declare variables $db external; db:get($db)}}| Read lock of the database externally bound to {{Code|$db}}.|}
A global lock will be assigned if the name of the database is not a static string:
* {{Code|for $db in ('db1', 'db2') return db:get($db)}}
* {{Code|doc(doc('test')/reference/text())}}
* <code>let $db := 'test' return insert nodes <test/> into db:getpre($db)</code>
The functions {{Code|fn:doc}} and {{Code|fn:collection}} can also be used to address that are not stored in a database. However, this may lead to unwanted locks, and you have two options to reduce the number of locks: No database lookups will take place if {{Option|WITHDB}} option is disabled, or if {{Function|Fetch|fetch:doc}} is used instead of {{Code|fn:doc}}.
=Changelog=
 
;Version 10.0
* Updated: Lock detection was improved by splitting compilation into multiple steps.
;Version 9.4
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu