Must a C state transition function use palloc on the returned value? 
Author Message
 Must a C state transition function use palloc on the returned value?

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



Tue, 29 Apr 2003 19:40:25 GMT
 Must a C state transition function use palloc on the returned value?

Quote:

> 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



Tue, 29 Apr 2003 23:12:35 GMT
 Must a C state transition function use palloc on the returned value?
Quote:
Tom Lane 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



Tue, 29 Apr 2003 23:21:42 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. Using value returned by scalar function

2. Calling Oracle function to return a value using ADO 2.5

3. Using ADO 2.5 to call Oracle function to return a value

4. State Transition Diagrams

5. Table.State returns incorrect state

6. Raiserror Statment how is state value used?

7. Aggregates with non-commutative transition functions

8. ResultSet as return value of function?

9. Function example returning more then 1 value

10. User defined functions doesn't return the correct value in Excel XP

11. Resultset as function return value


 
Powered by phpBB® Forum Software