Dear Paul, Thanks for your observation, and thanks for reporting it to the mailing list; indeed it’s the best place for all notifications and feature requests.
You’ve encountered a bug that was seemingly introduced with BaseX 9.3, and was the side effect of a premature index rewriting. The bug has been fixed [1] and a new snapshot is available [2]. BaseX 9.4.4 will be released later this month. Hope this helps, Christian [1] https://github.com/BaseXdb/basex/issues/1948 [2] https://files.basex.org/releases/latest/ On Wed, Oct 7, 2020 at 10:06 PM Paul L. Merchant Jr. <paul.l.merchant...@dartmouth.edu> wrote: > > Greetings everyone, I'm evaluating whether BaseX 9.4.3 might be suitable for > my projects and I think I've run into an XQuery optimizer bug that's easily > reproducible. I've got a test database "test-db" with two identical > documents containing minimal xml: "<doc title='a-document'/>". The > documents are stored in separate directories: > > test-db > |- a/doc.xml > |- b/doc.xml > > The XQuery I'm using I believe should retrieve only the document in path a, > but I'm getting different results depending on whether I write the expression > in a single let statement or two separate statements: > > > declare function local:show-paths($nodes as node()*) as node()* { > for $p in $nodes > return <path>{$p/base-uri()}</path> > }; > > let $docs_1 := collection('test-db/a')/doc[@title='a-document'] > > let $col := collection('test-db/a') > let $docs_2 := $col/doc[@title='a-document'] > > return > <result> > <single-expr expr_docs="{count($docs_1)}"/> > <single-expr-paths>{local:show-paths($docs_1)}</single-expr-paths> > <split-expr collection_docs="{count($col)}" expr_docs="{count($docs_2)}"/> > <split-expr-paths>{local:show-paths($docs_2)}</split-expr-paths> > </result> > > This code produces this result: > > <result> > <single-expr expr_docs="1"/> > <single-expr-paths> > <path>/test-db/a/doc.xml</path> > </single-expr-paths> > <split-expr collection_docs="1" expr_docs="2"/> > <split-expr-paths> > <path>/test-db/a/doc.xml</path> > <path>/test-db/b/doc.xml</path> > </split-expr-paths> > </result> > > I'd expect the expr_docs values for both single-expr and split-expr to be the > same. > > I'm happy to file this in the GitHub issue tracker, but as a newcomer to > BaseX I thought I should checkin with the list first. > > What are you thoughts and wishes? > > Thanks, > > -- Paul