select open change scope Open full search

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

SQLSTATE / CLASS 22 · DATA EXCEPTION

floating_point_exception

SQLSTATE
22P01
Condition name
floating_point_exception
Class
Data Exception
Source macro
ERRCODE_FLOATING_POINT_EXCEPTION
Evidence
Source path confirmed
Analysis & operational context

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

<h1>22P01</h1>

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

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

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

  • 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

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

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.

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.

Source evidence

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

22P01 is floating_point_exception in SQLSTATE Class 22.

Method: Read fixed definition.

src.errcodes.18.6

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.

Method: Read the complete handler and the PostgresMain SIGFPE registration.

Limits: The source confirms the handler and message; it does not show a natural SIGFPE runtime in this review.

src.path.handler src.path.registration

The handler is distinct from type-specific exact-numeric errors such as division-by-zero 22012 and numeric range 22003.

Method: Compare the fixed handler with the condition-specific source boundary named in the page.

Limits: Related-code distinctions are diagnostic guidance, not a claim that every arithmetic operator chooses one code.

src.path.handler

The locked catalogue records 22P01 from 7.4; that boundary does not prove exact implementation introduction.

Method: Use catalogue boundary.

src.errcodes.18.6

Message templates

ERROR · message.handler

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.

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:482ec6b1a7942ba6ac284a6a605… · English manual source