22P03ERRORTier 2 — Caution✅ HIGH confidenceinvalid binary representation
What this means
SQLSTATE 22P03 is a Postgres-specific error raised when a value supplied in binary format (e.g., via binary COPY or binary protocol parameter binding) does not have a valid binary representation for the expected data type.
Why it happens
- 1Sending binary-format parameter data that does not match the wire format expected for the target type
- 2Binary COPY data containing malformed type representations
How to reproduce
Binary COPY with malformed type data.
COPY my_table FROM STDIN WITH (FORMAT binary);
-- binary stream contains invalid type bytesFix 1: Use text format COPY for debugging binary format issues
When diagnosing 22P03 errors from binary COPY operations.
COPY my_table FROM STDIN WITH (FORMAT text);Why this works
Text format COPY is easier to inspect and debug. Switch back to binary only after confirming the data is valid.
Fix 2: Verify driver binary encoding against Postgres type documentation
When using binary protocol bindings in a custom driver or tool.
Why this works
Check the Postgres frontend/backend protocol documentation for the exact binary wire format of the target type.
Sources
📚 Official docs: https://www.postgresql.org/docs/current/errcodes-appendix.html
🔧 Source ref: Class 22 — Data Exception (Postgres-specific)
📖 Further reading: Postgres Protocol Binary Format
Confidence assessment
✅ HIGH confidence
Postgres-specific error for binary format validation. Stable across versions.
See also
🔗 Related errors
📄 Reference pages