From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-general@postgresql.org
Subject: Re: query_to_xml() returns invalid XML when query returns no rows
Date: Mon, 12 Mar 2018 18:31:07 -0400
Message-ID: <fb97da86-2397-4ccb-38a4-38153de31df0@2ndquadrant.com> (raw)
In-Reply-To: <p85r3j$qtb$1@blaine.gmane.org>
References: <p85r3j$qtb$1@blaine.gmane.org>
On 3/12/18 08:18, Thomas Kellerer wrote:
> I am not sure if this qualifies as a bug:
>
> query_to_xml() returns an empty XML document when the query returns no rows, e.g:
>
> select query_to_xml('select 42 where false', false, true, '');
>
> The problem with this is, that if the resulting XML is then fed into e.g. the xpath() function, that function fails because the "empty" document is an invalid XML:
That's because you have the tableforest argument set to true. If you
want a proper XML document, then you should write
select query_to_xml('select 42 where false', false, false, '');
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
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-general@postgresql.org
Cc: peter.eisentraut@2ndquadrant.com, spam_eater@gmx.net
Subject: Re: query_to_xml() returns invalid XML when query returns no rows
In-Reply-To: <fb97da86-2397-4ccb-38a4-38153de31df0@2ndquadrant.com>
References: <p85r3j$qtb$1@blaine.gmane.org> <fb97da86-2397-4ccb-38a4-38153de31df0@2ndquadrant.com>
* 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