Re: On login trigger: take three

Поиск
Список
Период
Сортировка
От Bharath Rupireddy
Тема Re: On login trigger: take three
Дата
Msg-id CALj2ACWFUW4jX9EW7CLxbzSS+b7b0Z=xKYrqzj2Rstc9MCEx7g@mail.gmail.com
обсуждение исходный текст
Ответ на Re: On login trigger: take three  (Alexander Korotkov <aekorotkov@gmail.com>)
Список pgsql-hackers
On Mon, Oct 16, 2023 at 6:36 AM Alexander Korotkov <aekorotkov@gmail.com> wrote:
>
> > On Mon, Oct 16, 2023 at 02:47:03AM +0300, Alexander Korotkov wrote:
> > > The attached revision fixes test failures spotted by
> > > commitfest.cputube.org.  Also, perl scripts passed perltidy.
>
> You are very fast and sharp eye!
> Thank you for fixing the indentation.  I just pushed fixes for the rest.

I noticed some typos related to this feature.

While on this, the event trigger example for C programming language
shown in the docs doesn't compile as-is. fmgr.h is needed.

Please see the attached patch.

[1]
2024-02-06 05:31:24.453 UTC [1401414] LOG:  tag LOGIN, event login

#include "postgres.h"

#include "commands/event_trigger.h"
#include "fmgr.h"

PG_MODULE_MAGIC;

PG_FUNCTION_INFO_V1(onlogin);

Datum
onlogin(PG_FUNCTION_ARGS)
{
    EventTriggerData *trigdata;

    if (!CALLED_AS_EVENT_TRIGGER(fcinfo))  /* internal error */
        elog(ERROR, "not fired by event trigger manager");

    trigdata = (EventTriggerData *) fcinfo->context;

    elog(LOG, "tag %s, event %s", GetCommandTagName(trigdata->tag),
trigdata->event);

    PG_RETURN_NULL();
}

gcc -shared -fPIC -I /home/ubuntu/postgres/pg17/include/server -o
login_trigger.so login_trigger.c

LOAD '/home/ubuntu/postgres/login_trigger.so';

CREATE FUNCTION onlogin() RETURNS event_trigger
    AS '/home/ubuntu/postgres/login_trigger' LANGUAGE C;

CREATE EVENT TRIGGER onlogin ON login
    EXECUTE FUNCTION onlogin();

--
Bharath Rupireddy
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: GUC-ify walsender MAX_SEND_SIZE constant
Следующее
От: Masahiko Sawada
Дата:
Сообщение: Re: Improve eviction algorithm in ReorderBuffer