How to use SPI_saveplan

Поиск
Список
Период
Сортировка
От Jack Orenstein
Тема How to use SPI_saveplan
Дата
Msg-id 45035D6E.7030507@geophile.com
обсуждение исходный текст
Ответы Re: How to use SPI_saveplan  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Is this logical?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Idle in transaction state.