Re: c extension - Mailing list pgsql-novice

From Joe Conway
Subject Re: c extension
Date
Msg-id 41890A80.6020304@joeconway.com
Whole thread Raw
In response to Re: c extension  (Kjetil Haaland <kjetil.haaland@student.uib.no>)
Responses Re: c extension
Re: c extension
List 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

pgsql-novice by date:

Previous
From: Kjetil Haaland
Date:
Subject: Re: c extension
Next
From: Tom Lane
Date:
Subject: Re: c extension