value out of range: overflow
SQLSTATE 22003 condition numeric_value_out_of_range class 22 — Data Exception severity ERROR
Reproduced & verified on PostgreSQL 14.23, 15.18, 16.14, 17.10 and 18.4 — identical message on every version.
Last reviewed 30 May 2025 · Reproduced live with the SQL on this page.
Symptoms
A numeric computation or conversion produced a value larger than the target type can hold. PostgreSQL raises SQLSTATE 22003 (numeric_value_out_of_range).
- Arithmetic result exceeds the type’s maximum.
- Common with multiplication/addition near the type’s limit.
- Also seen casting a large value into a narrower type.
What the server log shows
ERROR: value out of range: overflow
Why PostgreSQL raises this — what the manual says
Section 8.1.3 Floating-Point Types:
“Values that are too large or too small will cause an error.”
Each numeric type has a fixed range. When an operation or cast produces a value beyond that range, it cannot be represented and PostgreSQL reports 22003 rather than silently wrapping.
Common causes
- Arithmetic exceeding the type’s maximum.
- Casting a large value into a smaller type.
- Accumulating sums that overflow an integer type.
How to fix it
- Use a wider type (e.g.
bigintornumeric). - Cast intermediate results to
numericto avoid integer overflow. - Validate input ranges before computation.
Related & next steps
Reference: PostgreSQL 18 Section 8.1 “Numeric Types”.