2ndQuadrant/pg_stat_plans — pull request #29 by petergeoghegan (2013-08-11 23:56:00+00:00)
Title: When explaining, verify query text

There are some scenarios in which it is possible for multiple calls to the
executor to occur at the same nesting level for the same query. This includes,
at the very least, when SQL functions are called.

As protection against the SQL function case in particular, but also as
insurance against other cases that may emerge, record the SQL text (EXPLAIN...
prefix and all) to be explained within pg_stat_plans_explain, and then verify
that it is consistent with the query descriptor sourceText indicated within
pgsp_ExecutorEnd().