I wrote:
> I think the right fix is to make sure that ProcessCompletedNotifies
> saves and restores the call-time CurrentMemoryContext.
The patch committed here appears to fix it for me:
http://git.postgresql.org/gitweb?p=postgresql.git;a=commitdiff;h=722548e4309c28631ada292fe6cad04ae8f9c151
regards, tom lane