mlw <markw(at)mohawksoft(dot)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
In response to
Responses
pgsql-hackers by date
| Next: | From: Holger Krug | Date: 2002-01-04 16:36:57 |
| Subject: ON ERROR triggers |
| Previous: | From: Thomas Lockhart | Date: 2002-01-04 15:52:45 |
| Subject: Re: datetime error? |