39P02 — srf_protocol_violated
39P02 is srfprotocolviolated. The fixed executor path checks value-per-call and materialize set-returning-function contracts and reports the exact violated return mode.
English manual coverage begins with PostgreSQL 8.1. Source history and runtime observations have their own recorded version boundaries.
Reading PG 18·Select a recorded version
- aliases
- Unknown
- class name
- External Routine Invocation Exception
- condition name
- srf_protocol_violated
- lang
- en
- sqlstate
- 39P02
Definition PG 18
39P02
At a glance {#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 {#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 {#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 {#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 {#versions}
The locked catalogue records this condition from 7.4 in the listed formal snapshots and 19beta3; fixed source coverage is PostgreSQL 18.6.
Related {#related}
Sources {#sources}
See the fixed execSRF.c and materialize path (lines 665-686) alongside the structured evidence record.
Compare versions
SQLSTATE evidence and recorded runtime versions
claims · identity
{
"claim_id": "identity",
"limits": "",
"method": "Read the fixed definition row.",
"position": 0,
"runtime": [],
"sources": [
"src.errcodes.18.6"
],
"statement": "39P02 is srf_protocol_violated in Class 39."
}claims · return-modes
{
"claim_id": "return-modes",
"limits": "",
"method": "Read the rsinfo.returnMode, isDone, and returnsSet checks.",
"position": 1,
"runtime": [],
"sources": [
"src.path.srf"
],
"statement": "The executor reports this code when a set-returning function violates value-per-call or materialize mode, or supplies an unrecognized returnMode."
}claims · boundary
{
"claim_id": "boundary",
"limits": "",
"method": "Interpret the source checks in their executor context.",
"position": 2,
"runtime": [],
"sources": [
"src.path.srf"
],
"statement": "The fixed path is an executor-to-set-returning-function contract, not an ordinary query row-count condition."
}messages · message.srf-value-per-call
{
"limits": "",
"message_id": "message.srf-value-per-call",
"path": "",
"position": 0,
"raw": {
"id": "message.srf-value-per-call",
"primary_template": "table-function protocol for value-per-call mode was not followed",
"severity_source": "ERROR",
"sources": [
"src.path.srf"
],
"sqlstate": "39P02"
},
"severity": "ERROR",
"sources": [
"src.path.srf"
],
"templates": [
{
"kind": "primary",
"literal": "table-function protocol for value-per-call mode was not followed",
"position": 0,
"role": "",
"template": "table-function protocol for value-per-call mode was not followed"
}
]
}messages · message.srf-materialize
{
"limits": "",
"message_id": "message.srf-materialize",
"path": "",
"position": 1,
"raw": {
"id": "message.srf-materialize",
"primary_template": "table-function protocol for materialize mode was not followed",
"severity_source": "ERROR",
"sources": [
"src.path.srf"
],
"sqlstate": "39P02"
},
"severity": "ERROR",
"sources": [
"src.path.srf"
],
"templates": [
{
"kind": "primary",
"literal": "table-function protocol for materialize mode was not followed",
"position": 0,
"role": "",
"template": "table-function protocol for materialize mode was not followed"
}
]
}messages · message.srf-returnmode
{
"limits": "",
"message_id": "message.srf-returnmode",
"path": "",
"position": 2,
"raw": {
"id": "message.srf-returnmode",
"primary_template": "unrecognized table-function returnMode: %d",
"severity_source": "ERROR",
"sources": [
"src.path.srf"
],
"sqlstate": "39P02"
},
"severity": "ERROR",
"sources": [
"src.path.srf"
],
"templates": [
{
"kind": "primary",
"literal": "unrecognized table-function returnMode:",
"position": 0,
"role": "",
"template": "unrecognized table-function returnMode: %d"
}
]
}sources · src.errcodes.18.6
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/errcodes.txt",
"position": 0,
"sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
"source_id": "src.errcodes.18.6",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L312"
}sources · src.calls.REL_18_6
{
"commit": "",
"docs_url": "",
"kind": "local_artifact",
"location": "",
"path": "raw/calls/REL_18_6.jsonl",
"position": 1,
"sha256": "9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf",
"source_id": "src.calls.REL_18_6",
"tag": "",
"url": ""
}sources · src.path.srf
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/executor/execSRF.c",
"position": 2,
"sha256": "5c6038cbcc254113a39119af636331063b11d75ad7757b027620d78ed1ecdf2a",
"source_id": "src.path.srf",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/executor/execSRF.c#L363-L365"
}Source references
Full definition and evidence JSON
Definition sources
center · PostgreSQL 18 · english-manuals:8f8fa28d620ccffb8d980bb7920513dc200cbc354fffb8e01f1e4a96de151b41
Text language: en · english-manuals:8f8fa28d620ccffb8d980bb7920513dc200cbc354fffb8e01f1e4a96de151b41