pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrei Pozolotin <andrei.pozolotin@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Question: what is proper way to define python function as event_trigger?
Date: Sun, 22 Dec 2019 20:52:23 -0600
Message-ID: <14c06e65a329f2b35c14342a68a6766c@gmail.com> (raw)
In-Reply-To: <51571587-2017-c550-07ef-8e7ade96bbd4@openvistas.net>
References: <0d6c5bdc3ab532bc3240cfb14bc55ce9@gmail.com>
	<c4b5ce31-027a-d531-3305-4fe9f35c70de@openvistas.net>
	<51571587-2017-c550-07ef-8e7ade96bbd4@openvistas.net>

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





view thread (6+ messages)  latest in thread

Message-ID: <14c06e65a329f2b35c14342a68a6766c@gmail.com>
Permalink:  ../14c06e65a329f2b35c14342a68a6766c@gmail.com/
Also on:    postgresql.org/message-id/14c06e65a329f2b35c14342a68a6766c@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: andrei.pozolotin@gmail.com
  Subject: Re: Question: what is proper way to define python function as event_trigger?
  In-Reply-To: <14c06e65a329f2b35c14342a68a6766c@gmail.com>
  References: <0d6c5bdc3ab532bc3240cfb14bc55ce9@gmail.com> <c4b5ce31-027a-d531-3305-4fe9f35c70de@openvistas.net> <51571587-2017-c550-07ef-8e7ade96bbd4@openvistas.net> <14c06e65a329f2b35c14342a68a6766c@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox