[PATCH] Writing changes of decoding plugin in the memory context where data is kept? - Mailing list pgsql-hackers

From Michael Paquier
Subject [PATCH] Writing changes of decoding plugin in the memory context where data is kept?
Date
Msg-id CAB7nPqT2jwWWYf=kng-_06Ss3qM3DKJzXQrojF0B-NJgcP2sdA@mail.gmail.com
Whole thread Raw
Responses Re: [PATCH] Writing changes of decoding plugin in the memory context where data is kept?  (Andres Freund <andres@2ndquadrant.com>)
List pgsql-hackers
Hi all,

When working on a decoder plugin, I have been pointed that it is
incorrect to write changes in an output plugin while not being in the
memory context where changes are written.
In pg_decode_change@test_decoding.c, we do the following:
old = MemoryContextSwitchTo(data->context);
OutputPluginPrepareWrite(ctx, true);
[...]
MemoryContextSwitchTo(old);
MemoryContextReset(data->context);
OutputPluginWrite(ctx, true);

Wouldn't it be better to call OutputPluginWrite before switching back
to the old context? The attached patch for test_decoding does so.
Comments welcome.
Regards,
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: Sending out a request for more buildfarm animals?
Next
From: Tom Lane
Date:
Subject: Re: Cache invalidation bug in RelationGetIndexAttrBitmap()