select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

SQLSTATE / CLASS 2F · SQL ROUTINE EXCEPTION

function_executed_no_return_statement

SQLSTATE
2F005
Condition name
function_executed_no_return_statement
Class
SQL Routine Exception
Source macro
ERRCODE_S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT
Evidence
Source path confirmed
Analysis & operational context

English SQLSTATE atlas: authored explanations and source/runtime evidence are separate from the manual definitions. View source ↗

<h1>2F005</h1>

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.

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.

Sources

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

Source evidence

Evidence belongs to the frozen source and runtime versions listed here. It is not a runtime verification of the selected manual version.

2F005 is function_executed_no_return_statement in SQLSTATE Class 2F.

Method: Read the fixed errcodes definition row, severity, and macro.

src.errcodes.18.6

The fixed PostgreSQL 18.6 source contains the report contexts and message variants described on the page.

Method: Read the complete source context around the resolved report groups.

Limits: Source confirmation is not a runtime observation in this batch.

src.path.0

Locked release definitions establish catalogue presence from 7.4; they do not establish a precise introducing release or runtime use.

Method: Compare canonical release facts with the available history boundary.

Limits: Definition presence is not an emitting-path observation.

src.errcodes.18.6

Message templates

ERROR · message.plpgsql-function-no-return

Primary

control reached end of function without RETURN
ERROR · message.plpgsql-trigger-no-return

Primary

control reached end of trigger procedure without RETURN

The same trigger template appears at more than one fixed control-flow path.

Reproduction & repair cases

No reproduction case is attached to this condition.

Recorded runtime evidence

No runtime observation is attached to this entry.

Definition snapshot: english-manuals:8091a6212cf5eeef2791bd36409… · English manual source