Re: C-language functions: SRF question

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jorge Arevalo <jorgearevalo(at)gis4free(dot)org>
Cc: Merlin Moncure <mmoncure(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: C-language functions: SRF question
Date: 2010-04-13 18:37:25
Message-ID: 7867.1271183845@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jorge Arevalo <jorgearevalo(at)gis4free(dot)org> writes:
> BTW, this code is for WKT Raster. A PostGIS extension. We can use the
> memory context I said (fcinfo->flinfo->fn_mcxt) to allocate memory
> when we need to call one of our functions from a standard "version 1"
> function, but is this the right context? I mean, the context we should
> use for a whole-plugin-lifetime persistence.

fn_mcxt will typically point at a query-lifespan context. If you need
to allocate storage that will live as long as the session, there's not
that much reason not to use malloc, except perhaps that you have to
remember to do your own out-of-memory-failure checks. The typical
coding pattern in the backend for session-lifespan storage is to use
TopMemoryContext, or possibly make your own context (as a child of
TopMemoryContext) so that you can easily identify how much storage
you're using for this purpose.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message A B 2010-04-13 19:12:59 Re: Need some help with a query (uniq -c)
Previous Message Greg Smith 2010-04-13 17:24:11 Re: Dynamic Catalog Views