Re: user defined types and strings - Mailing list pgsql-novice

From Michael Fuhr
Subject Re: user defined types and strings
Date
Msg-id 20050223172307.GA27659@winnie.fuhr.org
Whole thread Raw
In response to user defined types and strings  (Kjetil Haaland <kjetil.haaland@student.uib.no>)
Responses Re: user defined types and strings  (Kjetil Haaland <kjetil.haaland@student.uib.no>)
List pgsql-novice
On Wed, Feb 23, 2005 at 02:01:36PM +0100, Kjetil Haaland wrote:

> I have made a user defined type which has a string of variable length and and
> an integer value. Since the string is of variable length i have used a
> pointer for the string. When i use this type as a column in a table and
> inserts values into it, the string will go away. I understand that this is
> because i am pointing to a place in memory for the string, and that this wont
> last for a very long time. So i am wondering how i am supposed to use strings
> in a user defined type so they will be saved in the database when the type is
> inserted in a table?

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?

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

pgsql-novice by date:

Previous
From: Frank Bax
Date:
Subject: Re: Can Clipper connect Postgresql
Next
From: Kjetil Haaland
Date:
Subject: Re: user defined types and strings