Re: event trigger support for PL/Python

From: "Euler Taveira" <euler(at)eulerto(dot)com>
To: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: event trigger support for PL/Python
Date: 2025-08-07 00:34:58
Message-ID: a654c6d4-725c-4ae8-b349-e13a113d0df5@app.fastmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2025-08-07 01:01:26 Re: Dead code with short varlenas in toast_save_datum()
Previous Message Joel Jacobson 2025-08-07 00:16:05 Re: Optimize LISTEN/NOTIFY