Bug #22823 gt and lt operators appear to be reversed in ExtractValue() command
Submitted: 29 Sep 2006 13:04 Modified: 17 Nov 2006 16:20
Reporter: Vincent Fumo Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: XML functions Severity:S2 (Serious)
Version:5.1.11 OS:Microsoft Windows (Windows)
Assigned to: Alexander Barkov
Tags: ExtractValue, XML, XPath

[29 Sep 2006 13:04] Vincent Fumo
Description:
In reguards to XPath evaluation of integer and floating point values, the greater than and less than operators appear to have been implemented in reverse.

How to repeat:
If you run the following select statement:

SELECT
ExtractValue(
'<entry><id>foo</id><pt>10</pt></entry><entry><id>bar</id><pt>50</pt></entry>',
'/entry[(pt < 9)]/id'
);

the result you get is: 'foo bar' where you would expect to get 0 results. If you reverse the '<' operator as follows:

SELECT
ExtractValue(
'<entry><id>foo</id><pt>10</pt></entry><entry><id>bar</id><pt>50</pt></entry>',
'/entry[(pt > 9)]/id'
);

you get 0 results.

This can be repeated using floating points as well.

Suggested fix:
Reverse the implementation of the operarors when they are used to evaluate integers and floating point values.
[17 Oct 2006 7:38] Hartmut Holzgraefe
mysqltest test case

Attachment: bug22823.tar.gz (application/x-gzip, text), 786 bytes.

[23 Oct 2006 9:17] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/14159

ChangeSet@1.2310, 2006-10-23 14:17:57+05:00, bar@mysql.com +3 -0
  Bug#22823 gt and lt operators appear to be reversed in ExtractValue() command
  Problem: "greater than" and "less than" XPath operators appeared to have been implemented in reverse.
  Fix: swap arguments to eq_func() and eq_func_reverse() to provide correct operation result.
[3 Nov 2006 11:59] Alexander Barkov
Pushed into 5.1.13-rpl
[16 Nov 2006 16:46] Alexander Barkov
Appeared in 5.1.14 common
[17 Nov 2006 16:20] Jon Stephens
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release.

If necessary, you can access the source repository and build the latest available version, including the bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html

Documented bugfix in 5.1.14 changelog.