Re: [HACKERS] Aggregates with context - a question

Поиск
Список
Период
Сортировка
От Philip Warner
Тема Re: [HACKERS] Aggregates with context - a question
Дата
Msg-id 3.0.5.32.19990610125021.00a1cb10@mail.rhyme.com.au
обсуждение исходный текст
Ответ на Re: [HACKERS] Aggregates with context - a question  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [HACKERS] Aggregates with context - a question
Список 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
doyou 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   |/


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Philip Warner
Дата:
Сообщение: Re: [HACKERS] out of memory with large queries
Следующее
От: Vadim Mikheev
Дата:
Сообщение: select order by for update