What's the syntax used to write a Postgresql event trigger in Python? This
CREATE OR REPLACE FUNCTION log_schema_changes()
RETURNS EVENT_TRIGGER
LANGUAGE plpython3u
AS $$
import plpy
plyp.warning(TD)
$$;
CREATE EVENT TRIGGER log_ddl_changes
ON ddl_command_start
WHEN TAG IN ('CREATE TABLE', 'ALTER TABLE', 'DROP TABLE', 'CREATE INDEX', 'ALTER INDEX', 'DROP INDEX')
EXECUTE FUNCTION log_schema_changes();
generates the error message: ERROR: trigger functions can only be called as triggers
Note: version info psql (15.6 (Ubuntu 15.6-1.pgdg20.04+1), server 15.7 (Ubuntu 15.7-1.pgdg22.04+1))
audit
? So there is one create function, but in CREATE EVENT TRIGGER you call another function?CREATE OR REPLACE FUNCTION log_schema_changes() RETURNS EVENT_TRIGGER LANGUAGE plpython3u AS $$ import plpy plyp.warning(TD) $$;