SQLSTATE 22003Severity lowLab verified

Incident brief

Numeric value out of range

A value didn't fit in the numeric type's allowed range. PostgreSQL rejects it instead of wrapping it around or silently rounding it.

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

In 10 seconds

What
Numeric value out of range
What triggers it
Create a table with a smallint column.
The fix
Use a wider integer type (integer or bigint) if values can legitimately exceed smallint's range.
Proof
Reproduced on PostgreSQL 16.14 → Inserting 40000 into a smallint column (documented range -32768 to +32767) was rejected with SQLSTATE 22003. No row was stored.

The fix

What to do right now

The immediate, application-level response to this error.

  • Use a wider integer type (integer or bigint) if values can legitimately exceed smallint's range.
  • Validate expected value ranges in the application before inserting.
  • Remember arithmetic on in-range values can still overflow the result type — see the premium counterexample below.
Fix — SQL
-- widen the type so a legitimately larger value fits
ALTER TABLE metrics.counters ALTER COLUMN count TYPE integer;
INSERT INTO metrics.counters (id, count) VALUES (5, 40000);

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-16 (Docker lab, PostgreSQL 16.14)
Reviewed by
Verified against PostgreSQL 16.14 in an isolated lab environment
Audit status
reviewed