39P03ERRORTier 2 — Caution✅ HIGH confidenceevent trigger protocol violated
What this means
SQLSTATE 39P03 is a Postgres-specific error raised when an event trigger function violates the event trigger calling protocol — for example, returning a non-VOID value from an event trigger function.
Why it happens
- 1An event trigger function returns a non-VOID value (event triggers must return VOID)
- 2An event trigger function does not follow the event trigger calling conventions
How to reproduce
Event trigger function returning a non-VOID value.
CREATE OR REPLACE FUNCTION bad_event_trigger() RETURNS event_trigger AS $
BEGIN
-- implementation
END;
$ LANGUAGE plpgsql;
-- If it returns a value instead of nothing, 39P03 firesFix 1: Ensure event trigger functions return VOID
When writing event trigger functions.
CREATE OR REPLACE FUNCTION ddl_event_fn() RETURNS event_trigger AS $
DECLARE obj RECORD;
BEGIN
FOR obj IN SELECT * FROM pg_event_trigger_ddl_commands() LOOP
RAISE NOTICE 'DDL: % on %', obj.command_tag, obj.object_identity;
END LOOP;
-- no RETURN value needed
END;
$ LANGUAGE plpgsql;Why this works
Event trigger functions declared as RETURNS event_trigger must not return a value. The function must complete normally (RETURN; implicitly) or by falling off the end.
Version notes
Postgres 9.3+Event triggers introduced in Postgres 9.3.Sources
📚 Official docs: https://www.postgresql.org/docs/current/errcodes-appendix.html
📚 Feature docs: https://www.postgresql.org/docs/current/event-trigger-definition.html
🔧 Source ref: Class 39 — External Routine Invocation Exception (Postgres-specific)
Confidence assessment
✅ HIGH confidence
Postgres-specific. Stable since 9.3.
See also
🔗 Related errors
📄 Reference pages