collection('/test-db-1/bib')//Q{}libro versus collection('/test-db-1/bib')//libro
Sunday, 29 March 2020 · 3 messages · last reply 30 Mar 2020
MH
Martin Honnen29 Mar 2020 16:26 #
Using BaseX 9.3.2, why does a query
collection('/test-db-1/bib')//Q{}libro
return 6 items while
collection('/test-db-1/bib')//libro
gives 0 items?
If I run
collection('/test-db-1/bib')//Q{}libro, collection('/test-db-1/bib')//libro
the info window shows
Compiling:
- rewrite
fn:collection([uri]) to document-node() item:
collection("/test-db-1/bib") -> db:open-pre("test-db-1", 12000002)
- merge steps: descendant::element(libro)
- rewrite fn:collection([uri]) to document-node() item:
collection("/test-db-1/bib") -> db:open-pre("test-db-1", 12000002)
- remove step without results: element(libro)
- rewrite iter step to empty sequence: element(libro) -> ()
- rewrite cached path to empty sequence: db:open-pre("test-db-1", 12000002)/descendant-or-self::node()/() -> ()
- rewrite expression list to iter path: (db:open-pre("test-db-1", 12000002)/descendant::element(libro), ()) -> db:open-pre("test-db-1", 12000002)/descendant::element(libro)
Optimized Query:
db:open-pre("test-db-1", 12000002)/descendant::element(libro) Query:
collection('/test-db-1/bib')//Q{}libro, collection('/test-db-1/bib')//libro Result:
- Hit(s): 6 Items
- Updated: 0 Items
- Printed: 1455 b
- Read Locking: test-db-1
- Write Locking: (none)MH
Martin Honnen30 Mar 2020 11:26 #
Quoted text · Martin Honnen · 41 lines
Am 29.03.2020 um 16:26 schrieb Martin Honnen: > Using BaseX 9.3.2, why does a query > > collection('/test-db-1/bib')//Q{}libro > > return 6 items while > > collection('/test-db-1/bib')//libro > > gives 0 items? > > If I run > > collection('/test-db-1/bib')//Q{}libro, collection('/test-db-1/bib')//libro > > the info window shows > > > Compiling: > - rewrite fn:collection([uri]) to document-node() item: > collection("/test-db-1/bib") -> db:open-pre("test-db-1", 12000002) > - merge steps: descendant::element(libro) > - rewrite fn:collection([uri]) to document-node() item: > collection("/test-db-1/bib") -> db:open-pre("test-db-1", 12000002) > - remove step without results: element(libro) > - rewrite iter step to empty sequence: element(libro) -> () > - rewrite cached path to empty sequence: db:open-pre("test-db-1", > 12000002)/descendant-or-self::node()/() -> () > - rewrite expression list to iter path: (db:open-pre("test-db-1", > 12000002)/descendant::element(libro), ()) -> db:open-pre("test-db-1", > 12000002)/descendant::element(libro) > Optimized Query: > db:open-pre("test-db-1", 12000002)/descendant::element(libro) > Query: > collection('/test-db-1/bib')//Q{}libro, collection('/test-db-1/bib')//libro > Result: > - Hit(s): 6 Items > - Updated: 0 Items > - Printed: 1455 b > - Read Locking: test-db-1 > - Write Locking: (none)
It seems the problems occurs if I have one document in the db that has elements in a namespace and one with elements in no namespace.
So if there is only one document with no namespaces then both collection('/test-db-3/ex2')//foo and
collection('/test-db-3/ex2')//Q{}foo select the
foo elements in no namespace but if there is a document using a namespace as well in the db then collection('/test-db-3/ex2')//foo does not select the foo elements in no namespace.
Are there any db/namespace related settings in BaseX that cause that behaviour?CG
Christian Grün30 Mar 2020 16:39 #
Hi Martin,
Thanks for the analysis. As you’ve already indicated, the combination of documents with and without namespaces triggered an optimization that should only take effect if all documents of a database have the same default namespace
The bug has been fixed; a new snapshot is online [1,2].
Best,
Christian
[1] https://github.com/BaseXdb/basex/issues/1831
[2] http://files.basex.org/releases/latest/
Quoted text · Martin Honnen · 58 lines
On Mon, Mar 30, 2020 at 11:26 AM Martin Honnen <martin.honnen at gmx.de> wrote: > > Am 29.03.2020 um 16:26 schrieb Martin Honnen: > > Using BaseX 9.3.2, why does a query > > > > collection('/test-db-1/bib')//Q{}libro > > > > return 6 items while > > > > collection('/test-db-1/bib')//libro > > > > gives 0 items? > > > > If I run > > > > collection('/test-db-1/bib')//Q{}libro, collection('/test-db-1/bib')//libro > > > > the info window shows > > > > > > Compiling: > > - rewrite fn:collection([uri]) to document-node() item: > > collection("/test-db-1/bib") -> db:open-pre("test-db-1", 12000002) > > - merge steps: descendant::element(libro) > > - rewrite fn:collection([uri]) to document-node() item: > > collection("/test-db-1/bib") -> db:open-pre("test-db-1", 12000002) > > - remove step without results: element(libro) > > - rewrite iter step to empty sequence: element(libro) -> () > > - rewrite cached path to empty sequence: db:open-pre("test-db-1", > > 12000002)/descendant-or-self::node()/() -> () > > - rewrite expression list to iter path: (db:open-pre("test-db-1", > > 12000002)/descendant::element(libro), ()) -> db:open-pre("test-db-1", > > 12000002)/descendant::element(libro) > > Optimized Query: > > db:open-pre("test-db-1", 12000002)/descendant::element(libro) > > Query: > > collection('/test-db-1/bib')//Q{}libro, collection('/test-db-1/bib')//libro > > Result: > > - Hit(s): 6 Items > > - Updated: 0 Items > > - Printed: 1455 b > > - Read Locking: test-db-1 > > - Write Locking: (none) > > It seems the problems occurs if I have one document in the db that has > elements in a namespace and one with elements in no namespace. > > So if there is only one document with no namespaces then both > collection('/test-db-3/ex2')//foo and > collection('/test-db-3/ex2')//Q{}foo select the `foo` elements in no > namespace but if there is a document using a namespace as well in the db > then collection('/test-db-3/ex2')//foo does not select the `foo` > elements in no namespace. > > > Are there any db/namespace related settings in BaseX that cause that > behaviour? >
Written for BaseX 9.3. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery