Skip to content

39P02 — srf_protocol_violated

Source-backed reference for PostgreSQL SQLSTATE 39P02.

39P02

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.

Field Value
SQLSTATE 39P02
Condition srf_protocol_violated
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_E_R_I_E_SRF_PROTOCOL_VIOLATED
Aliases

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.

39P01, 39P03, 2F002

Sources

See the fixed execSRF.c and materialize path (lines 665-686) alongside the structured evidence record.