SQLSTATE 2201GSeverity lowLab verified

Incident brief

width_bucket count must be positive

width_bucket(operand, low, high, count) requires the bucket count to be a positive integer; passing zero or a negative count raises this data exception.

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
width_bucket count must be positive
What triggers it
Call width_bucket(operand, low, high, count) with a count argument of zero or less.
The fix
Pass a bucket count of at least 1.
Proof
Reproduced on PostgreSQL 18.4 → A single SELECT reproduces SQLSTATE 2201G; the histogram function rejects the non-positive bucket count.

The fix

What to do right now

The immediate, application-level response to this error.

  • Pass a bucket count of at least 1.
  • If the count comes from a parameter or column, validate it (GREATEST(count, 1) or an explicit check) before the call.
Fix — SQL
-- width_bucket needs a positive number of buckets.
SELECT width_bucket(5.0, 0.0, 10.0, 5);

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