BaseXdb / basex

BaseX Main Repository.
http://basex.org
BSD 3-Clause "New" or "Revised" License
661 stars 267 forks source link

XQuery: Bug on arithemetic operations with last() and position() #2220

Closed Twilight-Shuxin closed 1 year ago

Twilight-Shuxin commented 1 year ago

Description of the Problem

Given this XML document:

<S/>

and XPath Query

//S[last() * 150000 >= position()]

BaseX returns empty result set.

Expected Behavior

Should return node S as predicate evaluates to true.

Steps to Reproduce the Behavior

  1. Create database create database test <S/>
  2. Execute XPath query xquery //S[last() * 150000 >= position()]

Do you have an idea how to solve the issue?

It seems strange and might be related to overflow for changing the multiplication operand constant to smaller numbers BaseX functions as expected. However it seems like a bug for all integers involved including intermediate results are within integer range.

What is your configuration?

BaseX version: BaseX 10.7 beta latest commit 43fb2d5 on Windows

ChristianGruen commented 1 year ago

Thanks again. Your assumption about overflows was correct. We made the mistake of computing a long value instead of a double value.