Re: Self referencing composite datatype

Поиск
Список
Период
Сортировка
От Igor Neyman
Тема Re: Self referencing composite datatype
Дата
Msg-id A76B25F2823E954C9E45E32FA49D70EC1BBF3923@mail.corp.perceptron.com
обсуждение исходный текст
Ответ на Re: Self referencing composite datatype  (David Johnston <polobo@yahoo.com>)
Ответы Re: Self referencing composite datatype  (David Johnston <polobo@yahoo.com>)
Список pgsql-general
> -----Original Message-----
> From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-
> owner@postgresql.org] On Behalf Of David Johnston
> Sent: Wednesday, August 07, 2013 10:35 AM
> To: pgsql-general@postgresql.org
> Subject: Re: [GENERAL] Self referencing composite datatype
>
> Sameer Thakur wrote
> > Hello,
> > I wanted to create a composite datatype to represent a Node. So it
> > would have a few attributes and an array of type Node which is the
> > children of this node.
> > create type Node as (r integer, s integer, children Node []); But i
> > get error type Node[] does not exist. I understand that Node is not
> > defined hence the error.
> > But how do i get around this problem?
>
> In theory if you are using 9.1 or later you can first create the node type and
> then alter it to include a children attribute with the self-referencing type-
> array.
>
> begin;
>
> create type node as (r integer, s integer); alter type node add attribute
> children node[];
>
> end;
>
> I'm running 9.0 so cannot readily test this at the moment.
>
> David J.
>

Under 9.2.2 I'm getting an error:

ERROR:  composite type node cannot be made a member of itself

********** Error **********

ERROR: composite type node cannot be made a member of itself
SQL state: 42P16

Regards,
Igor Neyman


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

Предыдущее
От: Seref Arikan
Дата:
Сообщение: Pl/Python runtime overhead
Следующее
От: David Johnston
Дата:
Сообщение: Re: Populating array of composite datatype