Re: c extension - Mailing list pgsql-novice

From Joe Conway
Subject Re: c extension
Date
Msg-id 4188F207.3030702@joeconway.com
Whole thread Raw
In response to c extension  (Kjetil Haaland <kjetil.haaland@student.uib.no>)
Responses Re: c extension  (Kjetil Haaland <kjetil.haaland@student.uib.no>)
List pgsql-novice
Kjetil Haaland wrote:
> I am writing a c extension function to my postgres database and in this i am
> trying to allocate memory space for a table of char. When i try to call a
> function that returns a value from this table postgres crashes. It works fine
> running it as c code. I have added part of the code and hope that someone can
> help me.

>     scoreChar = (char*)palloc(20*sizeof(char));

It doesn't look like that palloc is done in a sufficiently long-lived
memory context. Read up on them in src/backend/utils/mmgr/README.

Joe

pgsql-novice by date:

Previous
From: Joe Conway
Date:
Subject: Re: building a row with a plpgsql function
Next
From: Raphael Bauduin
Date:
Subject: Re: building a row with a plpgsql function