|
From: Dannes W. <no...@gi...> - 2026-07-16 19:41:29
|
Branch: refs/heads/develop Home: https://github.com/eXist-db/exist Commit: 28e1ed84c7b7dc986a7d59a61e285b58eafc8739 https://github.com/eXist-db/exist/commit/28e1ed84c7b7dc986a7d59a61e285b58eafc8739 Author: Joe Wicentowski <jo...@gm...> Date: 2026-06-24 (Wed, 24 Jun 2026) Changed paths: M exist-core/src/main/java/org/exist/xquery/LocationStep.java M exist-core/src/test/xquery/count.xql Log Message: ----------- [bugfix] Bind context item for trailing function-call path step on stored docs A trailing path step that is a function call whose argument is a relative child step (e.g. doc(...)/authors/author/places/count(place)) returned the wrong result on stored (persistent) documents: count(place) was evaluated once over the whole context instead of once per context item, counting every descendant (a single 5 instead of (2, 3)). The same query over an in-memory document was already correct. LocationStep.getDependencies() reports a CONTEXT_ITEM dependency for a step that is the initial step of its enclosing expression, so that PathExpr.eval() selects the per-item evaluation branch. It detected "initial step" lazily via parent.getSubExpression(0) == this. That test is unreliable at evaluation time because Function.checkArgument() rewrites the parent's child list after analysis, wrapping the argument in a DynamicCardinalityCheck. The wrapped LocationStep no longer matched parent.getSubExpression(0), so it dropped the CONTEXT_ITEM dependency and PathExpr.eval() fell through to the whole-context branch, which collapses the per-item multiplicity for an atomic-returning step. In-memory nodes were unaffected because PathExpr forces the per-item branch for memtree regardless of the dependency flags. Capture whether the step is the initial step during analyze(), before the parent's child list can be rewritten, and use the cached value in getDependencies(). Adds XQSuite regression tests in count.xql covering the stored-doc case, the in-memory case, and both of the workarounds from the issue (the simple map operator and copying the persistent tree into memory). Closes https://github.com/eXist-db/exist/issues/6521 Co-Authored-By: Claude Opus 4.8 (1M context) <no...@an...> Commit: 29b96e85b9cd08e0122f8e7a9a5c9c63467e7f6e https://github.com/eXist-db/exist/commit/29b96e85b9cd08e0122f8e7a9a5c9c63467e7f6e Author: Dannes Wessels <di...@us...> Date: 2026-07-16 (Thu, 16 Jul 2026) Changed paths: M exist-core/src/main/java/org/exist/xquery/LocationStep.java M exist-core/src/test/xquery/count.xql Log Message: ----------- Merge pull request #6522 from joewiz/bugfix/6521-path-step-context-item [bugfix] Bind context item for trailing function-call path step on stored docs Compare: https://github.com/eXist-db/exist/compare/089bd02b0866...29b96e85b9cd To unsubscribe from these emails, change your notification settings at https://github.com/eXist-db/exist/settings/notifications |