pgsql: Set correct context for XPath evaluation

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Set correct context for XPath evaluation
Date: 2018-06-21 19:58:12
Message-ID: E1fW5ie-0003eO-I8@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Set correct context for XPath evaluation

According to the SQL standard, the context of XMLTABLE's XPath
row_expression is the document node of the XML input document, not the
root node. This becomes visible when a relative path rather than
absolute is used as row expression. Absolute paths is what was used in
original tests and docs (and the most common form used in examples
throughout the interwebs), which explains why this wasn't noticed
before.

Other functions such as xpath() and xpath_exists() also have this
problem. While not specified by the SQL standard, it would be pretty
odd to leave those functions to behave differently than XMLTABLE, so
change them too. However, this is a backwards-incompatible change.

No backpatch, out of fear of breaking code depending on the original
broken behavior.

Author: Markus Winand
Reported-By: Markus Winand
Reviewed-by: Álvaro Herrera
Discussion: https://postgr.es/m/0684A598-002C-42A2-AE12-F024A324EAE4@winand.at

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e474c2b7e4b656895d6afcbd36857c9ebb0fcedd

Modified Files
--------------
src/backend/utils/adt/xml.c | 10 ++--------
src/test/regress/expected/xml.out | 8 +++++++-
src/test/regress/expected/xml_1.out | 12 +++++++++---
src/test/regress/expected/xml_2.out | 8 +++++++-
src/test/regress/sql/xml.sql | 3 ++-
5 files changed, 27 insertions(+), 14 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2018-06-21 20:18:58 pgsql: Fix partial aggregation for variance(int4) and related aggregate
Previous Message Tom Lane 2018-06-21 16:37:26 pgsql: Improve requirements documentation for ldap test suite.