[PATCH] Writing changes of decoding plugin in the memory context where data is kept?

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: [PATCH] Writing changes of decoding plugin in the memory context where data is kept?
Date: 2014-05-15 00:11:15
Message-ID: CAB7nPqT2jwWWYf=kng-_06Ss3qM3DKJzXQrojF0B-NJgcP2sdA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)test_decoding(dot)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 Content-Type Size
0001-Write-changes-of-test_decoding-while-being-in-the-da.patch text/plain 1.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2014-05-15 00:13:06 Re: Cache invalidation bug in RelationGetIndexAttrBitmap()
Previous Message Tomas Vondra 2014-05-14 22:41:02 Re: Sending out a request for more buildfarm animals?