SQLSTATE 22P02Severity mediumLab verified

Incident brief

Invalid input syntax

A string literal was cast to a type whose input function couldn't parse it. PostgreSQL rejected the value outright rather than guessing at a conversion.

Reproduced on PostgreSQL 16.14Verified 2026-07-15 (Docker lab, PostgreSQL 16.14)Reviewed by Verified against PostgreSQL 16.14 in an isolated lab environment

In 10 seconds

What
Invalid input syntax
What triggers it
Cast a string literal to a type whose input function can't parse it (e.g. a non-numeric string to integer).
The fix
Fix the literal so it matches the target type's actual input format.
Proof
Reproduced on PostgreSQL 16.14 → Casting a non-numeric string to integer was rejected with SQLSTATE 22P02, naming the exact invalid value. The session was unaffected afterward.

The fix

What to do right now

The immediate, application-level response to this error.

  • Fix the literal so it matches the target type's actual input format.
  • For boolean specifically, only a documented set of strings — and their unique prefixes — are accepted; see the premium test.
  • Don't rely on NULLIF to guard this generally — see the counterexample for why it only catches one specific value.
Fix — SQL
SELECT '42'::integer;

Related & next steps

Follow the thread

Everything this error touches — jump straight to the sibling error, term, runbook, or parameter.

Verification

PG 16.14
Last verified
2026-07-15 (Docker lab, PostgreSQL 16.14)
Reviewed by
Verified against PostgreSQL 16.14 in an isolated lab environment
Audit status
reviewed