Re: Must a C state transition function use palloc on the returned value? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Must a C state transition function use palloc on the returned value?
Date
Msg-id 11251.973868587@sss.pgh.pa.us
Whole thread Raw
In response to Must a C state transition function use palloc on the returned value?  (Dirk Lutzebaeck <lutzeb@aeccom.com>)
Responses Re: Must a C state transition function use palloc on the returned value?  (Dirk Lutzebaeck <lutzeb@aeccom.com>)
List pgsql-hackers
Dirk Lutzebaeck <lutzeb@aeccom.com> writes:
> I'm defining a new aggregate using a C transition function. It is of
> type TEXT, so the C function gets pointers (*text) to the internal-state1 and
> next-data-item parameters. 

> Question is if the returning value of type *text must be palloc'ed or
> can be just taken from the input parameters.

The result must be a fresh palloc, since both inputs will be pfreed the
moment you return.  7.1 will copy the result for you if you are so
incautious as to try to return an input, but 7.0.* just falls over :-(
        regards, tom lane


pgsql-hackers by date:

Previous
From: Christof Petig
Date:
Subject: Re: AW: Re: [INTERFACES] USE OF CURSORS IN ECPG
Next
From: Dirk Lutzebaeck
Date:
Subject: Re: Must a C state transition function use palloc on the returned value?