22015 — interval_field_overflow
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.
| 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 | — |
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
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
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
- Primary,
ERRORin ordinary context:interval field value out of range: "%s", where%sis the original interval input. The cited branch adds no fixed DETAIL or HINT.
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
Sources
src/backend/utils/adt/timestamp.c#L884-L967containsinterval_in, typmod range selection, datetime decoding, theDTERR_FIELD_OVERFLOWremap, and the lateritmin2intervalrange branch.src/backend/utils/adt/datetime.c#L4195-L4266mapsDTERR_INTERVAL_OVERFLOWto the exact22015primary and documents thaterrsavefills anErrorSaveContextinstead of throwing.
Runtime verification is not_run; no interval runtime observation is claimed. The structured evidence record retains the exact message role and source boundary.