↑↓ select↵ open⌫ change scopeOpen full search

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

Wiki / SQLSTATE

22015 — interval_field_overflow

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.

English manual coverage begins with PostgreSQL 8.1. Source history and runtime observations have their own recorded version boundaries.

Reading PG 18·Select a recorded version

aliases
Unknown
class name
Data Exception
condition name
interval_field_overflow
lang
en
sqlstate
22015

Definition PG 18

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.

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, 22003, 22008, 22012

Sources {#sources}

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

Compare versions

SQLSTATE evidence and recorded runtime versions

claims · identity
{
  "claim_id": "identity",
  "limits": "",
  "method": "Read the fixed errcodes row and macro.",
  "position": 0,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "22015 is interval_field_overflow in SQLSTATE Class 22."
}
claims · interval-input-path
{
  "claim_id": "interval-input-path",
  "limits": "This is the interval input decoding path, not every interval arithmetic overflow.",
  "method": "Read interval_in, the remap, and the DateTimeParseError switch.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.interval-input.18.6",
    "src.datetime-errors.18.6"
  ],
  "statement": "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."
}
claims · soft-error-path
{
  "claim_id": "soft-error-path",
  "limits": "",
  "method": "Read the ErrorSaveContext comment and errsave branch.",
  "position": 2,
  "runtime": [],
  "sources": [
    "src.datetime-errors.18.6"
  ],
  "statement": "DateTimeParseError fills ErrorSaveContext through errsave instead of throwing when a soft error context is supplied; ordinary callers receive ERROR."
}
claims · history
{
  "claim_id": "history",
  "limits": "",
  "method": "Use catalogue presence and history boundaries.",
  "position": 3,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "The locked catalogue records 22015 from 7.4 without proving an exact implementation introduction date."
}
messages · message.interval-field-overflow
{
  "limits": "",
  "message_id": "message.interval-field-overflow",
  "path": "",
  "position": 0,
  "raw": {
    "id": "message.interval-field-overflow",
    "primary_template": "interval field value out of range: \"%s\"",
    "severity_source": "ERROR (ordinary context; errsave soft path when escontext supplied)",
    "sources": [
      "src.datetime-errors.18.6"
    ],
    "sqlstate": "22015"
  },
  "severity": "ERROR (ordinary context; errsave soft path when escontext supplied)",
  "sources": [
    "src.datetime-errors.18.6"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "interval field value out of range: \" \"",
      "position": 0,
      "role": "",
      "template": "interval field value out of range: \"%s\""
    }
  ]
}
sources · src.errcodes.18.6
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/errcodes.txt",
  "position": 0,
  "sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
  "source_id": "src.errcodes.18.6",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L185"
}
sources · src.interval-input.18.6
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/adt/timestamp.c",
  "position": 1,
  "sha256": "2614ccd2182fa904b4cac9bef43039e90a1af578d2d1c6803d49a07420d168f2",
  "source_id": "src.interval-input.18.6",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/timestamp.c#L884-967"
}
sources · src.datetime-errors.18.6
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/adt/datetime.c",
  "position": 2,
  "sha256": "709e05b536f611f7eeaaabb716501d59d4d1e87c53757e15240fe1fc4845459c",
  "source_id": "src.datetime-errors.18.6",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/adt/datetime.c#L4195-4266"
}

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · english-manuals:7c9b397a8eae2359eda1701b3f2c9b44599e435cc802048255eb3999776740d9

Text language: en · english-manuals:7c9b397a8eae2359eda1701b3f2c9b44599e435cc802048255eb3999776740d9