From: | Seref Arikan <serefarikan(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: How to manage shared library lifetime through C functions |
Date: | 2014-08-04 13:08:14 |
Message-ID: | CA+4ThdoWMaRYWg+DDvcdGmcOUB5OgT7EtSAoKM3Pr7uOhoQy6w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
On Mon, Aug 4, 2014 at 11:58 AM, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com
> wrote:
> On 08/04/2014 01:31 PM, Seref Arikan wrote:
>
>> Thanks a lot Heikki and Albe. Exactly what I was asking for.
>> Heikki: the libraries are written in languages that have their own runtime
>> and their documentation insists that both init and dispose calls are
>> performed when used from C. PG_init() and proc_exit sounds spot on.
>>
>
> You might also consider creating your own PL handler for those languages.
> Or google around if one exists already.
That was what I checked first, but unfortunately none exists at the moment.
I really want to write one,which would probably be a much cleaner way of
doing what I'm going to do, but time pressure does not let me.
At the moment the lowest hanging fruit is to pass values through C
functions to these libraries and get the results back; hence, my questions.
>
>
> Any ideas about keeping some data at session level between calls? Both
>> calls of the same function and different C functions. (though temp table
>> is
>> always there as an option)
>>
>
> You can use a global variable in the C extension. If you need to allocate
> memory that survives across function calls, use "MemoryContextSwitchTo(TopMemoryContext);
> ... = palloc(...)". I'm sure you'll find examples of that in the existing
> extensions too.
>
Thanks, I'll check this out as well.
> - Heikki
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Albe Laurenz | 2014-08-04 13:48:31 | Re: How to manage shared library lifetime through C functions |
Previous Message | Craig Ringer | 2014-08-04 11:52:15 | Re: How to manage shared library lifetime through C functions |