Re: Question: what is proper way to define python function as event_trigger?

From: Andrei Pozolotin <andrei(dot)pozolotin(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Question: what is proper way to define python function as event_trigger?
Date: 2019-12-23 02:52:23
Message-ID: 14c06e65a329f2b35c14342a68a6766c@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jeff, hi:

1. my concern is global "event_trigger" for DDL, not per-table "trigger"
for DML

2. regardless - thank you for the link, I found it helpful

3. Tom Lane says event_trigger is just not implemented in plpython

Andrei.

On 2019-12-22 17:20, Jeff Ross wrote:
> On 2019-12-22 16:07, Jeff Ross wrote:
>> 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..."
>>
> My bad--that should be "create function public.verify() returns
> trigger... "
>
> Jeff

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrei Pozolotin 2019-12-23 02:53:20 Re: Question: what is proper way to define python function as event_trigger?
Previous Message Adrian Klaver 2019-12-23 01:52:52 Re: Semi-unable to add new records to table--primary key needed?