Re: sig 11 in RC3 - Mailing list pgsql-hackers

From Tom Lane
Subject Re: sig 11 in RC3
Date
Msg-id 5238.1010160124@sss.pgh.pa.us
Whole thread Raw
In response to sig 11 in RC3  (mlw <markw@mohawksoft.com>)
Responses Re: sig 11 in RC3  (Holger Krug <hkrug@rationalizer.com>)
List pgsql-hackers
mlw <markw@mohawksoft.com> writes:
> I have a couple functions which form the basis of an aggregate.

You can't lie to the system by claiming your state value is an integer
when it's really a pointer to palloc'd memory.  The memory will get
recycled out from under you.

Try declaring the aggregate as using int4[] as the transition type,
and make sure that the intermediate states are valid at least to the
point of having a correct varlena length word.  This will allow the
system to copy the values around when it needs to.

Alternatively, keep the data structure in a longer-lived context
(TransactionCommandContext should work) instead of the per-tuple
context.  That's uglier but would avoid a lot of copying.

See src/backend/executor/nodeAgg.c if you are wondering why the state
values need to be copied around.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Thomas Lockhart
Date:
Subject: Re: datetime error?
Next
From: Holger Krug
Date:
Subject: ON ERROR triggers