Re: Question: what is proper way to define python function asevent_trigger?
От | Jeff Ross |
---|---|
Тема | Re: Question: what is proper way to define python function asevent_trigger? |
Дата | |
Msg-id | c4b5ce31-027a-d531-3305-4fe9f35c70de@openvistas.net обсуждение исходный текст |
Ответ на | Question: what is proper way to define python function asevent_trigger? (Andrei Pozolotin <andrei.pozolotin@gmail.com>) |
Ответы |
Re: Question: what is proper way to define python function asevent_trigger?
|
Список | pgsql-general |
On 2019-12-22 15:27, Andrei Pozolotin wrote: > > Hello. > > Problem: > > 1. any attempt to define python function as an event_trigger, i.e.: > > CREATE FUNCTION public.verify() > RETURNS event_trigger > LANGUAGE 'plpython3u' > AS $$ print("hello-kitty") $$; > > 2. fails with message: > > ERROR: trigger functions can only be called as triggers > > SQL state: 0A000 > > 3. here in the source: > > https://github.com/postgres/postgres/blob/master/src/pl/plpython/plpy_procedure.c#L226 > > Question: > > what is proper way to define python function as event_trigger? > > Thank you. > > Just do "create function public.verify() as trigger..." https://www.postgresql.org/docs/10/plpython-trigger.html TD["event"] contains the type of event as a string and I routinely do things like if TD["event"] == "UPDATE": #do update stuff elif TD["event'} == "INSERT": #do insert related stuff Jeff
В списке pgsql-general по дате отправления: