2200L
Read PG 18 manual ↗not_an_xml_document
- SQLSTATE
- 2200L
- Condition name
- not_an_xml_document
- Class
- Data Exception
- Source macro
- ERRCODE_NOT_AN_XML_DOCUMENT
- Evidence
- Source path confirmed
English SQLSTATE atlas: authored explanations and source/runtime evidence are separate from the manual definitions. View source ↗
At a glance
The SQL/XML SQLSERIALIZE DOCUMENT operation received input that could not satisfy the requested document form. PostgreSQL 18.6 maps this public DOCUMENT path through xmltotext_with_options with XMLOPTION_DOCUMENT; a failed or soft parse is mapped to not an XML document. The wrapper’s early non-DOCUMENT/no-indent bypass is not a CONTENT-mode 2200L claim, and this entry does not cover every XML content or comment violation.
Meaning
This member is the document-level XML failure for the public SQL/XML SQLSERIALIZE DOCUMENT form. That operation reaches xmltotext_with_options with XMLOPTION_DOCUMENT; it calls xml_parse with an ErrorSaveContext, and when no document is returned or the saved parse error is set, the wrapper frees the partial document and raises 2200L. Its early guard returns binary-compatible input for non-DOCUMENT/no-indent, so this mapping should not be generalized to CONTENT. The lower xml_parse routine has separate 2200M/2200N branches, so this wrapper must not be read as a synonym for every parser error.
Messages
The SQLSERIALIZE DOCUMENT wrapper raises ERROR with primary not an XML document. The cited branch has no separate DETAIL or HINT; any parser-specific context must be taken from the actual runtime error and build.
Diagnosis
Capture the full context and the expression supplied to SQLSERIALIZE. Check whether the operation requested DOCUMENT or CONTENT, then inspect the document boundary, top-level structure, and encoding. A 2200L diagnosis is tied to the DOCUMENT mapping described above; do not infer it from a CONTENT request or conflate member codes 2200M/N/S/T with this document-level condition.
Response
Repair the XML document boundary and structure identified by the parser, preserving the caller’s required document-versus-fragment requirement.
When this branch raises ERROR, an explicit transaction must first be recovered with ROLLBACK or ROLLBACK TO SAVEPOINT for a savepoint established before the statement; in autocommit, retry only the corrected action after the failed statement completes. See the transaction and retry guide for this boundary rule.
Versions
The locked catalogue records this condition from 8.3.0; fixed source coverage is PostgreSQL 18.6.
Sources
Fixed source: src/backend/utils/adt/xml.c#L669-697. The structured evidence record retains the document-option guard, message, and scope boundaries. The source confirms the wrapper mapping; the precise input and any libxml2 context are runtime-dependent. No natural XML case was run for this page.
Source evidence
Evidence belongs to the frozen source and runtime versions listed here. It is not a runtime verification of the selected manual version.
The public SQLSERIALIZE DOCUMENT operation reaches xmltotext_with_options with XMLOPTION_DOCUMENT; when xml parsing fails or records a soft error, the wrapper maps that document conformance failure to 2200L with primary not an XML document.
Method: Read xml.c XML option mapping.
Limits: The wrapper returns binary-compatible input for non-DOCUMENT/no-indent before this check, so this evidence does not generalize the 2200L mapping to CONTENT; it is distinct from the 2200M invalid-document branch in xml_parse and from content/subconstruct errors.
The locked catalogue records 2200L from 8.3.0 without proving an exact implementation introduction date.
Method: Use catalogue boundary.
- src/backend/utils/errcodes.txt · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7 raw/calls/REL_18_6.jsonl· ·- src/backend/utils/adt/xml.c · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7
Message templates
ERROR · message.xml-document-option
Primary
not an XML document
Reproduction & repair cases
No reproduction case is attached to this condition.
Recorded runtime evidence
No runtime observation is attached to this entry.
Definition snapshot: english-manuals:700239ce3937fabfbe632254589… · English manual source