Re: Arrays of records? - Mailing list pgsql-general

From Pavel Stehule
Subject Re: Arrays of records?
Date
Msg-id 162867790707071339p597e6165qf039a5fb9aeb65a2@mail.gmail.com
Whole thread Raw
In response to Arrays of records?  (Chris Travers <chris@travelamericas.com>)
List pgsql-general
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
>

pgsql-general by date:

Previous
From: Zlatko Matić
Date:
Subject: Re: How to retrieve number of rows affected, in an after statement trigger?
Next
From: Tom Lane
Date:
Subject: Re: Crash in PostgreSQL-8.2.4 while executing query