Re: ffunc called multiple for same value

From: Ian Burrell <imb(at)rentrak(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: ffunc called multiple for same value
Date: 2004-07-23 20:48:39
Message-ID: 410179A7.90102@rentrak.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
>
> So I'm rather inclined to define this behavior as "not a bug". The fact
> that you're complaining seems to indicate that your ffunc scribbles on
> its input, which is bad programming practice in any case. Ordinarily
> I would not think that an ffunc should have any problem with being
> executed repeatedly on the same final transvalue. (If you really want
> to do things that way, maybe your code should take responsibility for
> keeping a flag to execute just once, rather than pushing the cost onto
> everybody.)
>

We are doing things in the aggregates that make them troublesome when
called the ffunc is called multiple times. The state structure uses a
lot of memory for intermediate work. The memory needs to be freed as
soon as possible otherwise there is a danger of running of out memory.
It is possible to store the resuts on the first ffunc call, free the
intermediate state, return the results on later calls, and make sure the
free only happens once.

The docs didn't make clear that calling ffunc multiple times could
happens so we did not code to allow it.

- Ian

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2004-07-23 20:58:55 Re: [HACKERS] Tutorial
Previous Message Thomas F.O'Connell 2004-07-23 20:47:32 psql listTables