select open change scope Open full search

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

SQLSTATE / CLASS 22 · DATA EXCEPTION

invalid_xml_content

SQLSTATE
2200N
Condition name
invalid_xml_content
Class
Data Exception
Source macro
ERRCODE_INVALID_XML_CONTENT
Evidence
Source path confirmed
Analysis & operational context

English SQLSTATE atlas: authored explanations and source/runtime evidence are separate from the manual definitions. View source ↗

<h1>2200N</h1>

At a glance

This member covers invalid XML content. PostgreSQL 18.6’s core XML parser has a content-mode declaration guard and content-parse guards that report 2200N; the original XML option determines whether a document parse failure is instead reported as 2200M.

Meaning

This member names invalid XML content at the parser’s CONTENT boundary. In content mode, an invalid XML declaration raises invalid XML content: invalid XML declaration with a detail produced by errdetail_for_xml_code(res_code). A failed balanced-content parse raises invalid XML content; if CONTENT input contains a DOCTYPE and is parsed as a document, the failed document parse still uses the original option to select 2200N. The same failed parser call uses 2200M when the original option was DOCUMENT. The declaration branch calls errsave and the content branches call xml_errsave: with an ErrorSaveContext these errors are saved and returned to the caller, while an ordinary context throws ERROR; that distinction is separate from the dynamic DETAIL text.

Messages

The cited branches raise ERROR with primary invalid XML content: invalid XML declaration for the declaration guard, with dynamic DETAIL from errdetail_for_xml_code(res_code), or primary invalid XML content for the later content/document parse failures. The declaration variant’s evidence template is dynamic errdetail_for_xml_code(res_code), not a fixed DETAIL string. No fixed universal DETAIL or HINT should be invented for those parser failures. 2200L is the outer document-option wrapper, while 2200S and 2200T identify comment and processing-instruction syntax.

Diagnosis

Read the complete parser message and the XML fragment or value it identifies. Check element names, character data, encoding, and the operation’s expected XML level. Follow a reported 2200L, 2200M, 2200S, or 2200T directly when the server emits one of those codes; do not choose 2200N from the word “invalid” alone.

Response

Correct the XML content at the element, character, or encoding boundary named by the diagnostic, and retain the actual code when validating the fix.

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 core source: src/backend/utils/adt/xml.c#L1780-1894. The shared xml_errsave/errsave helper defines the soft-error versus ordinary-throw behavior. The structured evidence record retains the declaration and content-parse guards, dynamic-detail boundary, and scope limits. Core availability depends on USE_LIBXML; 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.

2200N is invalid_xml_content in SQLSTATE Class 22.

Method: Read fixed definition.

src.errcodes.18.6

The core XML parser uses 2200N for failed content parsing and for an invalid XML declaration in content mode.

Method: Read both content-mode branches.

Limits: The XML declaration path adds a dynamic errdetail_for_xml_code result; do not publish a fabricated fixed DETAIL.

src.path.xml-invalid-content src.path.xml-content-parse

The XML declaration branch calls errsave and the content branches call xml_errsave; with an ErrorSaveContext these errors are saved and returned to the caller, while an ordinary context throws ERROR.

Method: Read the declaration/content calls and the xml_errsave helper.

Limits: The soft-error propagation distinction is separate from the dynamic DETAIL produced for XML declaration failures.

Core XML content parsing is compiled under the USE_LIBXML feature guard; build support and parser version affect availability and detail text.

Method: Read surrounding fixed source guards.

Limits: Source confirmation is not a natural runtime observation.

src.path.xml-content-parse

The locked catalogue records 2200N from 8.3.0 without proving an exact implementation introduction date.

Method: Use catalogue boundary.

src.errcodes.18.6

Message templates

ERROR · message.invalid-content

Primary

invalid XML content
ERROR · message.invalid-declaration

Primary

invalid XML content: invalid XML declaration

Detail

dynamic errdetail_for_xml_code(res_code)

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:3a5877f8251ae4d0d33f2e27428… · English manual source