Incident brief
Invalid XML processing instruction
xmlpi() rejects an illegal processing-instruction target; the name 'xml' (in any case) is reserved and cannot be used as a target.
What lands in your log
ERROR: invalid XML processing instruction
In 10 seconds
- What triggers it
- Call xmlpi(name xml, 'payload') using 'xml' as the processing-instruction target.
- Fix
- Use a non-reserved target name for the processing instruction.
- Proof
- Reproduced on PostgreSQL 18.4 → A single SELECT reproduces SQLSTATE 2200T; the reserved target 'xml' is rejected with a DETAIL saying so.
Fix
What to do right now
Application-level steps for this error.
- Use a non-reserved target name for the processing instruction.
- Rename any 'xml'-prefixed target to an application-specific name.
-- The PI target name 'xml' is reserved; use another name.
SELECT xmlpi(name proc, 'payload');For this error
See this error live on the server
Run these against the affected instance to confirm the diagnosis before you act.
Invalid XML processing instruction (2200T) is statement-local: PostgreSQL does not retain the rejected value after the statement ends. Capture the exact bound value and statement position in application/server logs, then run this targeted validation before retrying.
Validate processing-instruction content
Check the exact XML shape before applying xmlparse/xmlcomment/xmlpi.
SELECT pi_content,
position('?>' in pi_content) > 0 AS contains_forbidden_terminator
FROM (VALUES ('bad ?> content'::text)) v(pi_content);Why it happens
What PostgreSQL is telling you
The mechanism behind the error, grounded in the official manual, not paraphrased.
PostgreSQL 18 Documentation, Appendix A. PostgreSQL Error Codes (Table A.1, Class 22, Data Exception)
2200T → invalid_xml_processing_instructionRead the full section on postgresql.org →
Using a reserved PI target name
The processing-instruction target 'xml' is reserved by the XML spec, so xmlpi(name xml, ...) raises 'invalid XML processing instruction'.The session continues normally
xmlpi() failed as a standalone call outside a transaction, leaving the session clear to run its next statement normally.Reproduce & verify
A real, single-session PostgreSQL reproduction
A literal transcript of SQL run against a live PostgreSQL instance in an isolated lab. The commands below are exactly what was executed.
- 1Call xmlpi(name xml, 'payload') using 'xml' as the processing-instruction target.
- 2PostgreSQL validates the processing-instruction target name.
- 3Because 'xml' is reserved, the statement aborts with SQLSTATE 2200T.
A generator emitted a processing instruction named 'xml' and every document failed to build.
-- The error is self-contained in one statement; no schema is required.
SELECT 'no schema needed' AS setup_note;SELECT xmlpi(name payload, 'bad ?> content');
SELECT 'ok' AS session_after_error;SELECT 'ok' AS session_after_error;What PostgreSQL actually returned
setup_note
------------------
no schema needed
(1 row)ERROR: invalid XML processing instruction
DETAIL: XML processing instruction target name cannot be "xml". session_after_error
---------------------
ok
(1 row)xmlpi() succeeds once the target name is not reserved.
Without this
Before: the 'xml' target aborts
With this, tested
After: a valid target builds the PI
- A second operational test: exact SQL, raw output, measured result, and engineer notes
Card required. Cancel before day 7 and you are not charged.
Connected
Everything this error touches
Every page this SQLSTATE connects to: the concept that explains it, the runbooks that fix it, the parameters you tune to prevent it, and the sibling errors it travels with. All real cross-references. Jump straight in, or open the full interactive map.
Verification
- Last verified
- 2026-07-24 (isolated lab, PostgreSQL 18.4)
- Verification scope
- Verified against PostgreSQL 18.4 in an isolated lab environment
- Audit status
- reviewed
Went further?
Pro unlocks the second lab proof
Free page stops the bleeding. Pro adds the operational test, SQLSTATE audit, and deeper evidence, same error, more certainty.