Re: event trigger support for PL/Python - Mailing list pgsql-hackers

From Euler Taveira
Subject Re: event trigger support for PL/Python
Date
Msg-id a654c6d4-725c-4ae8-b349-e13a113d0df5@app.fastmail.com
Whole thread Raw
In response to Re: event trigger support for PL/Python  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: event trigger support for PL/Python
List 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/



pgsql-hackers by date:

Previous
From: "Joel Jacobson"
Date:
Subject: Re: Optimize LISTEN/NOTIFY
Next
From: Michael Paquier
Date:
Subject: Re: Dead code with short varlenas in toast_save_datum()