# 22015 — interval_field_overflow

> Source-backed reference for PostgreSQL SQLSTATE 22015.
---

## At a glance {#at-a-glance}
An interval input field exceeds the range accepted by the interval decoder. PostgreSQL 18.6 maps that datetime parsing condition to SQLSTATE `22015`; later interval construction or arithmetic can use different range codes.

<!-- BEGIN SQLSTATE FACTS: generated by scripts/generate.py; do not edit -->

| Field | Value |
| --- | --- |
| SQLSTATE | `22015` |
| Condition | `interval_field_overflow` |
| Status | `active` |
| Known present by | `7.4` |
| Locked snapshots | `9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3` |
| Macros | `ERRCODE_INTERVAL_FIELD_OVERFLOW` |
| Aliases | `—` |

<!-- source facts: data/errcodes/22015.json -->
<!-- END SQLSTATE FACTS -->

## Meaning {#meaning}
The fixed `interval_in` path parses the input, decodes the interval fields under the typmod range, and retries ISO 8601 decoding when the first parse reports a bad format. When decoding returns `DTERR_FIELD_OVERFLOW`, `interval_in` remaps it to `DTERR_INTERVAL_OVERFLOW`; `DateTimeParseError` then uses `ERRCODE_INTERVAL_FIELD_OVERFLOW` with the original input in the primary. This is the interval-field input boundary. `itmin2interval` conversion failure, typmod adjustment, and interval arithmetic have separate guards and may report `22008`, `22003`, or another condition; they are not automatically `22015`.

## Diagnosis {#diagnosis}
Read the complete primary and identify the input string, interval field, and declared typmod/range. Check whether the value overflowed while decoding a field, or whether the operation actually failed later while constructing, scaling, or dividing an interval. A date/time field diagnostic belongs to the neighboring datetime codes, and interval division by a zero factor is `22012`. Do not replace a field-range failure with a generic numeric overflow fix.

## Response {#response}
Correct the named interval field or input representation so it fits the operation's accepted range, and review the interval typmod if it is imposing the boundary. If the failure is in later arithmetic, repair that operation according to its own SQLSTATE. In ordinary error context this path raises `ERROR`, so an explicit transaction needs `ROLLBACK` or `ROLLBACK TO SAVEPOINT` before retrying; an `ErrorSaveContext` caller receives a saved error and a NULL/failed return instead of a thrown error.

## Messages {#messages}
- Primary, `ERROR` in ordinary context: `interval field value out of range: "%s"`, where `%s` is the original interval input. The cited branch adds no fixed DETAIL or HINT.

## Versions {#versions}
The locked catalogue records this condition from 7.4; fixed source coverage is PostgreSQL 18.6. The source-backed path is interval input decoding; it does not claim that every interval arithmetic overflow uses `22015`.

## Related {#related}
[`22007`](../22007/), [`22003`](../22003/), [`22008`](../22008/), [`22012`](../22012/)

## Sources {#sources}
- [`src/backend/utils/adt/timestamp.c#L884-L967`](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/timestamp.c#L884-L967) contains `interval_in`, typmod range selection, datetime decoding, the `DTERR_FIELD_OVERFLOW` remap, and the later `itmin2interval` range branch.
- [`src/backend/utils/adt/datetime.c#L4195-L4266`](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/datetime.c#L4195-L4266) maps `DTERR_INTERVAL_OVERFLOW` to the exact `22015` primary and documents that `errsave` fills an `ErrorSaveContext` instead of throwing.

Runtime verification is `not_run`; no interval runtime observation is claimed. The structured [evidence record](../data/evidence/22015.json) retains the exact message role and source boundary.
