39P01
Read PG 18 manual ↗trigger_protocol_violated
- SQLSTATE
- 39P01
- Condition name
- trigger_protocol_violated
- Class
- External Routine Invocation Exception
- Source macro
- ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED
- Evidence
- Source path confirmed
English SQLSTATE atlas: authored explanations and source/runtime evidence are separate from the manual definitions. View source ↗
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.
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.
Sources
See the fixed trigger.c, tcn.c, and plperl.c paths 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.
39P01 is trigger_protocol_violated in Class 39.
Method: Read the fixed definition row.
The core trigger manager reports this code when a trigger function sets the isnull flag, and for invalid BEFORE STATEMENT return values.
Method: Read each fixed trigger-manager context and its message.
contrib/tcn checks trigger invocation context, AFTER timing, row level, argument count, and primary-key setup with this code.
Method: Read the complete tcn checks around each report.
PL/Perl has a WARNING variant for an ignored DELETE-row modification and an ERROR variant for an invalid trigger return value.
Method: Compare ereport levels and exact messages.
- src/backend/utils/errcodes.txt · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7 raw/calls/REL_18_6.jsonl· ·- src/backend/commands/trigger.c · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7 - contrib/tcn/tcn.c · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7 - src/pl/plperl/plperl.c · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7
Message templates
ERROR · message.trigger-null
Primary
trigger function %u returned null value
ERROR · message.before-statement
Primary
BEFORE STATEMENT trigger cannot return a value
ERROR · message.tcn-called-as-trigger
Primary
triggered_change_notification: must be called as trigger
ERROR · message.tcn-after-change
Primary
triggered_change_notification: must be called after the change
ERROR · message.tcn-each-row
Primary
triggered_change_notification: must be called for each row
ERROR · message.tcn-one-parameter
Primary
triggered_change_notification: must not be called with more than one parameter
ERROR · message.tcn-primary-key
Primary
triggered_change_notification: must be called on a table with a primary key
WARNING · message.plperl-delete-warning
Primary
ignoring modified row in DELETE trigger
ERROR · message.plperl-invalid-return
Primary
result of PL/Perl trigger function must be undef, "SKIP", or "MODIFY"
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:043c90ea7404f171f59d747ef8b… · English manual source