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