Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ijAX4-0006up-0l for pgsql-general@arkaria.postgresql.org; Sun, 22 Dec 2019 23:21:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ijAX2-00065M-Ia for pgsql-general@arkaria.postgresql.org; Sun, 22 Dec 2019 23:21:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ijAX2-00065E-8q for pgsql-general@lists.postgresql.org; Sun, 22 Dec 2019 23:21:04 +0000 Received: from luna.openvistas.net ([207.158.15.156] helo=openvistas.net) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ijAWu-00016l-B9 for pgsql-general@lists.postgresql.org; Sun, 22 Dec 2019 23:21:03 +0000 Received: (qmail 46361 invoked from network); 22 Dec 2019 23:20:52 -0000 Received: from unknown (HELO ?10.0.26.26?) (jross@216.166.169.13) de/crypted with TLSv1.2: ECDHE-RSA-AES128-GCM-SHA256 [128/128] DN=none by mail.openvistas.net with ESMTPSA; 22 Dec 2019 23:20:52 -0000 Subject: Re: Question: what is proper way to define python function as event_trigger? To: pgsql-general@lists.postgresql.org References: <0d6c5bdc3ab532bc3240cfb14bc55ce9@gmail.com> From: Jeff Ross Message-ID: <51571587-2017-c550-07ef-8e7ade96bbd4@openvistas.net> Date: Sun, 22 Dec 2019 16:20:51 -0700 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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