↑↓ 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

event_trigger_protocol_violated

Reading PG 18current·documented in 13 of 22 versions, 9.5 to 20

SQLSTATE
39P03
Condition name
event_trigger_protocol_violated
Class
External Routine Invocation Exception
Source macro
ERRCODE_E_R_I_E_EVENT_TRIGGER_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>39P03</h1>

At a glance

39P03 is event_trigger_protocol_violated. Fixed event-trigger helpers reject calls outside their required sql_drop, table_rewrite, or event-trigger function context.

Meaning

An event-trigger helper was called without the state it requires. The fixed messages identify sql_drop, table_rewrite, or a general event-trigger function context, so this is a call-context violation rather than an object-existence error.

Diagnosis

Identify the helper and required event context from the message. Check whether the call belongs in a sql_drop, table_rewrite, or other event-trigger function.

Response

Move the helper into the required event-trigger context or remove the invalid call; replaying the same DDL does not change that context.

Versions

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

Sources

See the fixed event_trigger.c helper 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.

39P03 is event_trigger_protocol_violated in Class 39.

Method: Read the fixed definition row.

Source: src/backend/utils/errcodes.txt

The core event-trigger functions reject calls outside their required sql_drop, table_rewrite, or event-trigger context with this code.

Method: Read each currentEventTriggerState guard and its message.

Source: src/backend/commands/event_trigger.c

The message names the required event-trigger function context, so the failing boundary is call context rather than object existence alone.

Method: Compare the guard with the function named in the message.

Source: src/backend/commands/event_trigger.c

Message templates

ERROR · message.sql-drop

Primary

%s can only be called in a sql_drop event trigger function

Source: src/backend/commands/event_trigger.c

ERROR · message.table-rewrite

Primary

%s can only be called in a table_rewrite event trigger function

Source: src/backend/commands/event_trigger.c

ERROR · message.event-trigger

Primary

%s can only be called in an event trigger function

Source: src/backend/commands/event_trigger.c

Reproduction & repair cases

No reproduction case is attached to this condition.

Recorded runtime evidence

No runtime observation is attached to this entry.

Version history 1
  1. 9.4 → 9.5 added

Definition snapshot: english-manuals:8a70296194d2a159053ae04c004… · English manual source