-
-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests for context item in functions #3167
Conversation
Phew this is a big one. Because of the amount of potential breakage i d put this on the 6.0.0 milestone (which might now happen rather soon) |
@duncdrum Do you see a potential for much breakage outside of broken XQSuite tests? I think it is probably just XQTS tests that might break and in the exist codebase it seems to be just those range index ones. |
I think that lots of folks might have xqsuite tests involving range indexes. Also god knows how many local functions rely on the faulty behavior. Does not scream 5.1.2 to me. |
@duncdrum tests on range indexes are fine. It's the tests in exist for range indexes which start without an explicit context item that have a problem, e.g. from
The above is invalid XQuery as it starts |
tests are failing... |
@dizzzz Exactly my point! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good find!
I would like to see a positive test as well. A function with an explicit context item.
It is again the question if the fix should be part of this PR or if this can be merged before the actual issue is fixed.
I think both belong together, especially since you might have an idea how to fix it.
I am still waiting on comments from @wolfgangmm |
@adamretter Is this still something you're hoping to include in 5.3.0? I see that in #3163 you mention that the combined fixes yield us another 4% passing in XQTS, so it's a big improvement. |
@joewiz I'm still waiting for input on it |
In todays community call, @wolfgangmm expressed a preference to fixing it with approach 1:
|
As @adamretter pointed out there are lots of positive tests present already. |
@adamretter setting both contextItem and contextSequence to null was also done for HOFs to fix #1960 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to see those tests implemented as XQSuite tests.
RootNode.java does not need to know where it is called. As long as every Function and UserDefinedFunction call nulls the context. |
@line-o Hmm! I am not sure it is that simple... Off the top of my head - wouldn't that possibly break things like |
@adamretter I see we have Wolfgang's agreement on the approach and Dannes' approval, but there are some remaining CI failures. Can this be merged, or is additional work needed to get passing CI results? I ask because I recall that this PR needs to be resolved in order for #3163. |
this PR is superseded by #3605 |
These tests show that eXist-db is incorrectly setting the context item inside both static and dynamic function calls.
According to https://www.w3.org/TR/xquery-31/#id-eval-function-call when evaluating the body of a function:
Unfortunately these tests show otherwise :-(
The issue is predominantly with
RootNode.java
which always establishes a context item, i.e. it is unaware of when it is inside aUserDefinedFunction.java
.I am not sure of the best way to fix this? I can see two options at the moment:
RootNode.java
aware that it is being called inside a function, and have it always throwXPDY0002
in that case.XQueryContext
so that the "focus (context item, context position, and context size)" is stack based and gets pushed down inUserDefinedFunction
before the body is eval'd, so that it is unavailable to the RootNode.@wolfgangmm thoughts please? it would be good to discuss it. Some of your XQSuite tests for the Range Index (
extensions/indexes/range/src/test/xquery/range/range.xql
) are relying on this incorrect behaviour, but I think they could be rewritten to start withfn:collection(...)
.In addition in
UserDefinedFunction
, the function body is evaluated like so:I suspect that should also be adjusted to: