Peter Eisentraut <peter_e@gmx.net> writes:
> Tom Lane writes:
>> The other possibility is to make EXPLAIN output look like a SELECT
>> result. Not sure how hard this would be to do, but in the long run
>> I suppose that would be the direction to move in.
> You could internally rewrite it to something like
> select explain('select * from pg_class;');
Having looked, I think it wouldn't be that bad to call the regular
printtup.c routines directly. Assuming that the output model we
want is "one text column, with one row per line", it'd only be
necessary to fake up a correct TupleDesc and then form a HeapTuple
from each line of output. Lots less work than trying to rewrite
the query, I think.
regards, tom lane