SQLSTATE 2F005Severity mediumLab verified

Incident brief

Function ended without RETURN

A function declared to return a value must execute a RETURN on every path; a code path that falls off the end without RETURN raises this SQL-routine exception at call time.

What lands in your log

ERROR: control reached end of function without RETURN

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 a value-returning function whose control flow can reach the end without executing RETURN.
Fix
Ensure every path executes RETURN (add a final RETURN or cover all branches).
Proof
Reproduced on PostgreSQL 18.4 → A function call reproduces SQLSTATE 2F005; a path that reaches the end without RETURN fails, naming the function in the CONTEXT.

Fix

What to do right now

Application-level steps for this error.

  • Ensure every path executes RETURN (add a final RETURN or cover all branches).
  • For functions that may legitimately produce nothing, RETURN NULL explicitly.
Fix SQL
-- Ensure every path returns a value.
SELECT compute_total_fixed();

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