Skip to content

2F005 — function_executed_no_return_statement

Source-backed reference for PostgreSQL SQLSTATE 2F005.

2F005

At a glance

PL/pgSQL reports 2F005 at ERROR level when a function or trigger procedure reaches the end without the required RETURN. The fixed 18.6 paths distinguish an ordinary function from a trigger procedure in their messages.

Field Value
SQLSTATE 2F005
Condition function_executed_no_return_statement
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT
Aliases

Meaning

The confirmed messages are control reached end of function without RETURN and control reached end of trigger procedure without RETURN. The return requirement depends on the routine kind and declared return behavior; it is not a generic “function returned NULL” message.

Messages

The confirmed messages are control reached end of function without RETURN and control reached end of trigger procedure without RETURN. The return requirement depends on the routine kind and declared return behavior; this is not a generic “function returned NULL” message.

Diagnosis

Read the routine signature and the control-flow paths that can reach the end. For a trigger procedure, inspect each branch that should return the trigger row or NULL according to the trigger contract; for a value-returning function, inspect every branch for a compatible RETURN.

Response

Add the required return path and validate the routine definition before rerunning the operation. This is a routine control-flow repair; retry only after considering whether the enclosing operation performed any visible work.

Versions

The locked catalogue places this condition at least by PostgreSQL 7.4. The facts block lists the published snapshots; source-path status is limited to the fixed PostgreSQL 18.6 evidence below.

2F000, 38000

Sources

See the fixed source links and message limits in the structured evidence record.