Re: user defined type

Поиск
Список
Период
Сортировка
От Kjetil Haaland
Тема Re: user defined type
Дата
Msg-id 200411091338.29654.kjetil.haaland@student.uib.no
обсуждение исходный текст
Ответ на Re: user defined type  (Michael Fuhr <mike@fuhr.org>)
Ответы Re: user defined type  (Michael Fuhr <mike@fuhr.org>)
Список pgsql-novice
On Monday 08 November 2004 22:24, Michael Fuhr wrote:
> On Mon, Nov 08, 2004 at 01:26:55PM +0100, Kjetil Haaland wrote:
> > typedef struct alignres {
> >   int value;
> >   char *fstring;
> > }alignres;
>
> If you want to store character data, I think the characters must
> be stored in the structure itself; I don't think using a pointer
> will work (somebody please correct me if I'm mistaken).  So instead
> of "char *fstring" you'll need "char fstring[x]", where "x" is the
> maximum size of the character data.  You could also use "char fstring[1]"
> and allocate the alignres structure to be as big as necessary; if
> you do that then you might want to review the paragraph regarding
> TOAST-able types near the end of the "User-Defined Types" section
> of the documentation.
>
> http://www.postgresql.org/docs/7.4/static/xtypes.html
>
> Make sure your CREATE TYPE statement has "internallength" set
> correctly: either to the fixed size of the structure (including
> character data) or to "variable".  If you use "variable" then make
> sure you add the required length field to the beginning of the
> structure.  See the CREATE TYPE documentation for more info.

Thanks for the answer. There are some stuff i don't understand. I want to use
the fstring[1] way, because i don't know how large my string will be. You say
that i can allocate the hole structure, where should i do this? in the
in-data-function? It also says in the documentation that if I use the random
for internallength when i create my type I have to set the length in the
structure. Is this set in the declaration of the structure or in some of the
methods?

-Kjetil

В списке pgsql-novice по дате отправления:

Предыдущее
От: graeme
Дата:
Сообщение: Getting a trigger to call a function...
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: Getting a trigger to call a function...