On 11 January 2013 16:52, Simon Riggs <simon@2ndquadrant.com> wrote:
> We already overload the signals, so its just a new type for the signal
> handler to cope with.
>
> See procsignal_sigusr1_handler()
I roughed up something to help you here... this is like 50% of a patch.
pg_explain_backend() calls a SIGUSR1 variant which then allows a call
to RunDynamicExplain() during any call to CHECK_FOR_INTERRUPTS()
That only works when something in the executor has called
SetDynamicExplain(), which later needs to be Unset...
So that's all you need to invoke a dynamic EXPLAIN via a sysadmin
function. All you need to do is generate an EXPLAIN and dump it
somewhere useful, like the server log. Over to you Pavel. There's a
patch somewhere by Greg Stark that generated a plan from a running
server for progress bar stuff, but that was like 5 years ago nearly.
But the explain invocation stuff from that might be useful as a guide.
--
Simon Riggs http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services