Re: pointer scope and memory contexts

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Tim Keitt" <tkeitt(at)keittlab(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pointer scope and memory contexts
Date: 2008-11-06 13:28:08
Message-ID: 15359.1225978088@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Tim Keitt" <tkeitt(at)keittlab(dot)org> writes:
> [questions]

Switching memory contexts, in itself, only switches which context a bare
palloc() will allocate from (as opposed to MemoryContextAlloc). It
cannot have some magic impact on the validity of existing pointers.

> One last question: if I call SPI_finish, on the first call, do I need
> to switch contexts in the per-call section? (I saw some example code
> that suggested one needs to switch contexts back to
> multi_call_memory_ctx after SPI_finish.)

I believe SPI_finish will switch back to the context that was current
when SPI_connect was called.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2008-11-06 13:37:47 Re: plperl needs upgrade for Fedora 10
Previous Message Jaime Casanova 2008-11-06 13:16:12 Re: regression in analyze