BUG #16091: xpath fails to compute "name()", regression

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

BUG #16091: xpath fails to compute "name()", regression

apt.postgresql.org Repository Update
The following bug has been logged on the website:

Bug reference:      16091
Logged by:          Yuri Cherio
Email address:      [hidden email]
PostgreSQL version: 12.0
Operating system:   Ubuntu Linux 18.04
Description:        

After upgrading postgresql from 9 to 12 the following statement no longer
produces the same result: SELECT xpath('name()', '<abc>xyz</abc>'::XML)

PostgreSQL 9 returns '{abc}'
PostgreSQL 12 returns '{""}'

This behavior changed in version 11 and perpetuated into 12.

Reply | Threaded
Open this post in threaded view
|

Re: BUG #16091: xpath fails to compute "name()", regression

Tom Lane-2
PG Bug reporting form <[hidden email]> writes:
> After upgrading postgresql from 9 to 12 the following statement no longer
> produces the same result: SELECT xpath('name()', '<abc>xyz</abc>'::XML)

> PostgreSQL 9 returns '{abc}'
> PostgreSQL 12 returns '{""}'

> This behavior changed in version 11 and perpetuated into 12.

This looks to me to be an intentional change in xpath's behavior.
The v11 release notes call out the incompatibility:

    Correctly handle relative path expressions in xmltable(), xpath(), and
    other XML-handling functions (Markus Winand)

    Per the SQL standard, relative paths start from the document node of
    the XML input document, not the root node as these functions
    previously did.

Perhaps 'name(/*)' would do what you want now.

                        regards, tom lane


Reply | Threaded
Open this post in threaded view
|

Re: BUG #16091: xpath fails to compute "name()", regression

Cherio
Thanks Tom,

This is what we essentially did to make the old code work.
I guess you are saying this is not considered a regression.
Than this is not a bug.

On Wed, Oct 30, 2019 at 2:10 PM Tom Lane <[hidden email]> wrote:
PG Bug reporting form <[hidden email]> writes:
> After upgrading postgresql from 9 to 12 the following statement no longer
> produces the same result: SELECT xpath('name()', '<abc>xyz</abc>'::XML)

> PostgreSQL 9 returns '{abc}'
> PostgreSQL 12 returns '{""}'

> This behavior changed in version 11 and perpetuated into 12.

This looks to me to be an intentional change in xpath's behavior.
The v11 release notes call out the incompatibility:

    Correctly handle relative path expressions in xmltable(), xpath(), and
    other XML-handling functions (Markus Winand)

    Per the SQL standard, relative paths start from the document node of
    the XML input document, not the root node as these functions
    previously did.

Perhaps 'name(/*)' would do what you want now.

                        regards, tom lane