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 1ijDpj-00074p-Rj for pgsql-general@arkaria.postgresql.org; Mon, 23 Dec 2019 02:52:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ijDpi-0003wQ-FB for pgsql-general@arkaria.postgresql.org; Mon, 23 Dec 2019 02:52:34 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ijDph-0003wJ-WD for pgsql-general@lists.postgresql.org; Mon, 23 Dec 2019 02:52:34 +0000 Received: from mail-yb1-xb44.google.com ([2607:f8b0:4864:20::b44]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ijDpa-0004fQ-SQ for pgsql-general@lists.postgresql.org; Mon, 23 Dec 2019 02:52:32 +0000 Received: by mail-yb1-xb44.google.com with SMTP id v15so6552747ybp.13 for ; Sun, 22 Dec 2019 18:52:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:content-transfer-encoding:date:from:to:subject :in-reply-to:references:message-id:user-agent; bh=oP81GkaFbWI1uB3m/knfCg7+0ANPUTl3vLdgIS4nC2Y=; b=u35zLg4ng04T2p3kr6s3+4uVlJVMTnSedBk18hf1BVYU3HOgjz285l+cpYtFq31UAQ J/6lyadMN96/PgrEPtoNicjgXTtcz5swWHh/Ki6KF0n0TW+1VQhzz8PU5J7OrPXvfZSA VsDoWRXF3mfuYh03AeRrqmMrUk3bHFHdI3IoqLSPlp20fD/XgfjdJOmZVBUUXRfXDIoR BD9XEH34pEWxRpAJz/fb5oxgbSXClg37JMYuBguoazbOPRdbFlu5iMWTFvwQk8itpIjy BnpkzDtKPadlxPCBuD/p4vRmUTABrAYhvM6cKuA9HqUcX6VHfVk3PfJQCIVjs7dV5HBU oNOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:content-transfer-encoding:date:from :to:subject:in-reply-to:references:message-id:user-agent; bh=oP81GkaFbWI1uB3m/knfCg7+0ANPUTl3vLdgIS4nC2Y=; b=gLWGLe5nLTE3m5eRPlQpe36A2bgTkMVljGcbaukaKY0RexBlioadRLPVELOymOtNSn ISaQuCbeq5CHkaEFL13quVAR1QReM8gZZdGBIkSpN4RPRbmXFD0TdqNdVI8a/gcLtJa+ E2BhbwGLFYq570Nj9zcf0Q8Af+lX9NrQRo0HLrbA8OO6TyGivL74vlrLljF54RBLpfHN 43M4t7XXEAkp9sTYhGg8DnOv9antOgeuXCyn8CZOpjLYdVkc+N/eRx9Z3cEMqYz865De uhSFdkOqIQH2OzJSiVRj0tGh0ZVd/Hb7MtbutyotmyvM2k7Shu6lThRigblP19JO+QOO NXEQ== X-Gm-Message-State: APjAAAULlqZmaM/Q8Xrme+QYpycNFOYj+zHZELjlbSKP1Nhyu0pSCRws r3tVJsfEx615JAcpvI/FP8WpJJJlrYQ= X-Google-Smtp-Source: APXvYqwxiEajA+XlnPGuiWxZZF/T/Vv5i3gBttK7ffE0QQLD4z/GTDdtoXeWSr+MMqL93aLVjUAHAA== X-Received: by 2002:a25:fc0a:: with SMTP id v10mr18818745ybd.288.1577069545202; Sun, 22 Dec 2019 18:52:25 -0800 (PST) Received: from mail-cube (c-73-74-24-80.hsd1.il.comcast.net. [73.74.24.80]) by smtp.gmail.com with ESMTPSA id m30sm7479447ywh.12.2019.12.22.18.52.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Dec 2019 18:52:24 -0800 (PST) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Sun, 22 Dec 2019 20:52:23 -0600 From: Andrei Pozolotin To: pgsql-general@lists.postgresql.org Subject: Re: Question: what is proper way to define python function as event_trigger? In-Reply-To: <51571587-2017-c550-07ef-8e7ade96bbd4@openvistas.net> References: <0d6c5bdc3ab532bc3240cfb14bc55ce9@gmail.com> <51571587-2017-c550-07ef-8e7ade96bbd4@openvistas.net> Message-ID: <14c06e65a329f2b35c14342a68a6766c@gmail.com> X-Sender: andrei.pozolotin@gmail.com User-Agent: Roundcube Webmail/1.3.10 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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