Re: Arrays of records?

From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
To: "Chris Travers" <chris(at)travelamericas(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Arrays of records?
Date: 2007-07-07 20:39:44
Message-ID: 162867790707071339p597e6165qf039a5fb9aeb65a2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)travelamericas(dot)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
>

In response to

Browse pgsql-general by date

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