Independent technical referenceOfficial site
  • Software and digital services
  • Databases

22003

PostgreSQL 22003 numeric_value_out_of_range: number overflow

Verified with sources2 sourcesReviewed Oct 19, 2026
Technician coming? See the 2 steps they must show you
Trace

Risk level

Medium

Proceed carefully and stop if the check is unclear.

Urgency

Medium

Quick answer

PostgreSQL raises SQLSTATE 22003 (numeric_value_out_of_range) when an input number, cast, sequence, or calculation exceeds the allowed range of its target numeric type. Check the value against the column or expression type bounds and record the failing input before changing types.

Safety first

Stop and check this first

  • Do not attempt to modify system catalogs directly or bypass constraints to store out-of-range numbers; always execute ROLLBACK to close a failed transaction block before retrying, and redact sensitive financial figures from logs.
  • Never truncate high-order digits, clamp values to +2147483647, or switch monetary columns from numeric to inexact real or double precision just to avoid SQLSTATE 22003: Section 8.1.3 warns that floating-point types are inexact approximations and monetary amounts should use numeric.

Safe checks you can perform

  • Locate the overflowing type and expression in the ErrorResponse message
  • Inspect numeric_precision, numeric_scale, and pg_typeof for the target column or expression
  • Test candidate input strings non-destructively with pg_input_error_info

Leave these tasks to a qualified professional

  • Do not attempt this professional task: Promote intermediate arithmetic operands or validate numeric bounds in the application
  • Do not attempt this professional task: Widen the column or sequence type (for example integer to bigint or wider NUMERIC) after backup

What a technician must be able to justify

Technician visit

These are the steps they must carry out and show you. Tick them as they work: if steps are skipped, do not accept a part swap.

These are not instructions for opening or handling the equipment yourself. They are the checks that should support a technical conclusion.

  1. Promote intermediate arithmetic operands or validate numeric bounds in the application

    What they doHave the developer cast operands to bigint or numeric before multiplying or summing values that can exceed 2147483647, and validate user inputs against the documented type range before executing the statement.

    They must show youthe query plan or SELECT test demonstrating pg_typeof and a successful calculation on boundary test values.

    In writingthe updated SQL expression and the minimum and maximum numeric bounds enforced by the application.

  2. Widen the column or sequence type (for example integer to bigint or wider NUMERIC) after backup

    What they doWhen legitimate identifiers or monetary totals outgrow the column, have your DBA verify a backup, check serial or identity sequence bounds with pg_get_serial_sequence, and alter the column and sequence to bigint or a wider NUMERIC(precision, scale) during a maintenance window.

    They must show youthe before and after information_schema.columns rows and sequence metadata for the widened column.

    In writingthe schema migration script, rollback procedure, and verification reading confirming 22003 no longer occurs.

Before accepting a part or repair

Nothing has been shown yet. Do not accept a part swap based on the code alone.

Follow these steps

Note: Follow the documented order. An error code identifies the affected system, but it does not prove by itself which part has failed.

  1. Locate the overflowing type and expression in the ErrorResponse message

    No special tools

    Who:
    Your developer or DBA examining the failed query for SQLSTATE 22003.
    How:
    Inspect the ErrorResponse fields C (22003), M (Message, such as value is out of range for type integer), D (Detail), P (Position), and W (Where) after redacting sensitive business figures.
    Result that matters:
    The primary message names the exact target type that overflowed and Position points to the cast, operator, or column assignment in the SQL string.
    If the message names smallint, integer, or bigint at a parameter or column assignment, that confirms an integer range violation rather than a floating-point underflow.
    If the message reports an overflow on a numeric column with declared precision and scale, that points to a NUMERIC(precision, scale) target whose integer digit limit (precision minus scale) was exceeded after rounding.
    Evidence to keep:
    Keep the redacted ErrorResponse fields C, M, D, P, and W along with the statement text.

    Evidence: PostgreSQL 18 Appendix A: Error Codes · PostgreSQL error and notice fields · PostgreSQL 18 numeric types

  2. Inspect numeric_precision, numeric_scale, and pg_typeof for the target column or expression

    Tools required

    Who:
    Your database administrator or developer with read-only schema access.
    How:
    Query information_schema.columns for data_type, numeric_precision, numeric_precision_radix, and numeric_scale on the target table, and use pg_typeof(expr) on non-overflowing sample inputs to check intermediate expression types.
    Result that matters:
    information_schema.columns reveals the exact declared precision and scale, while pg_typeof shows whether arithmetic is being evaluated in smallint, integer, bigint, or numeric.
    If pg_typeof shows that an intermediate multiplication or sum uses integer even though the destination is bigint, that confirms the expression overflows before assignment and needs wider input types.
    If numeric_precision minus numeric_scale is smaller than the count of digits to the left of the decimal point, that confirms the column declaration cannot hold the rounded magnitude.
    Evidence to keep:
    Save the query result showing data_type, numeric_precision, numeric_scale, and the pg_typeof output.

    Run only read-only catalog queries and issue ROLLBACK first if the session is in an aborted transaction; never clamp or modulo financial or quantity values to force them into a narrow column.

    Evidence: PostgreSQL ROLLBACK · PostgreSQL 18 system information functions · PostgreSQL 18 information_schema columns view · PostgreSQL 18 numeric types

  3. Test candidate input strings non-destructively with pg_input_error_info

    Tools required

    Who:
    Your developer reproducing the 22003 boundary in a test or read-only session.
    How:
    Run SELECT * FROM pg_input_error_info('42000000000', 'integer') (replacing the literal and type with your candidate value and column type) to inspect the soft error output.
    Result that matters:
    Table 9.83 shows that pg_input_error_info returns message, detail, hint, and sql_error_code (22003) when the input string is out of range for the specified type, or NULL fields when valid.
    If pg_input_error_info returns sql_error_code 22003 for the raw input string against the column type, that confirms the incoming datum itself exceeds the declared type bounds.
    If pg_input_error_info returns NULL for all individual inputs against the column type, that rules out raw input overflow and isolates the 22003 failure to an in-query arithmetic calculation or trigger.
    Evidence to keep:
    Record the exact pg_input_error_info row (message, detail, hint, sql_error_code) for the tested value.

    Do not run experimental writes on production tables; use SELECT with pg_input_error_info and redact proprietary financial values from shared tickets.

    Evidence: PostgreSQL 18 system information functions · PostgreSQL 18 numeric types

Still not solved

If the error persists, stop here. See what the technician must do and show you.

Virtual technician

Does 22003 still appear after these checks?

This guided flow uses the exact code and your answers to choose a test, an expected result and the next branch.

Where this code applies

A code is meaningful only inside the right product and version context.

Primary scope

System
Software and digital services
Brand
PostgreSQL
Product type
Databases

Known code variants

  • numeric_value_out_of_range
  • PostgreSQL 22003
  • SQLSTATE 22003

What it means

In Appendix A Table A.1, the PostgreSQL server assigns 22003 to numeric_value_out_of_range in Class 22 Data Exception. Section 8.1 documents the bounds of each numeric type: smallint accepts -32768 to +32767, integer accepts -2147483648 to +2147483647, and bigint accepts -9223372036854775808 to +9223372036854775807. For NUMERIC(precision, scale), PostgreSQL rounds excess fractional scale first and raises an error if digits to the left of the decimal point exceed precision minus scale; real and double precision also error on values that are too large or too small. Code 22003 alone does not prove a server fault or identify which expression overflowed.

Warnings and stop conditions

  • Lowsource verified

    Do not attempt to modify system catalogs directly or bypass constraints to store out-of-range numbers; always execute ROLLBACK to close a failed transaction block before retrying, and redact sensitive financial figures from logs.

    Evidence: PostgreSQL error and notice fields · PostgreSQL ROLLBACK

  • Mediumsource verified

    Never truncate high-order digits, clamp values to +2147483647, or switch monetary columns from numeric to inexact real or double precision just to avoid SQLSTATE 22003: Section 8.1.3 warns that floating-point types are inexact approximations and monetary amounts should use numeric.

    Evidence: PostgreSQL 18 Appendix A: Error Codes · PostgreSQL 18 numeric types

Symptoms and causes

Probable causes · in order

  • Integer literal, parameter, or arithmetic result outside smallint, integer, or bigint boundsCommon

    Section 8.1.1 states that smallint (-32768 to +32767), integer (-2147483648 to +2147483647), and bigint store whole numbers and any attempt to store values outside the allowed range results in an error.

    Evidence: PostgreSQL 18 Appendix A: Error Codes · PostgreSQL 18 numeric types

  • Value exceeding precision minus scale in a declared NUMERIC(precision, scale) columnCommon

    Section 8.1.2 explains that after rounding fractional digits to the declared scale, PostgreSQL raises an error if the number of digits to the left of the decimal point exceeds precision minus scale.

    Evidence: PostgreSQL 18 information_schema columns view · PostgreSQL 18 numeric types

  • Floating-point overflow or underflow, or a serial sequence exceeding its 4-byte integer columnPossible

    Section 8.1.3 notes that real and double precision raise an error when values are too large, too small, or too close to zero (underflow), and Section 8.1.4 notes serial columns use 4-byte integer bounds up to 2147483647.

    Evidence: PostgreSQL 18 numeric types

Sources and technical references

  1. 1

    PostgreSQL 18 Appendix A: Error Codes

    PostgreSQL Global Development Group · 2026 · official_doc

  2. 2

    PostgreSQL error and notice fields

    PostgreSQL Global Development Group · 2026 · official_doc

Sources: PostgreSQL 18 Appendix A: Error Codes · PostgreSQL error and notice fieldsreviewed 2026-10-19 · verified

Was this entry useful?