select open change scope Open full search

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

SQLSTATE / CLASS 39 · EXTERNAL ROUTINE INVOCATION EXCEPTION

srf_protocol_violated

SQLSTATE
39P02
Condition name
srf_protocol_violated
Class
External Routine Invocation Exception
Source macro
ERRCODE_E_R_I_E_SRF_PROTOCOL_VIOLATED
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>39P02</h1>

At a glance

39P02 is srf_protocol_violated. The fixed executor path checks value-per-call and materialize set-returning-function contracts and reports the exact violated return mode.

Meaning

The executor received a set-returning function state that violated the selected protocol: table-function protocol for value-per-call mode was not followed, table-function protocol for materialize mode was not followed, or unrecognized table-function returnMode: %d.

Diagnosis

Inspect the C or extension function that sets ReturnSetInfo fields, especially returnMode, isDone, and returnSet. This is an SRF protocol issue, not a row-count result.

Response

Repair the SRF value-per-call or materialize implementation and its ReturnSetInfo state; changing LIMIT or transaction policy does not repair the executor contract.

Versions

The locked catalogue records this condition from 7.4 in the listed formal snapshots and 19beta3; fixed source coverage is PostgreSQL 18.6.

Sources

See the fixed execSRF.c and materialize path (lines 665-686) alongside 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.

39P02 is srf_protocol_violated in Class 39.

Method: Read the fixed definition row.

src.errcodes.18.6

The executor reports this code when a set-returning function violates value-per-call or materialize mode, or supplies an unrecognized returnMode.

Method: Read the rsinfo.returnMode, isDone, and returnsSet checks.

src.path.srf

The fixed path is an executor-to-set-returning-function contract, not an ordinary query row-count condition.

Method: Interpret the source checks in their executor context.

src.path.srf

Message templates

ERROR · message.srf-value-per-call

Primary

table-function protocol for value-per-call mode was not followed
ERROR · message.srf-materialize

Primary

table-function protocol for materialize mode was not followed
ERROR · message.srf-returnmode

Primary

unrecognized table-function returnMode: %d

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:b6e1acddab04879fddd4d1af214… · English manual source