SQLSTATE 2201FSeverity lowLab verified

Incident brief

Zero raised to a negative power

power(0, n) with a negative exponent is undefined because it implies division by zero, so PostgreSQL raises this data exception instead of returning infinity.

Reproduced on PostgreSQL 18.4Verified 2026-07-24 (isolated lab, PostgreSQL 18.4)Reviewed by Verified against PostgreSQL 18.4 in an isolated lab environment

In 10 seconds

What
Zero raised to a negative power
What triggers it
Call power(x, y) (or the ^ operator) with a base of exactly 0 and a negative exponent.
The fix
Ensure the base is non-zero whenever the exponent can be negative.
Proof
Reproduced on PostgreSQL 18.4 → A single SELECT reproduces SQLSTATE 2201F; the server refuses 0 raised to a negative power rather than returning infinity.

The fix

What to do right now

The immediate, application-level response to this error.

  • Ensure the base is non-zero whenever the exponent can be negative.
  • Special-case a zero base (return NULL or a sentinel) before calling power().
Fix — SQL
-- Use a non-zero base when the exponent may be negative.
SELECT power(2, -1);

Related & next steps

Follow the thread

Everything this error touches — jump straight to the sibling error, term, runbook, or parameter.

Verification

PG 18.4
Last verified
2026-07-24 (isolated lab, PostgreSQL 18.4)
Reviewed by
Verified against PostgreSQL 18.4 in an isolated lab environment
Audit status
reviewed