
Hi,

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. In the latter case I get
error messages like 

NOTICE:  PortalHeapMemoryFree: 0x0x40b22ce8 not in alloc set!

Dirk

Fri, 10 Nov 2000 12:19:21 +0100 (CET)
Dirk Lutzebaeck <lutzeb@aeccom.com>
Must a C state transition function use palloc on the returned value?
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

Fri, 10 Nov 2000 10:03:07 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: Must a C state transition function use palloc on the returned
	value?
Tom Lane writes:
 > 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 :-(

Thanks! It works now...

Dirk


Fri, 10 Nov 2000 16:13:13 +0100 (CET)
Dirk Lutzebaeck <lutzeb@aeccom.com>
Re: Must a C state transition function use palloc on the returned
	value?