View Single Post

   
  #3 (permalink)  
Old 04-17-2008, 09:32 PM
Kjetil Haaland
 
Posts: n/a
Default Re: user defined types and strings

On Wednesday 23 February 2005 18:23, Michael Fuhr wrote:
> Hmmm...haven't we already had this conversation? :-)
>
> http://archives.postgresql.org/pgsql...1/msg00096.php
> http://archives.postgresql.org/pgsql...1/msg00106.php
>
> The type's data needs to be a contiguous block of memory, preceded
> by four bytes (int32) indicating the total length (including the
> four bytes). You should also be aware of how TOAST works and the
> need to use PG_DETOAST_DATUM in certain places.
>
> http://www.postgresql.org/docs/8.0/static/xtypes.html
> http://www.postgresql.org/docs/8.0/s...age-toast.html
>
> Or have I misunderstood what you're asking?


We have had almost the same conversation before. The type works in my
functions, but since the string is just a pointer to a memory place it goes
away when the type is stored in tables in the database. I have read about the
TOAST stuff, and think i have to use this because i have a pointer, and that
the actual values have to be found elsewhere. Is this correct? But i don't
understand how this is used. I have tried to add the line

pg_detoast_datum((struct varlena*) DatumGetPointer(result));

in my input function after i have allocated the memory for the structure and
the string. I also set the length variable before i do this. But it still
want save what's in the string. I have also tried to add it in the output
function right after i have recieved the argument. But this doesn't help. Is
there any examples i can look at to see how TOAST is used?

thanks for all the help so far!
-Kjetil

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

Reply With Quote