Re: user defined types and strings

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Kjetil Haaland <kjetil(dot)haaland(at)student(dot)uib(dot)no>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: user defined types and strings
Date: 2005-02-23 17:23:07
Message-ID: 20050223172307.GA27659@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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/

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Kjetil Haaland 2005-02-23 19:14:06 Re: user defined types and strings
Previous Message Frank Bax 2005-02-23 14:08:23 Re: Can Clipper connect Postgresql