Re: C Function Memory Management

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Martin French <Martin(dot)French(at)romaxtech(dot)com>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org, pgsql-general-owner(at)postgresql(dot)org
Subject: Re: C Function Memory Management
Date: 2012-12-12 16:44:14
Message-ID: 10079.1355330654@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Martin French <Martin(dot)French(at)romaxtech(dot)com> writes:
> So out of curiosity, what would be your approach for data preservation
> cross call?

Usually I'd allocate the space in fcinfo->flinfo->fn_mcxt (which is a
query-lifespan context) and keep a pointer to it in
fcinfo->flinfo->fn_extra (which is a void * field that a C function
can do what it pleases with). There are plenty of examples in the
Postgres source code. If you are looking to cache data longer than
one query then it takes more thought.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Lutz Fischer 2012-12-12 16:51:14 problem with large inserts
Previous Message Adrian Klaver 2012-12-12 16:35:41 Re: Columns defined not matching pg_attibute