Re: user defined types and strings

From: Kjetil Haaland <kjetil(dot)haaland(at)student(dot)uib(dot)no>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: user defined types and strings
Date: 2005-02-23 19:14:06
Message-ID: 200502232014.06872.kjetil.haaland@student.uib.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Wednesday 23 February 2005 18:23, Michael Fuhr wrote:
> Hmmm...haven't we already had this conversation? :-)
>
> http://archives.postgresql.org/pgsql-novice/2004-11/msg00096.php
> http://archives.postgresql.org/pgsql-novice/2004-11/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/static/storage-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

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message operationsengineer1 2005-02-23 21:17:35 shutdown postmaster question
Previous Message Michael Fuhr 2005-02-23 17:23:07 Re: user defined types and strings