select open change scope Open full search

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

SQLSTATE / CLASS 22 · DATA EXCEPTION

invalid_argument_for_power_function

SQLSTATE
2201F
Condition name
invalid_argument_for_power_function
Class
Data Exception
Source macro
ERRCODE_INVALID_ARGUMENT_FOR_POWER_FUNCTION
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>2201F</h1>

At a glance

Power functions reject operands whose real-valued result is undefined. Fixed numeric paths report zero raised to a negative power is undefined or a negative number raised to a non-integer power yields a complex result.

Meaning

2201F covers two distinct power guards: a zero base with a negative exponent, and a negative base with a non-integer exponent. The checks occur for ordinary finite numeric values and in the special-value path. Numeric NaN handling can return NaN or 1 under POSIX rules, and several infinity combinations are defined; a negative base with an integer exponent is not automatically this error.

Diagnosis

Inspect the resolved base and exponent types and the exact primary message. A decimal exponent that is not integral is different from a negative integer exponent, so changing scale or applying an unrelated cast is not a repair. Check special values separately rather than treating every NaN or infinity as an invalid power.

Response

Choose a base/exponent pair with the intended real result, or change the business rule explicitly. If the ERROR is in an explicit transaction, roll back or roll back to the existing savepoint before retrying; an autocommit client can retry the corrected operation.

Versions

The locked catalogue records this condition from 8.0.0; the fixed source paths here are PostgreSQL 18.6. No natural runtime observation is claimed for this page.

Sources

The finite and special-value guards are in src/backend/utils/adt/numeric.c#L4045-4111 and #L4208-4220; the negative-base non-integral guard is in #L11373-11384. The structured evidence record retains the exact message roles; no natural runtime was run.

Source evidence

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

2201F is invalid_argument_for_power_function in SQLSTATE Class 22

Method: Read the fixed errcodes row and macro.

src.errcodes.18.6

Fixed PostgreSQL 18.6 numeric power paths bind zero-negative-exponent and negative-base-non-integral guards, including finite and special-value branches.

Method: Read complete source contexts for the representative guards.

Limits: Source confirmation is not a natural runtime observation.

src.numeric.power.special src.numeric.power.finite src.numeric.power.negative

The locked catalogue records 2201F from 8.0.0 without proving an exact implementation introduction date.

Method: Use catalogue presence and history boundaries.

src.errcodes.18.6

Message templates

ERROR · message.zero-negative-power

Primary

zero raised to a negative power is undefined
ERROR · message.negative-noninteger

Primary

a negative number raised to a non-integer power yields a complex result

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:4b081f00f7a6e7b20eb5ffcd080… · English manual source