select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

SQLSTATE / CLASS 22 · DATA EXCEPTION

interval_field_overflow

SQLSTATE
22015
Condition name
interval_field_overflow
Class
Data Exception
Source macro
ERRCODE_INTERVAL_FIELD_OVERFLOW
Evidence
Source path confirmed
Analysis & operational context

English SQLSTATE atlas: authored explanations and source/runtime evidence are separate from the manual definitions. View source ↗

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.

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, 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

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.

Sources

Runtime verification is not_run; no interval runtime observation is claimed. The structured evidence record retains the exact message role and source boundary.

Source evidence

Evidence belongs to the frozen source and runtime versions listed here. It is not a runtime verification of the selected manual version.

22015 is interval_field_overflow in SQLSTATE Class 22.

Method: Read the fixed errcodes row and macro.

src.errcodes.18.6

interval_in maps a datetime field-overflow decode result to DTERR_INTERVAL_OVERFLOW before DateTimeParseError reports the interval-field primary; later itmin2interval range failure is a separate 22008 branch.

Method: Read interval_in, the remap, and the DateTimeParseError switch.

Limits: This is the interval input decoding path, not every interval arithmetic overflow.

src.interval-input.18.6 src.datetime-errors.18.6

DateTimeParseError fills ErrorSaveContext through errsave instead of throwing when a soft error context is supplied; ordinary callers receive ERROR.

Method: Read the ErrorSaveContext comment and errsave branch.

src.datetime-errors.18.6

The locked catalogue records 22015 from 7.4 without proving an exact implementation introduction date.

Method: Use catalogue presence and history boundaries.

src.errcodes.18.6

Message templates

ERROR (ordinary context; errsave soft path when escontext supplied) · message.interval-field-overflow

Primary

interval field value out of range: "%s"

Reproduction & repair cases

No reproduction case is attached to this condition.

Recorded runtime evidence

No runtime observation is attached to this entry.

Definition snapshot: english-manuals:40b82c89a0498a42b8f5d83cb60… · English manual source