39P01 — trigger_protocol_violated
39P01
At a glance
39P01 is trigger_protocol_violated. Fixed PostgreSQL 18.6 paths cover the core trigger manager, contrib/tcn checks, and PL/Perl trigger return handling, with path-specific messages and severity.
| Field | Value |
|---|---|
| SQLSTATE | 39P01 |
| Condition | trigger_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_TRIGGER_PROTOCOL_VIOLATED |
| Aliases | — |
Meaning
The code marks a trigger protocol mismatch. Core trigger-manager messages include trigger function %u returned null value and BEFORE STATEMENT trigger cannot return a value. contrib/tcn checks trigger timing, level, argument count, and primary-key setup; PL/Perl has a DELETE-row WARNING and a separate ERROR for an invalid trigger return.
Diagnosis
Use the exact message to identify the path. For the trigger manager, check the isnull flag and BEFORE STATEMENT return contract; for tcn, check AFTER timing, row level, argument count, and primary key; for PL/Perl, check whether the return is undef, SKIP, or MODIFY. The DELETE-row WARNING means a modification was ignored, while the invalid-return message is an ERROR.
Response
Correct the timing, level, event, arguments, or return value for the identified path. For PL/Perl, decide whether the ignored DELETE-row modification is acceptable before writing again; retry only after the contract is fixed and the original operation is known not to have completed.
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
Sources
See the fixed trigger.c, tcn.c, and plperl.c paths alongside the structured evidence record.