↑↓ select↵ open⌫ change scopeOpen full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Wiki / SQLSTATE

2200L — not_an_xml_document

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 xmltotextwithoptions 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.

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
not_an_xml_document
lang
en
sqlstate
2200L

Definition PG 18

2200L

At a glance {#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 {#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 {#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 {#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 {#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 {#versions}

The locked catalogue records this condition from 8.3.0; fixed source coverage is PostgreSQL 18.6.

Related {#related}

2200M, 2200N, 2200S, 2200T

Sources {#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.

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": "2200L is not_an_xml_document in SQLSTATE Class 22."
}
claims · mechanism.xml-document-option
{
  "claim_id": "mechanism.xml-document-option",
  "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.",
  "method": "Read xml.c XML option mapping.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.path.xml-document-option"
  ],
  "statement": "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."
}
claims · history
{
  "claim_id": "history",
  "limits": "",
  "method": "Use catalogue boundary.",
  "position": 2,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "The locked catalogue records 2200L from 8.3.0 without proving an exact implementation introduction date."
}
messages · message.xml-document-option
{
  "limits": "",
  "message_id": "message.xml-document-option",
  "path": "",
  "position": 0,
  "raw": {
    "id": "message.xml-document-option",
    "primary_template": "not an XML document",
    "severity_source": "ERROR",
    "sources": [
      "src.path.xml-document-option"
    ],
    "sqlstate": "2200L"
  },
  "severity": "ERROR",
  "sources": [
    "src.path.xml-document-option"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "not an XML document",
      "position": 0,
      "role": "",
      "template": "not an 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#L210"
}
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-document-option
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/adt/xml.c",
  "position": 2,
  "sha256": "f1c70b5ee5ee9a20a41d9b2c27bc7a8a50dbd47d9489ba462a4a678f7f55f14d",
  "source_id": "src.path.xml-document-option",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/xml.c#L669-L697"
}

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · english-manuals:60da6ac1b79ae99649dc75108beff9a0982f5ab42b3183ab743aedc48b874c78

Text language: en · english-manuals:60da6ac1b79ae99649dc75108beff9a0982f5ab42b3183ab743aedc48b874c78