Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ncCwz-0000QF-44 for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Apr 2022 21:12:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ncCwx-0007xf-J4 for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Apr 2022 21:12:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ncCwx-0007xV-6A for pgsql-hackers@lists.postgresql.org; Wed, 06 Apr 2022 21:12:23 +0000 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ncCwu-0001lp-SZ for pgsql-hackers@lists.postgresql.org; Wed, 06 Apr 2022 21:12:22 +0000 Received: by mail-ej1-x62e.google.com with SMTP id qh7so6766724ejb.11 for ; Wed, 06 Apr 2022 14:12:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=6hMsF9F2ddtDULsXAm6BIMv6ABwbB5jgEw2BQKfICAY=; b=ja5/gtKM+Gg/0U53PMZj30h1iaCsTM+6TxqgrGVT6kPfJswu19mjgMWdUX0PQWTBSO naVacXiaYkzdqvCSI1Wh9mYUaUgm5U1rMGPDKdxsiXj9YpEgqztB2N0Z8wOh5beCA5zp ES5N0vrI+GI+AnHOAT9RVt4SCo9g0oTtml3GeFjk4eS1Nx+YWYds2nj4X52c7/NkAC83 Dyf9IrcLl8KFtONvvkzEYNw2Y09KABmjtUnlPWT/2taKs29vutWdH0OlJHsSH4tZhURd llOtCGwgLZO+bMPfBnOBqfHqozDlbYwFuRJdKp8HdB9H2ees1cSMONe8Sr9TA+dPV8O7 hz0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=6hMsF9F2ddtDULsXAm6BIMv6ABwbB5jgEw2BQKfICAY=; b=ZUW36+Qyd3jLRJDKyH7XyskXeOVjj+BcGzTvWZwm8CwEdnd8VknE5Bqyu5as/vjQwJ QGOjnMdsfY2z4iClKcxF+30B54Ps5hx4ZVdMZBJPv178cj1zZCVbIQIoZJbpbeigmLiX CunkOImcZU+z9bO6ML/RYGFozOdHuWH4zSeJT/gmaAiy3bmjH8KTcXRtYf15Hp3wjQ2o GaVV8Uzvx6vU5pPLyhf3JjLbW4PX6dioeCXL/Pc5d5kzKva9LETo8cWckGAdeM+5wLte dzNslUZsks7a2ZxB2MMmh2dTpNwkMr5ztNeAh510zTZuETVzEiFQOFTD63l9XKgF9f36 mrFA== X-Gm-Message-State: AOAM533qAx41W61VZuNjpMlKyKSm2MQewJrtgrHpCpyiXi5jIIWNgVXC 0Q44HdyJNsAJiJw8SZ9CT5olwMtaOMT7sieCFg8= X-Google-Smtp-Source: ABdhPJz/LGwTCHXF+/GdSHRohl5jBNoHAxZMD7v4QCHQ6GcKvwiZmjRxq89vqgIt0zeuM0btc/wolMIDXbrO3Lv3zX0= X-Received: by 2002:a17:907:6e21:b0:6e1:c1ab:d0e0 with SMTP id sd33-20020a1709076e2100b006e1c1abd0e0mr10306620ejc.358.1649279540079; Wed, 06 Apr 2022 14:12:20 -0700 (PDT) MIME-Version: 1.0 References: <164581437973.1035.16436524743292685141.pgcf@coridan.postgresql.org> <622A8B8C.1060306@anastigmatix.net> In-Reply-To: Reply-To: fabriziomello@gmail.com From: =?UTF-8?Q?Fabr=C3=ADzio_de_Royes_Mello?= Date: Wed, 6 Apr 2022 18:12:08 -0300 Message-ID: Subject: Re: trigger example for plsample To: Mark Wong Cc: Chapman Flack , PostgreSQL Hackers , Konstantina Skovola Content-Type: multipart/alternative; boundary="0000000000001f2de705dc02d10f" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000001f2de705dc02d10f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Apr 6, 2022 at 5:44 PM Mark Wong wrote: > > On Thu, Mar 10, 2022 at 06:36:44PM -0500, Chapman Flack wrote: > > On 03/02/22 15:12, Mark Wong wrote: > > > > > I've attached v2, which reduces the output: > > > > > > * Removing the notices for the text body, and the "compile" message. > > > * Replaced the notice for "compile" message with a comment as a > > > placeholder for where a compiling code or checking a cache may go. > > > * Reducing the number of rows inserted into the table, thus reducing > > > the number of notice messages about which code path is taken. > > > > I think the simplifying assumption of a simple interpreted language allows > > a lot more of this code to go away. I mean more or less that whole firs= t > > PG_TRY...PG_END_TRY block, which could be replaced with a comment sayin= g > > something like > > > > The source text may be augmented here, such as by wrapping it as the > > body of a function in the target language, prefixing a parameter list > > with names like TD_name, TD_relid, TD_table_name, TD_table_schema, > > TD_event, TD_when, TD_level, TD_NEW, TD_OLD, and args, using whatever > > types in the target language are convenient. The augmented text can b= e > > cached in a longer-lived memory context, or, if the target language uses > > a compilation step, that can be done here, caching the result of the > > compilation. > > > > That would leave only the later PG_TRY block where the function gets > > "executed". That could stay largely as is, but should probably also hav= e > > a comment within it, something like > > > > Here the function (the possibly-augmented source text, or the result > > of compilation if the target language uses such a step) should be > > executed, after binding these values from the TriggerData struct to > > the expected parameters. > > > > That should make the example shorter and clearer, and preserve the output > > tested by the regression test. Trying to show much more than that involves > > assumptions about what the PL's target language syntax looks like, how its > > execution engine works and parameters are bound, and so on, and that is > > likely to just be distracting, IMV. > > I think I've applied all of these suggestions and attached a new patch. > Cool... I also have a look into the code. To me everything is also ok!!! Regards, -- Fabr=C3=ADzio de Royes Mello --0000000000001f2de705dc02d10f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Wed, Apr 6, 2022 at 5:44 PM Mark Wong <markwkm@gmail.com> wrote:
>
&= gt; On Thu, Mar 10, 2022 at 06:36:44PM -0500, Chapman Flack wrote:
> = > On 03/02/22 15:12, Mark Wong wrote:
> >
> > > I&#= 39;ve attached v2, which reduces the output:
> > >
> >= > * Removing the notices for the text body, and the "compile"= message.
> > > * Replaced the notice for "compile" m= essage with a comment as a
> > > =C2=A0 placeholder for where a= compiling code or checking a cache may go.
> > > * Reducing th= e number of rows inserted into the table, thus reducing
> > > = =C2=A0 the number of notice messages about which code path is taken.
>= ; >
> > I think the simplifying assumption of a simple interpre= ted language allows
> > a lot more of this code to go away. I mean= more or less that whole first
> > PG_TRY...PG_END_TRY block, whic= h could be replaced with a comment saying
> > something like
&g= t; >
> > =C2=A0 The source text may be augmented here, such as = by wrapping it as the
> > =C2=A0 body of a function in the target = language, prefixing a parameter list
> > =C2=A0 with names like TD= _name, TD_relid, TD_table_name, TD_table_schema,
> > =C2=A0 TD_eve= nt, TD_when, TD_level, TD_NEW, TD_OLD, and args, using whatever
> >= ; =C2=A0 types in the target language are convenient. The augmented text ca= n be
> > =C2=A0 cached in a longer-lived memory context, or, if th= e target language uses
> > =C2=A0 a compilation step, that can be = done here, caching the result of the
> > =C2=A0 compilation.
&g= t; >
> > That would leave only the later PG_TRY block where the= function gets
> > "executed". That could stay largely a= s is, but should probably also have
> > a comment within it, somet= hing like
> >
> > =C2=A0 Here the function (the possibly-= augmented source text, or the result
> > =C2=A0 of compilation if = the target language uses such a step) should be
> > =C2=A0 execute= d, after binding these values from the TriggerData struct to
> > = =C2=A0 the expected parameters.
> >
> > That should make = the example shorter and clearer, and preserve the output
> > teste= d by the regression test. Trying to show much more than that involves
&g= t; > assumptions about what the PL's target language syntax looks li= ke, how its
> > execution engine works and parameters are bound, a= nd so on, and that is
> > likely to just be distracting, IMV.
&= gt;
> I think I've applied all of these suggestions and attached = a new patch.
>

Cool... I also have a look into the code. To me= everything is also ok!!!

Regards,

--
Fabr=C3=ADzio de Ro= yes Mello
--0000000000001f2de705dc02d10f--