2200M — invalid_xml_document
This catalogue member denotes an invalid XML document. PostgreSQL 18.6 has a core xml_parse document branch that reports invalid XML document, and the contrib/xml2 XSLT path reports the same SQLSTATE for a failed source document or stylesheet parse. These are distinct emitters from the 2200L document-option wrapper.
English manual coverage begins with PostgreSQL 8.1. Source history and runtime observations have their own recorded version boundaries.
Reading PG 18·Select a recorded version
- aliases
- Unknown
- class name
- Data Exception
- condition name
- invalid_xml_document
- lang
- en
- sqlstate
- 2200M
Definition PG 18
2200M
At a glance {#at-a-glance}
This catalogue member denotes an invalid XML document. PostgreSQL 18.6 has a core xml_parse document branch that reports invalid XML document, and the contrib/xml2 XSLT path reports the same SQLSTATE for a failed source document or stylesheet parse. These are distinct emitters from the 2200L document-option wrapper.
Meaning {#meaning}
This member names an invalid XML document condition from a concrete document parser guard. In core xml_parse, a failed xmlCtxtReadDoc parse reports 2200M when the original XML option was DOCUMENT; when the original option was CONTENT, the same parser failure reports 2200N. The separate contrib/xml2 functions use 2200M when parsing the input document or stylesheet as XML. The core xml_errsave helper passes these results to errsave: an ErrorSaveContext stores the error and returns, while an ordinary context throws; this soft-error path is distinct from the direct ERROR branches in contrib/xml2.
Messages {#messages}
The core branch raises ERROR with primary invalid XML document. The contrib/xml2 branches raise ERROR with primary error parsing XML document or error parsing stylesheet as XML document. The cited branches do not provide a fixed DETAIL or HINT template; libxml2 context can be attached dynamically. Do not replace these messages with 2200L’s not an XML document.
Diagnosis {#diagnosis}
Use the actual SQLSTATE, message, detail, and context to distinguish document-level failure from invalid content (2200N), comment (2200S), or processing instruction (2200T). Inspect whether the producer is core xml_parse or contrib/xml2, then correct the named document or stylesheet. These emitters are source-confirmed here; no natural runtime was run.
Response {#response}
Use the actual message and parser context to repair the invalid document; do not substitute a 2200L fix without confirming the emitted SQLSTATE.
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 {#versions}
The locked catalogue records this condition from 8.3.0; fixed source coverage is PostgreSQL 18.6.
Related {#related}
Sources {#sources}
Fixed core source: src/backend/utils/adt/xml.c#L1780-1862. The separate contrib/xml2/xslt_proc.c#L84-100 paths parse an XML document and stylesheet. The shared xml_errsave/errsave helper defines the soft-error versus ordinary-throw behavior. The structured evidence record retains both emitters, message roles, and scope boundaries. Core availability depends on USE_LIBXML; no natural XML case was run for this page.
Compare versions
SQLSTATE evidence and recorded runtime versions
claims · identity
{
"claim_id": "identity",
"limits": "",
"method": "Read fixed definition.",
"position": 0,
"runtime": [],
"sources": [
"src.errcodes.18.6"
],
"statement": "2200M is invalid_xml_document in SQLSTATE Class 22."
}claims · mechanism.core-xml
{
"claim_id": "mechanism.core-xml",
"limits": "The dynamic libxml diagnostic may be attached separately; no single static DETAIL template should be invented.",
"method": "Read the document parse failure branch.",
"position": 1,
"runtime": [],
"sources": [
"src.path.xml-invalid-document"
],
"statement": "The core xml_parse document branch maps a failed libxml document parse to 2200M with primary invalid XML document."
}claims · mechanism.error-save
{
"claim_id": "mechanism.error-save",
"limits": "This source distinction describes error propagation; it is not a natural runtime observation.",
"method": "Read the xml_errsave comment and errsave call.",
"position": 2,
"runtime": [],
"sources": [],
"statement": "The core xml_errsave helper passes XML errors to errsave: an ErrorSaveContext stores the error and returns, while an ordinary context throws; this soft-error path is distinct from the direct ERROR branches in contrib/xml2."
}claims · mechanism.xml2
{
"claim_id": "mechanism.xml2",
"limits": "This path requires the xml2 extension and is separate from core XML constructors.",
"method": "Read the complete xml2 error branch.",
"position": 3,
"runtime": [],
"sources": [
"src.path.xml2-document"
],
"statement": "The contrib/xml2 XSLT path also reports invalid XML document when its parser reports an error."
}claims · build-boundary
{
"claim_id": "build-boundary",
"limits": "Source confirmation is not a natural runtime observation.",
"method": "Read surrounding fixed source guards.",
"position": 4,
"runtime": [],
"sources": [
"src.path.xml-invalid-document"
],
"statement": "Core XML branches are compiled under the USE_LIBXML feature guard; availability depends on the server build."
}claims · history
{
"claim_id": "history",
"limits": "",
"method": "Use catalogue boundary.",
"position": 5,
"runtime": [],
"sources": [
"src.errcodes.18.6"
],
"statement": "The locked catalogue records 2200M from 8.3.0 without proving an exact implementation introduction date."
}messages · message.core-document
{
"limits": "",
"message_id": "message.core-document",
"path": "",
"position": 0,
"raw": {
"id": "message.core-document",
"primary_template": "invalid XML document",
"severity_source": "ERROR",
"sources": [
"src.path.xml-invalid-document"
],
"sqlstate": "2200M"
},
"severity": "ERROR",
"sources": [
"src.path.xml-invalid-document"
],
"templates": [
{
"kind": "primary",
"literal": "invalid XML document",
"position": 0,
"role": "",
"template": "invalid XML document"
}
]
}messages · message.xml2-document
{
"limits": "",
"message_id": "message.xml2-document",
"path": "",
"position": 1,
"raw": {
"id": "message.xml2-document",
"primary_template": "error parsing XML document",
"severity_source": "ERROR",
"sources": [
"src.path.xml2-document"
],
"sqlstate": "2200M"
},
"severity": "ERROR",
"sources": [
"src.path.xml2-document"
],
"templates": [
{
"kind": "primary",
"literal": "error parsing XML document",
"position": 0,
"role": "",
"template": "error parsing XML document"
}
]
}sources · src.errcodes.18.6
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/errcodes.txt",
"position": 0,
"sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
"source_id": "src.errcodes.18.6",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L211"
}sources · src.calls.REL_18_6
{
"commit": "",
"docs_url": "",
"kind": "local_artifact",
"location": "",
"path": "raw/calls/REL_18_6.jsonl",
"position": 1,
"sha256": "9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf",
"source_id": "src.calls.REL_18_6",
"tag": "",
"url": ""
}sources · src.path.xml-invalid-document
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/adt/xml.c",
"position": 2,
"sha256": "f1c70b5ee5ee9a20a41d9b2c27bc7a8a50dbd47d9489ba462a4a678f7f55f14d",
"source_id": "src.path.xml-invalid-document",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/xml.c#L1846-L1862"
}sources · src.path.xml2-document
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "contrib/xml2/xslt_proc.c",
"position": 3,
"sha256": "a5a76f59e851175955dfa62477fd4a7d7be3fb69b37e7a7e955ab76c8e01d0ae",
"source_id": "src.path.xml2-document",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/contrib/xml2/xslt_proc.c#L84-L100"
}sources · src.path.xml-error-save
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/adt/xml.c",
"position": 4,
"sha256": "f1c70b5ee5ee9a20a41d9b2c27bc7a8a50dbd47d9489ba462a4a678f7f55f14d",
"source_id": "src.path.xml-error-save",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/xml.c#L2047-L2082"
}Source references
Full definition and evidence JSON
Definition sources
center · PostgreSQL 18 · english-manuals:5cf75ff3965b358c66a63b051df95fd3c7e7158d843a7e3c1a8b12d418ac641b
Text language: en · english-manuals:5cf75ff3965b358c66a63b051df95fd3c7e7158d843a7e3c1a8b12d418ac641b