Re: Must a C state transition function use palloc on the returned value?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dirk Lutzebaeck <lutzeb(at)aeccom(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Must a C state transition function use palloc on the returned value?
Date: 2000-11-10 15:03:07
Message-ID: 11251.973868587@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dirk Lutzebaeck <lutzeb(at)aeccom(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dirk Lutzebaeck 2000-11-10 15:13:13 Re: Must a C state transition function use palloc on the returned value?
Previous Message Christof Petig 2000-11-10 12:49:33 Re: AW: Re: [INTERFACES] USE OF CURSORS IN ECPG