How to use SPI_saveplan

From: Jack Orenstein <jao(at)geophile(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: How to use SPI_saveplan
Date: 2006-09-10 00:33:50
Message-ID: 45035D6E.7030507@geophile.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2006-09-10 00:49:34 Re: Idle in transaction state.
Previous Message Stephan Szabo 2006-09-10 00:18:52 Re: Is this logical?