On Wed, May 19, 2021 at 2:05 PM Michael Paquier <michael@paquier.xyz> wrote:
> On Wed, May 19, 2021 at 10:26:28AM +0530, Amit Kapila wrote:
> > How about moving AfterTriggerEndQuery() to apply_handle_*_internal
> > calls? That way, we might not even need to change Push/Pop calls.
>
> Isn't that going to be a problem when a tuple is moved to a new
> partition in the tuple routing? This does a DELETE followed by an
> INSERT, but the operation is an UPDATE.
That indeed doesn't work. Once AfterTriggerEndQuery() would get
called for DELETE from apply_handle_delete_internal(), after triggers
of the subsequent INSERT can't be processed, instead causing:
ERROR: AfterTriggerSaveEvent() called outside of query
IOW, the patch you posted earlier seems like the way to go.
--
Amit Langote
EDB: http://www.enterprisedb.com