"Joshua D. Drake" <[EMAIL PROTECTED]> writes:
> Mike Nolan wrote:
>> That part I get, but I cannot seem to get an 'explain select....' to return
>> the explain output inside a function.

> Oh interesting. Hmmm. Alvaro can you think of a way to execute the 
> result into a variable and return it as a notice?

I think it's done already, at least if you are using a recent release.
I note the following relevant items in the CVS log:

2005-04-05 14:05  tgl

        * doc/src/sgml/plpgsql.sgml, src/pl/plpgsql/src/gram.y: Adjust
        grammar for plpgsql's OPEN command so that a cursor can be OPENed
        on non-SELECT commands such as EXPLAIN or SHOW (anything that
        returns tuples is allowed).  This flexibility already existed for
        bound cursors, but OPEN was artificially restricting what it would
        take.  Per a gripe some months back.

2005-02-10 15:36  tgl

        * src/backend/: executor/spi.c, tcop/pquery.c (REL8_0_STABLE),
        executor/spi.c, tcop/pquery.c: Fix SPI cursor support to allow
        scanning the results of utility commands that return tuples (such
        as EXPLAIN).  Per gripe from Michael Fuhr.  Side effect: fix an old
        bug that unintentionally disabled backward scans for all
        SPI-created cursors.

(The latter is in 8.0.2 and up, the former only in CVS tip.)

This is relevant to plpgsql because both "FOR ... IN query" and plpgsql
cursors depend on SPI cursors.

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

Reply via email to