FOTS: 'castable as' issues with numeric values

Bug #1077206 reported by Sorin Marian Nasoi
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Zorba
Fix Released
High
Markos Zaharioudakis

Bug Description

Here are some examples of wrong results from 'castable as'.
ZORBA_WITH_BIG_INTEGER set to OFF/ON makes no difference:

-129 castable as xs:byte
returns true
http://www.w3.org/TR/xmlschema-2/#byte mentions the "minInclusive· to be -128" ...

1.7976931348623157E+308 castable as xs:decimal
returns true

2147483648 castable as xs:int
returns true

1.7976931348623157E+308 castable as xs:integer
returns true

-9223372036854775809 castable as xs:long
returns true for ZORBA_WITH_BIG_INTEGER set to ON, err:FOAR0002 otherwise which is correct

Basically the same error happens with every numeric data type.

More examples include (but are not limited to):
From the "prod-CastableExpr":

"cbcl-castable-byte-001,cbcl-castable-byte-002, cbcl-castable-decimal-007,cbcl-castable-decimal-008,cbcl-castable-decimal-009,cbcl-castable-decimal-010,cbcl-castable-duration-001,cbcl-castable-duration-002,cbcl-castable-int-001,cbcl-castable-int-002,cbcl-castable-integer-001,cbcl-castable-integer-002,cbcl-castable-integer-003,cbcl-castable-integer-004,cbcl-castable-long-001,cbcl-castable-long-002,cbcl-castable-negativeInteger-001,cbcl-castable-nonNegativeInteger-001,cbcl-castable-nonPositiveInteger-001,cbcl-castable-positiveInteger-001,cbcl-castable-short-001,cbcl-castable-short-002,cbcl-castable-unsignedByte-001,cbcl-castable-unsignedByte-002,cbcl-castable-unsignedInt-001,cbcl-castable-unsignedInt-002,cbcl-castable-unsignedLong-001,cbcl-castable-unsignedLong-002,cbcl-castable-unsignedShort-001,cbcl-castable-unsignedShort-002"

Tags: fots

Related branches

Revision history for this message
Sorin Marian Nasoi (sorin.marian.nasoi) wrote :

@Markos: please reassign if needed.
I assigned it to you because this could be related to some optimisation issue.

description: updated
Revision history for this message
Sorin Marian Nasoi (sorin.marian.nasoi) wrote : Re: FOST: 'castable as' issues with numeric values

Reassigned the numeric failures to Paul as Markos suggested.

summary: - FOST: 'castable as' issues
+ FOST: 'castable as' issues with numeric values
description: updated
Changed in zorba:
assignee: Markos Zaharioudakis (markos-za) → Paul J. Lucas (paul-lucas)
description: updated
Changed in zorba:
status: New → In Progress
Revision history for this message
Paul J. Lucas (paul-lucas) wrote :

I figured out that the ATOMIC_CAST_MATRIX in root_typemanager.cpp was wrong for several types. According to "bzr blame," Markos is the author of this code. I fixed the obviously wrong matrix entries -- you're welcome. Assigning to Markos for review and follow-up.

Changed in zorba:
assignee: Paul J. Lucas (paul-lucas) → Markos Zaharioudakis (markos-za)
Revision history for this message
Markos Zaharioudakis (markos-za) wrote :

Where is the fix in ATOMIC_CAST_MATRIX? I didn't see any commit in the trunk. Is it in a branch?
And no, I am not the original author of this code (Vinayak is).

Revision history for this message
Sorin Marian Nasoi (sorin.marian.nasoi) wrote :

Just wanted to mention that merge proposal
https://code.launchpad.net/~zorba-coders/zorba/bug-1077206/+merge/134797
was not a complete fix for this bug although linking the bug no. to a merge proposal in a way implies that the bug is fixed by the merge proposal.

for instance the query:
-129 castable as xs:byte
still returns true.

Same is true for the other queries mentioned in the original report.

Revision history for this message
Markos Zaharioudakis (markos-za) wrote :

Sorin, -129 castable as xs:byte returns false for me. Can you double check please?

Revision history for this message
Markos Zaharioudakis (markos-za) wrote :

With BIG_INTEGERS=ON, the following cases in the prod-CastableExpr fail still:

1. Castable-UnionType-1
2. Castable-ListType-2

This is not a bug, but a missing V3.0 extension: In V1.0, the target type must be an atomic type. In V3.0, it can be a simple type.

3. cbcl-castable-decimal-007
4. cbcl-castable-decimal-008
5. cbcl-castable-decimal-009
6. cbcl-castable-decimal-010
7. cbcl-castable-integer-001
8. cbcl-castable-integer-002
9. cbcl-castable-integer-003
10. cbcl-castable-integer-004

I don't understand why the expected result of these is "false". I think this is actually a FOTS bug (the expected result should be "true", assuming the implementation does not pose any upper bounds on integers and decimals)

Revision history for this message
Sorin Marian Nasoi (sorin.marian.nasoi) wrote :

Hi Markos: I can confirm that indeed after a clean build I see that 20 of the reported tests were fixed: thanks for the help.

Can you please file 2 bugs with W3C for the issue you reported:
- one for the missing XQuery 3.0 dependency in test cases Castable-UnionType-1 and Castable-ListType-2

- one for the other 8 test cases ( cbcl-castable-decimal-007 through cbcl-castable-decimal-010 and cbcl-castable-integer-001 through cbcl-castable-integer-004).
I have checked the latest version of the test set:
http://dev.w3.org/cvsweb/2011/QT3-test-suite/prod/CastableExpr.xml?rev=1.10;content-type=text%2Fplain
and there is no environment setting whatsoever for these test cases

In order to report a bug with W3C for FOTS please select these:
- first choose 'XPath / XQuery / XSLT'
- choose the 'XQuery 3 and XPath 3 Test Suite' component
HTH.

Adding the 2 bug reports with W3C will allow us to mark this bug as 'fix committed'.

Chris Hillery (ceejatec)
summary: - FOST: 'castable as' issues with numeric values
+ FOTS: 'castable as' issues with numeric values
Revision history for this message
Sorin Marian Nasoi (sorin.marian.nasoi) wrote :

Added lp:1090251 for the remaining unsolved test cases that were originally reported.

Marking this bug as "Fix committed".

Changed in zorba:
status: In Progress → Fix Committed
Changed in zorba:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.