On Thu, Apr 20, 2023 at 6:09 PM shveta malik <shveta.malik@gmail.com> wrote:
>
>
> Few more comments, mainly for event_trigger.c in the patch dated April17:
>
> 1)EventTriggerCommonSetup()
> + pub_funcoid = LookupFuncName(pubfuncname, 0, NULL, true);
>
> This is the code where we have special handling for ddl-triggers. Here
> we are passing 'missing_ok' as true, so shouldn't we check pub_funcoid
> against 'InvalidOid' ?
>
I think so. However, I think this shouldn't be part of the first patch
as the first patch is only about deparsing. We should move this to DDL
publication patch or maybe a separate patch altogether. Another thing
is I feel it is better if this functionality is part of
filter_event_trigger().
>
> 2) EventTriggerTableInitWriteEnd()
>
> + if (stmt->objtype == OBJECT_TABLE)
> + {
> + parent = currentEventTriggerState->currentCommand->parent;
> + pfree(currentEventTriggerState->currentCommand);
> + currentEventTriggerState->currentCommand = parent;
> + }
> + else
> + {
> + MemoryContext oldcxt;
> + oldcxt = MemoryContextSwitchTo(currentEventTriggerState->cxt);
> + currentEventTriggerState->currentCommand->d.simple.address = address;
> + currentEventTriggerState->commandList =
> + lappend(currentEventTriggerState->commandList,
> + currentEventTriggerState->currentCommand);
> +
> + MemoryContextSwitchTo(oldcxt);
> + }
> +}
>
> It will be good to add some comments in the 'else' part. It is not
> very much clear what exactly we are doing here and for which scenario.
>
Yeah, that would be better. I feel the event trigger related changes
should be moved to a separate patch in itself.
--
With Regards,
Amit Kapila.