PostgreSQL Bugs

Collected from the PG bugs email list.

Bug ID15342
PG Version9.6.7
OSUbuntu 16; Ubuntu 18; Raspbian (Pi)
Opened2018-08-20 17:59:11+00
Reported byRyan Lambert

Body of first available message related to this bug follows.

The following bug has been logged on the website:

Bug reference:      15342
Logged by:          Ryan Lambert
Email address:      (redacted)
PostgreSQL version: 9.6.7
Operating system:   Ubuntu 16; Ubuntu 18; Raspbian (Pi)


It seems that `pg_dump` is unable to provide a reliable database backups
that include specific combinations of XML data.  The following SQL Fiddle
creates a table with three rows of XML data.  The first row, "Document, no
DOCTYPE" is the only row of the three that will always load from a backup
from `pg_dump`.  I've tried this one a few sub-versions of 9.6 and 9.5.!17/78a83/1/0

The second row added includes a DOCTYPE declaration in the XML.  Restoring
this row from pg_dump will fail unless you add `SET XML OPTION DOCUMENT;`.  
Trying to restore the pg_dump file without adding `SET XML OPTION DOCUMENT`

ERROR:  invalid XML content
DETAIL:  line 2: StartTag: invalid element name
  <!DOCTYPE document SYSTEM "subjects.dtd">
CONTEXT:  COPY xml_doc, line 2, column data: "<?xml version="1.0"
  <!DOCTYPE document SYSTEM "subjects.dtd">

The third row restores with the default setting but fails if `SET XML OPTION
DOCUMENT;` is set.

ERROR:  invalid XML document
DETAIL:  line 1: Start tag expected, '<' not found
CONTEXT:  COPY xml_doc, line 3, column data:

So it seems that if you have XML data that includes <!DOCTYPE> and other XML
that is just fragments... pg_dump won't work without manual tinkering and

The specific data I use that is hanging me up is the QGIS layer style data
(stored in `public.layer_styles`).


2018-08-20 17:59:11+00=?utf-8?q?PG_Bug_reporting_form?=BUG #15342: pg_dump - XML with mixed content types generates invalid backup file
2018-08-23 15:24:55+00Tom LaneRe: BUG #15342: pg_dump - XML with mixed content types generates invalid backup file