Re: BUG #15908: Xpath operations fail - Mailing list pgsql-bugs

From Daniel Gustafsson
Subject Re: BUG #15908: Xpath operations fail
Date
Msg-id 3A26D5D1-D3FF-48DE-A9F2-C3B7BCC1367E@yesql.se
Whole thread Raw
In response to BUG #15908: Xpath operations fail  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
> On 16 Jul 2019, at 13:55, PG Bug reporting form <noreply@postgresql.org> wrote:

> --Incorrect, ASCII 'A', 'D', and 'test' > ASCII '2' or UT8 values as well.
> SELECT xpath('/row/c1', xmlrecord) as c1, xpath('/row/c2[@m=2 or not(@m)]',
> t.xmlrecord) as row, xpath('/row/c2[@m=2 or not(@m)]/text() >=
> ''2''',t.xmlrecord) VAL FROM test t;
> -- {<c1>Manual</c1>}  | {<c2>1</c2>,"<c2 m=\"2\">2</c2>"}    | {true}
> -- {<c1>Apropos</c1>} | {<c2>1</c2>,"<c2 m=\"2\">2</c2>"}    | {true}
> -- {<c1>Apropos</c1>} | {<c2>1</c2>,"<c2 m=\"2\">3</c2>"}    | {true}
> -- {<c1>Apropos</c1>} | {<c2>1</c2>,"<c2 m=\"2\">A</c2>"}    | {false}
> -- {<c1>Apropos</c1>} | {<c2>1</c2>,"<c2 m=\"2\">D</c2>"}    | {false}
> -- {<c1>Apropos</c1>} | {<c2>1</c2>,"<c2 m=\"2\">test</c2>"} | {false}

Far from being an exprt in this area, but AFAIK xpath() is evaluated as XPath
1.0 and according to the specification [1] only = and != comparison are defined:

   "When neither object to be compared is a node-set and the operator is <=, <,
    >= or >, then the objects are compared by converting both objects to
    numbers and comparing the numbers according to IEEE 754."

‘A', 'D' and ‘test’ are thus converted to floating point NaN’s.

cheers ./daniel

[1] https://www.w3.org/TR/1999/REC-xpath-19991116/#booleans


pgsql-bugs by date:

Previous
From: Mary Kellen Park
Date:
Subject: Re: PLEASE HELP!
Next
From: Daniel Gustafsson
Date:
Subject: Re: BUG #15912: The units of `autovacuum_vacuum_cost_delay` settingshould be documented