• Alvaro Herrera's avatar
    Set correct context for XPath evaluation · e474c2b7
    Alvaro Herrera authored
    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
    e474c2b7
xml_1.out 69.1 KB