↑↓ select↵ open⌫ change scopeOpen full search

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

Wiki / SQLSTATE

22P01 — floating_point_exception

PostgreSQL's fixed core path installs FloatExceptionHandler for SIGFPE. The handler emits an ERROR with primary floating-point exception and detail stating that an invalid floating-point operation was signaled, probably because of an out-of-range result or an invalid operation such as division by zero.

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
floating_point_exception
lang
en
sqlstate
22P01

Definition PG 18

22P01

At a glance {#at-a-glance}

PostgreSQL's fixed core path installs FloatExceptionHandler for SIGFPE. The handler emits an ERROR with primary floating-point exception and detail stating that an invalid floating-point operation was signaled, probably because of an out-of-range result or an invalid operation such as division by zero.

Meaning {#meaning}

FloatExceptionHandler(SIGNAL_ARGS) is a signal-to-ereport(ERROR) boundary in src/backend/tcop/postgres.c; PostgresMain registers it for SIGFPE. This is a floating-point signal path, not a promise that every division or numeric range failure uses 22P01. Exact numeric division by zero and numeric range checks have their own conditions, commonly 22012 and 22003.

Diagnosis {#diagnosis}

Preserve the complete ErrorResponse and server-log context, including statement position and any routine or context fields. Inspect operand types and the expression path: distinguish a hardware or floating-point invalid operation from an exact-numeric operator that reports 22012 or 22003. The fixed handler's detail is a diagnostic explanation, not proof that division by zero was the particular operation.

Messages {#messages}

  • ERROR primary: floating-point exception
  • DETAIL: An invalid floating-point operation was signaled. This probably means an out-of-range result or an invalid operation, such as division by zero.

Response {#response}

Correct the arithmetic or input range, and cast deliberately before the operation when that changes the intended numeric domain. In an explicit transaction, an ERROR leaves the transaction aborted, so issue ROLLBACK or ROLLBACK TO SAVEPOINT before retrying; in autocommit, fix the expression or data first and submit it again. The cited path is ERROR, not FATAL, so a normal client backend need not be reset merely because this condition occurred.

Versions {#versions}

The locked catalogue records this condition from PostgreSQL 7.4. The handler and SIGFPE registration cited here are from PostgreSQL 18.6 REL_18_6; the catalogue boundary does not prove the exact introduction of the current wording.

Related {#related}

22012, 22003, 22023

Sources {#sources}

src/backend/tcop/postgres.c#L3072-L3082

src/backend/tcop/postgres.c#L4245-L4249

The structured evidence record records the exact primary/detail, severity, and source/runtime boundary. No signal was induced for this review.

Compare versions

SQLSTATE evidence and recorded runtime versions

claims · identity
{
  "claim_id": "identity",
  "limits": "",
  "method": "Read fixed definition.",
  "position": 0,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "22P01 is floating_point_exception in SQLSTATE Class 22."
}
claims · signal-handler
{
  "claim_id": "signal-handler",
  "limits": "The source confirms the handler and message; it does not show a natural SIGFPE runtime in this review.",
  "method": "Read the complete handler and the PostgresMain SIGFPE registration.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.path.handler",
    "src.path.registration"
  ],
  "statement": "FloatExceptionHandler is the backend SIGFPE handler. It emits ERROR 22P01 with primary floating-point exception and detail about an invalid floating-point operation, an out-of-range result, or an invalid operation such as division by zero."
}
claims · numeric-boundary
{
  "claim_id": "numeric-boundary",
  "limits": "Related-code distinctions are diagnostic guidance, not a claim that every arithmetic operator chooses one code.",
  "method": "Compare the fixed handler with the condition-specific source boundary named in the page.",
  "position": 2,
  "runtime": [],
  "sources": [
    "src.path.handler"
  ],
  "statement": "The handler is distinct from type-specific exact-numeric errors such as division-by-zero 22012 and numeric range 22003."
}
claims · history
{
  "claim_id": "history",
  "limits": "",
  "method": "Use catalogue boundary.",
  "position": 3,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "The locked catalogue records 22P01 from 7.4; that boundary does not prove exact implementation introduction."
}
messages · message.handler
{
  "limits": "",
  "message_id": "message.handler",
  "path": "",
  "position": 0,
  "raw": {
    "detail_template": "An invalid floating-point operation was signaled. This probably means an out-of-range result or an invalid operation, such as division by zero.",
    "id": "message.handler",
    "primary_template": "floating-point exception",
    "severity_source": "ERROR",
    "sources": [
      "src.path.handler"
    ],
    "sqlstate": "22P01"
  },
  "severity": "ERROR",
  "sources": [
    "src.path.handler"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "floating-point exception",
      "position": 0,
      "role": "",
      "template": "floating-point exception"
    },
    {
      "kind": "detail",
      "literal": "An invalid floating-point operation was signaled. This probably means an out-of-range result or an invalid operation, such as division by zero.",
      "position": 1,
      "role": "",
      "template": "An invalid floating-point operation was signaled. This probably means an out-of-range result or an invalid operation, such as division by zero."
    }
  ]
}
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#L205"
}
sources · src.path.handler
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/tcop/postgres.c",
  "position": 1,
  "sha256": "9fb62275b1badf94d01ab351337b60410cd9b3ab1fe63fa9f23d6d2185a21061",
  "source_id": "src.path.handler",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/tcop/postgres.c#L3072"
}
sources · src.path.registration
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/tcop/postgres.c",
  "position": 2,
  "sha256": "9fb62275b1badf94d01ab351337b60410cd9b3ab1fe63fa9f23d6d2185a21061",
  "source_id": "src.path.registration",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/tcop/postgres.c#L4245"
}

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · english-manuals:62b1c359279374e7925be6589a21b880d0df14a26afca0407fab3cccb796fd41

Text language: en · english-manuals:62b1c359279374e7925be6589a21b880d0df14a26afca0407fab3cccb796fd41