pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Set correct context for XPath evaluation
Date: Thu, 21 Jun 2018 19:58:12 +0000
Message-ID: <E1fW5ie-0003eO-I8@gemulon.postgresql.org> (raw)

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(-)



Message-ID: <E1fW5ie-0003eO-I8@gemulon.postgresql.org>
Permalink:  ../E1fW5ie-0003eO-I8@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1fW5ie-0003eO-I8@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: alvherre@alvh.no-ip.org
  Subject: Re: pgsql: Set correct context for XPath evaluation
  In-Reply-To: <E1fW5ie-0003eO-I8@gemulon.postgresql.org>
  References: <E1fW5ie-0003eO-I8@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox