How to use SPI_saveplan - Mailing list pgsql-general

From Jack Orenstein
Subject How to use SPI_saveplan
Date
Msg-id 45035D6E.7030507@geophile.com
Whole thread Raw
Responses Re: How to use SPI_saveplan
List pgsql-general
The documentation on SPI_saveplan says:

     SPI_saveplan saves a passed plan (prepared by SPI_prepare) in
     memory ... and returns a pointer to the saved plan. This gives
     you the ability to reuse prepared plans in the subsequent
     invocations of your procedure in the current session. You may
     save the pointer returned in a local variable.

I'm missing something very basic. If I do this:

     PG_FUNCTION_INFO_V1(add_one);

     Datum foobar(PG_FUNCTION_ARGS)
     {
         ...
         void* plan = SPI_prepare(...);
         void* saved_plan = SPI_saveplan(plan);
         ...
     }

then how can I access the saved plan in a later invocation of foobar?
saved_plan goes out of scope on exit from foobar.

I've googled, but found little but copies of the postgres doc quoted
above.

Jack Orenstein



pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Is this logical?
Next
From: Tom Lane
Date:
Subject: Re: Idle in transaction state.