BUG #15517: JSONB_BUILD_ARRAY and JSON_BUILD_ARRAY omit XML Declaration (if present) from XML colums

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: mark(dot)drake(at)golden-hind(dot)com
Subject: BUG #15517: JSONB_BUILD_ARRAY and JSON_BUILD_ARRAY omit XML Declaration (if present) from XML colums
Date: 2018-11-22 18:40:08
Message-ID: 15517-f8fdb2e6b238eed0@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 15517
Logged by: Mark Drake
Email address: mark(dot)drake(at)golden-hind(dot)com
PostgreSQL version: 11.1
Operating system: Windows
Description:

postgres=# create table foo(x xml);
CREATE TABLE
postgres=# insert into foo values ('<XYZ>XXX</XYZ>');
INSERT 0 1
postgres=# insert into foo values ('<?xml
version="1.0"?><ABC>123</ABC>'::XML);
INSERT 0 1
postgres=# select x, x::text, JSONB_BUILD_ARRAY(x,x::text) from foo;
x | x |
jsonb_build_array
----------------+-------------------------------------+-------------------------------------------------------------
<XYZ>XXX</XYZ> | <XYZ>XXX</XYZ> | ["<XYZ>XXX</XYZ>",
"<XYZ>XXX</XYZ>"]
<ABC>123</ABC> | <?xml version="1.0"?><ABC>123</ABC> | ["<ABC>123</ABC>",
"<?xml version=\"1.0\"?><ABC>123</ABC>"]
(2 rows)

As can be seen the JSONB_BUILD_ARRAY of x has omitted the declaration. I
would have expected the declaration to be included in the output for column
X.

As can be seen a simple workaround is to generate based on the casting to
text. Not sure how much overhead (if any) this adds.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2018-11-22 20:21:20 Re: BUG #15514: process fails on jsonb_populate_recordset query. see simple example below
Previous Message Tom Lane 2018-11-22 17:01:58 Re: BUG #15516: Identifier not quoted with uppercase letter (spanish Ñ) doesn't get transformed to lowercase (ñ)