Hi I've now completed my implementation of a collect_distinct aggregate, and it seems to work. My statetype is basically a pointer to a hashtable (allocated from the aggcontext). Since using internal as statetype is unsupported, I use int8, and just cast my pointer back and forth from int8. It appears to work on both my dev (32bit) and my production (64bit) machine, and it doesn't crash even when used heavily. Is there some drawback to my approach? If not - why doesn't postgres allow "internal" as statetype? greetings, Florian Pflug