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.

What lands in your log

ERROR: zero raised to a negative power is undefined

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

In 10 seconds

What triggers it
Call power(x, y) (or the ^ operator) with a base of exactly 0 and a negative exponent.
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.

Fix

What to do right now

Application-level steps for 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);

Connected

Everything this error touches

Every page this SQLSTATE connects to: the concept that explains it, the runbooks that fix it, the parameters you tune to prevent it, and the sibling errors it travels with. All real cross-references. Jump straight in, or open the full interactive map.

Open in the interactive map →

Verification

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

Went further?

Pro unlocks the second lab proof

Free page stops the bleeding. Pro adds the operational test, SQLSTATE audit, and deeper evidence, same error, more certainty.

FollowSubstackLinkedInnew errors · lab notes · hiring loops