Search Postgresql Archives

Re: How to use SPI_saveplan

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jack Orenstein <jao@xxxxxxxxxxxx> writes:
> I'm missing something very basic. If I do this:

>      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?

It's up to you to save the pointer somewhere where you can find it again
when you need it.  If there's only one interesting plan, use a static
variable.  Otherwise, you'll need some sort of data structure to map
from what-you-need to the-plan-that-does-it.  You can find examples of
these approaches in the PG sources (from memory, ruleutils.c has some
examples of the former approach while ri_triggers.c does the latter).

			regards, tom lane


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux