Skip to content
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

XQuery: Incorrect result count with multiple sequence operators #2225

Closed
Twilight-Shuxin opened this issue Jul 3, 2023 · 2 comments
Closed

Comments

@Twilight-Shuxin
Copy link

Description of the Problem

Given this XML document:

<I><A/><B/></I>

and XPath Query

//B/reverse(tail(reverse(subsequence(//*/has-children(), 3))))

BaseX returns one element false.

Expected Behavior

Should return empty result set. For node B, //*/has-children() selects the result of I, A, B three nodes. Applying subsequence(s, 3) selects only the last element, and after application of tail function no result should be selected. In terms of number of results returned, the two reverse() operations seems redundant in this case. If deleted BaseX returns the expected results.

Steps to Reproduce the Behavior

  1. Create database create database db <I><A/><B/></I>
  2. Execute XPath query xquery //B/reverse(tail(reverse(subsequence(//*/has-children(), 3))))

This is a reduced test case from:

  1. Create database create database db <I><A><B><C/></B></A><D/></I>
  2. Execute XPath query xquery //D/reverse(tail(reverse(subsequence(./preceding::*/has-children(), 3))))

Do you have an idea how to solve the issue?

No response

What is your configuration?

BaseX version: BaseX 10.7 beta latest commit 564bd39 on Windows

@ChristianGruen
Copy link
Member

Thanks as always! reverse(tail(reverse(...))) is rewritten to a function that will be introduced with XQuery 4.0 – fn:trunk – and the optimization rules of that function contained a bug.

@Twilight-Shuxin
Copy link
Author

Thanks also for the response speed always so impressive!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants