I wrote:
> Hah - I thought of a solution. We can avoid this race condition if
> we make the remote session itself inspect pg_stat_activity and
> return its displayed application_name. Just need a foreign table
> that maps onto pg_stat_activity.
I went ahead and coded it that way, and it doesn't look too awful.
Any objections?
regards, tom lane