From: | Jack Orenstein <jao(at)geophile(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: How to use SPI_saveplan |
Date: | 2006-09-10 02:45:25 |
Message-ID: | 45037C45.8090405@geophile.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Tom Lane wrote:
> Jack Orenstein <jao(at)geophile(dot)com> writes:
>> Assigning SPI_prepare output to a local makes sense. Assigning
>> SPI_saveplan output to a static makes sense. But I don't see
>> the point in assigning SPI_saveplan output to a local, yet
>> that's what one case the doc specifically mentions.
>
> Hm, are you speaking of this?
>
> <para>
> <function>SPI_saveplan</function> saves a passed plan (prepared by
> <function>SPI_prepare</function>) in memory protected from freeing
> by <function>SPI_finish</function> and by the transaction manager
> 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. Always check if this pointer is
> <symbol>NULL</symbol> or not either when preparing a plan or using
> an already prepared plan in <function>SPI_execute_plan</function>.
> </para>
>
> My inclination is to just delete the last two sentences, on the grounds
> that they are essentially content-free. Perhaps the original author's
> intent would be met by s/local variable/static variable/, but this is
> reference material not beginner hints.
Yes, that's the passage I was referring to. I agree that it would be
clearer with your suggested edit.
Jack Orenstein
From | Date | Subject | |
---|---|---|---|
Next Message | Jack Orenstein | 2006-09-10 04:12:37 | Re: Idle in transaction state. |
Previous Message | Tom Lane | 2006-09-10 02:44:06 | Re: How to use SPI_saveplan |