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