pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Euler Taveira <euler@eulerto.com>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: event trigger support for PL/Python
Date: Wed, 06 Aug 2025 21:34:58 -0300
Message-ID: <a654c6d4-725c-4ae8-b349-e13a113d0df5@app.fastmail.com> (raw)
In-Reply-To: <CAFj8pRA_LmSMt7SRXgu+eF=rWF71ANCkG_wFE_PyVu4a4xjb9A@mail.gmail.com>
References: <03f03515-2068-4f5b-b357-8fb540883c38@app.fastmail.com>
	<CAFj8pRB2CRwfE6wRoARbL50y3eW1j+hY7d4AvTFHCxJvrKbgyw@mail.gmail.com>
	<c56def96-0524-4e7b-8b5b-3de5a9f3c40e@app.fastmail.com>
	<CAFj8pRA_LmSMt7SRXgu+eF=rWF71ANCkG_wFE_PyVu4a4xjb9A@mail.gmail.com>

On Wed, Aug 6, 2025, at 5:16 PM, Pavel Stehule wrote:
>
> I am checking the code, and I don't like too much an introduction of 
> PLPyTrigType - more when it is used in 
> the pair with variable is_trigger. This combination looks strange and 
> it is a little bit difficult to read for me.
>
> Maybe I prefer some like
>
> typedef enum {
>   PLPY_CALLED_AS_TRIGGER,
>   PLPY_CALLED_AS_EVENT_TRIGGER,
>   PLPY_CALLED_AS_FUNCTION
> } PLPyCallType;
>

I used the same pattern as PL/pgSQL

typedef enum PLpgSQL_trigtype
{
    PLPGSQL_DML_TRIGGER,
    PLPGSQL_EVENT_TRIGGER,
    PLPGSQL_NOT_TRIGGER,
} PLpgSQL_trigtype;

Are you suggesting that we should modify it too?

> and then instead
>
> if (is_trigger == PLPY_NOT_TRIGGER)
>
> the code can looks like
>
> if (call_type == PLPY_CALLED_AS_FUNCTION)
> {
>
> }
>

The is_trigger variable is similar to fn_is_trigger in PL/pgSQL (see
PLpgSQL_function). If this variable is not clear maybe a prefix should avoid
confusion.


-- 
Euler Taveira
EDB   https://www.enterprisedb.com/





view thread (11+ messages)  latest in thread

Message-ID: <a654c6d4-725c-4ae8-b349-e13a113d0df5@app.fastmail.com>
Permalink:  ../a654c6d4-725c-4ae8-b349-e13a113d0df5@app.fastmail.com/
Also on:    postgresql.org/message-id/a654c6d4-725c-4ae8-b349-e13a113d0df5@app.fastmail.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-hackers@postgresql.org
  Cc: euler@eulerto.com, pavel.stehule@gmail.com
  Subject: Re: event trigger support for PL/Python
  In-Reply-To: <a654c6d4-725c-4ae8-b349-e13a113d0df5@app.fastmail.com>
  References: <03f03515-2068-4f5b-b357-8fb540883c38@app.fastmail.com> <CAFj8pRB2CRwfE6wRoARbL50y3eW1j+hY7d4AvTFHCxJvrKbgyw@mail.gmail.com> <c56def96-0524-4e7b-8b5b-3de5a9f3c40e@app.fastmail.com> <CAFj8pRA_LmSMt7SRXgu+eF=rWF71ANCkG_wFE_PyVu4a4xjb9A@mail.gmail.com> <a654c6d4-725c-4ae8-b349-e13a113d0df5@app.fastmail.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