# 2200T — invalid_xml_processing_instruction

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

# 2200T

## At a glance {#at-a-glance}
An XML processing instruction violates its XML syntax. PostgreSQL 18.6’s `xmlpi` path rejects a target whose name is case-insensitively `xml`, or a non-NULL body containing `?>`; both guards report `invalid XML processing instruction` with a branch-specific DETAIL.

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

| Field | Value |
| --- | --- |
| SQLSTATE | `2200T` |
| Condition | `invalid_xml_processing_instruction` |
| 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_PROCESSING_INSTRUCTION` |
| Aliases | `—` |

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

## Meaning {#meaning}
This member is specific to XML processing-instruction syntax, including its target name and body. `xmlpi` checks the target with case-insensitive comparison, so `xml`, `XML`, and mixed-case forms hit the same target guard. Only after that syntax check does it apply the SQL NULL rule: a NULL body returns NULL for a valid target. A non-NULL body containing `?>` hits the body guard.

## Messages {#messages}

The target guard raises `ERROR` with primary `invalid XML processing instruction` and DETAIL `XML processing instruction target name cannot be "%s".`. The body guard uses the same primary and DETAIL `XML processing instruction cannot contain "?>".`. The cited branches have no separate HINT. `%s` is the runtime target name; a NULL body after a valid target is not a 2200T error.

## Diagnosis {#diagnosis}
Use the full message and detail to identify whether the target name or the instruction body is wrong. Check the target-name rule and remove the terminating `?>` sequence from the body while keeping the surrounding XML structure valid. Do not repair a comment or a general document error using this member’s rules.

## Response {#response}
Repair the target name or instruction body named by the detail, preserving valid XML structure and removing the forbidden processing-instruction form.

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/), [`2200S`](../2200s/)

## Sources {#sources}
Fixed source: [`src/backend/utils/adt/xml.c#L1010-1055`](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/xml.c#L1010-L1055). The structured [evidence record](../data/evidence/2200t.json) retains both guards, message/detail variants, NULL ordering, and scope boundaries. Target names and instruction content are runtime values; no natural XML runtime was run.
