# 2200S — invalid_xml_comment

> Source-backed reference for PostgreSQL SQLSTATE 2200S.
---

# 2200S

## At a glance {#at-a-glance}
An XML comment is invalid. PostgreSQL 18.6’s `xmlcomment` path reports `invalid XML comment` when the comment text contains the forbidden `--` sequence or ends in `-`; this is comment-specific XML syntax rather than a general document failure.

<!-- BEGIN SQLSTATE FACTS: generated by scripts/generate.py; do not edit -->

| Field | Value |
| --- | --- |
| SQLSTATE | `2200S` |
| Condition | `invalid_xml_comment` |
| Status | `active` |
| Known present by | `8.3.0` |
| Locked snapshots | `9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3` |
| Macros | `ERRCODE_INVALID_XML_COMMENT` |
| Aliases | `—` |

<!-- source facts: data/errcodes/2200S.json -->
<!-- END SQLSTATE FACTS -->

## Meaning {#meaning}
This member is specific to XML comment syntax, rather than to all XML document failures. Under `USE_LIBXML`, `xmlcomment` scans the input before constructing `<!--...-->`; a double hyphen anywhere or a trailing hyphen is rejected.

## Messages {#messages}

The guard raises `ERROR` with primary `invalid XML comment`. The cited branch has no separate DETAIL or HINT. Without `USE_LIBXML`, the function follows the separate XML-support path (`0A000`), so source presence does not by itself prove availability in every server build.

## Diagnosis {#diagnosis}
Inspect the comment text and the exact XML context named by the message. XML comments cannot contain the forbidden double-hyphen form or end with a hyphen; repair that comment while preserving surrounding markup. If the parser instead identifies a processing instruction or non-document content, follow 2200T or 2200L/N as reported.

## Response {#response}
Repair the comment text while preserving surrounding XML, following the comment-specific message rather than applying a general document workaround.

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](../guides/) 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}
[`2200L`](../2200l/), [`2200T`](../2200t/)

## Sources {#sources}
Fixed source: [`src/backend/utils/adt/xml.c#L490-523`](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/xml.c#L490-L523). The structured [evidence record](../data/evidence/2200s.json) retains the complete comment guard, message, and scope boundaries. The offending comment is runtime input and the function is compiled under `USE_LIBXML`; no natural XML runtime was run here.
