Обсуждение: Arrays of records?

Поиск
Список
Период
Сортировка

Arrays of records?

От
Chris Travers
Дата:
Hi all;

I was wondering how one would define an array of complex data types or
records.  Any ideas or is this simply not supported?

Best Wishes,
Chris Travers

Re: Arrays of records?

От
"Pavel Stehule"
Дата:
Hello

you can test it. PostgreSQL 8.3 supports it.

postgres=# CREATE TYPE at AS (a integer, b integer);
CREATE TYPE
postgres=# CREATE TABLE foo(a at[]);
CREATE TABLE
postgres=# INSERT INTO foo VALUES(ARRAY[(10,20)::at]);
INSERT 0 1
postgres=# INSERT INTO foo VALUES(ARRAY[(10,20)::at, (20,30)::at]);
INSERT 0 1
postgres=# SELECT * FROM foo;
           a
-----------------------
 {"(10,20)"}
 {"(10,20)","(20,30)"}
(2 rows)

postgres=# SELECT a[1] FROM foo;
    a
---------
 (10,20)
 (10,20)
(2 rows)

postgres=# SELECT a[1].a FROM foo;
 a
----
 10
 10
(2 rows)

regards

Pavel Stehule




2007/7/7, Chris Travers <chris@travelamericas.com>:
> Hi all;
>
> I was wondering how one would define an array of complex data types or
> records.  Any ideas or is this simply not supported?
>
> Best Wishes,
> Chris Travers
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
>        choose an index scan if your joining column's datatypes do not
>        match
>