I'm not sure about some of the details. I think it would make more sense to reset ApplyMessageContext in apply_dispatch(), so that it is done consistently after every message (as the name implies), not only some messages.
Also, perhaps ApplyMessageContext should be a child of TopTransactionContext. (You have it as a child of ApplyContext, which is under TopMemoryContext.) -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers