Skip site navigation (1) Skip section navigation (2)

Re: sig 11 in RC3

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: mlw <markw(at)mohawksoft(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: sig 11 in RC3
Date: 2002-01-04 16:02:04
Message-ID: 5238.1010160124@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
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 KrugDate: 2002-01-04 16:36:57
Subject: ON ERROR triggers
Previous:From: Thomas LockhartDate: 2002-01-04 15:52:45
Subject: Re: datetime error?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group