Re: [HACKERS] Aggregates with context - a question

From: Philip Warner <pjw(at)rhyme(dot)com(dot)au>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Aggregates with context - a question
Date: 1999-06-10 02:50:21
Message-ID: 3.0.5.32.19990610125021.00a1cb10@mail.rhyme.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At 10:20 9/06/99 -0400, Tom Lane wrote:

>> This is clearly not the case, and I have declared them as int4, which
>> will also presumable break on 64 bit implementations...
>
>The "clean" way to do it is to make a declared datatype that corresponds
>to the state storage you need, but that's overkill if such a datatype
>hasn't got any other use. I think the way you have done it is a
>reasonable cheat, though I agree that using int4 is risky for
>portability. There has been some talk of inventing a type OID
>representing "C string", and that (when available) might be a better way
>of declaring transtype1 when it's really a private struct of some sort.

Sounds like a wonderful idea; does this mean that users can be prevented from declaring a column of type 'C String'? Or do you then need to build all the support functions? I suppose the alternative would be to use a 'varbinary' (or varchar?), which has the first word being the structure length. That would at least be standard.

>One thing you have to be very careful about is memory allocation and
>lifetime. The way you are doing it, a palloc in the first transfn1
>iteration and a pfree in finalfn, will be fine. However this may change
>in 6.6, since we are going to have to do something to cure memory leaks
>in aggregation. (Currently, if the transfns are ones that palloc their
>result value, as all float8 ops do for example, the storage is not
>reclaimed until end of transaction. That's no good if there are lots of
>tuples...)
>
>> Anyway, the code is below.
>
>Looks OK except you are potentially pfreeing an uninit pointer in the
>finalfn...
>

Oops - pretty clever, considering I had already checked if it was zero...

Thanks for the information,

Philip

----------------------------------------------------------------
Philip Warner | __---_____
Albatross Consulting Pty. Ltd. |----/ - \
(A.C.N. 008 659 498) | /(@) ______---_
Tel: +61-03-5367 7422 | _________ \
Fax: +61-03-5367 7430 | ___________ |
Http://www.rhyme.com.au | / \|
| --________--
PGP key available upon request, | /
and from pgp5.ai.mit.edu:11371 |/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Vadim Mikheev 1999-06-10 03:14:33 select order by for update
Previous Message Philip Warner 1999-06-10 02:38:48 Re: [HACKERS] out of memory with large queries