Re: user defined types and strings

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: user defined types and strings
Дата
Msg-id 20050223172307.GA27659@winnie.fuhr.org
обсуждение исходный текст
Ответ на user defined types and strings  (Kjetil Haaland <kjetil.haaland@student.uib.no>)
Ответы Re: user defined types and strings  (Kjetil Haaland <kjetil.haaland@student.uib.no>)
Список 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 по дате отправления:

Предыдущее
От: Frank Bax
Дата:
Сообщение: Re: Can Clipper connect Postgresql
Следующее
От: Kjetil Haaland
Дата:
Сообщение: Re: user defined types and strings