Re: BUG #15908: Xpath operations fail

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: rvincent(at)temenos(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #15908: Xpath operations fail
Date: 2019-07-17 15:40:25
Message-ID: 3A26D5D1-D3FF-48DE-A9F2-C3B7BCC1367E@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

> On 16 Jul 2019, at 13:55, PG Bug reporting form <noreply(at)postgresql(dot)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[(at)m=2 or not(@m)]',
> t.xmlrecord) as row, xpath('/row/c2[(at)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Daniel Gustafsson 2019-07-17 16:03:09 Re: BUG #15912: The units of `autovacuum_vacuum_cost_delay` setting should be documented
Previous Message Mary Kellen Park 2019-07-17 14:54:03 Re: PLEASE HELP!