Tagged types module and varlena changes

From: Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl>
To: postgres list <pgsql-general(at)postgresql(dot)org>
Subject: Tagged types module and varlena changes
Date: 2009-08-26 12:14:45
Message-ID: D17BE14A-6EF9-4FCA-A4F5-69831A01B581@solfertje.student.utwente.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello all,

I'm trying to get Marcel's tagged types to work, but I ran into some
problems due to changes to the varlena type since he wrote that code.
I tried contacting him personally earlier, but he's having some
hardware issues apparently and can't help me; hence me asking here ;)

The problem is that the tagged types module uses this bit of code:

> struct varlena* tv = (struct varlena*)tt_palloc( VARSIZE( datum ) );
>
> tv->vl_len = VARSIZE( datum ) - sizeof(Oid);
> memcpy( tv->vl_dat,
> &((struct taggedtypev*)DatumGetPointer( datum ))->val,
> VARSIZE(datum) - sizeof(Oid) - VARHDRSZ );
> return PointerGetDatum( tv ) ;

This doesn't compile anymore as the vl_len member of struct varlena no
longer exists and we're supposed to use the SET_VARSIZE macro instead
now. I tried that, but then the memcpy bails out due to the size
calculation being wrong. I don't know enough about varlena usage to
figure out what the correct way of calculating the size for memcpy is,
or whether that approach is at all feasable with the current varlena
implementation. What should the above read?

I'm also slightly worried whether DatumGetPointer might return a null-
pointer in some cases. Is that possible?

Alban Hertroys

--
If you can't see the forest for the trees,
cut the trees and you'll see there is no forest.

!DSPAM:737,4a95273611861044619247!

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2009-08-26 12:28:15 Re: best practise/pattern for large OR / LIKE searches
Previous Message tv 2009-08-26 11:54:53 Re: best practise/pattern for large OR / LIKE searches