Re: c extension

From: Joe Conway <mail(at)joeconway(dot)com>
To: Kjetil Haaland <kjetil(dot)haaland(at)student(dot)uib(dot)no>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: c extension
Date: 2004-11-03 16:42:40
Message-ID: 41890A80.6020304@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Kjetil Haaland wrote:
> Many thanks for good answer. I have also allocated memory for a table of
> integers in the same file, and this table seems to work fine, i can print out
> values from it without any problems.
>
> Is there any good reason it should work with integers and not with characters?

Not sure -- sheer luck ;-)

> In what memory context should it be created to last until the user logs out?

Probably TopMemoryContext

"TopMemoryContext --- this is the actual top level of the context tree;
every other context is a direct or indirect child of this one.
Allocating here is essentially the same as "malloc", because this
context will never be reset or deleted."

I.e. anything allocated in TopMemoryContext will live until the session
ends.

See:
http://www.joeconway.com/tut_oscon_2004.pdf
particularly starting at or about page 64. Much of the detailed
explanation is not in the slides, but it should give you some examples
and ideas. There are examples throughout the presentation, and several
of them have examples of memory context use.

Joe

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2004-11-03 19:53:17 Re: c extension
Previous Message Kjetil Haaland 2004-11-03 16:19:45 Re: c extension