Re: could not find array type for data type character varying[] - Mailing list pgsql-general

From Sam Mason
Subject Re: could not find array type for data type character varying[]
Date
Msg-id 20091028153648.GR5407@samason.me.uk
Whole thread Raw
In response to could not find array type for data type character varying[]  (Viktor Rosenfeld <listuser36@googlemail.com>)
Responses could not identify an equality operator for type annotation (Was: could not find array type for data type character varying[])
List pgsql-general
On Wed, Oct 28, 2009 at 04:17:32PM +0100, Viktor Rosenfeld wrote:
> I'm trying to aggregate a list of table attributes into an array.

I'd suggest using a tuple, arrays for things where each element means
the same thing.  I'd guess you care about the substructure (i.e. the
element has a "namespace", a "name" and a "value") and hence using an
array in the first place seems wrong.  Maybe something like:

  CREATE TYPE foo AS ( namespace TEXT, name TEXT, value TEXT );
  SELECT id, array_accum(row(a,b,c)::foo)
  FROM data
  GROUP BY id;

> Why doesn't this work?

Arrays of arrays aren't directly supported; you currently have to put
them into a tuple first.  Something like:

  CREATE TYPE bar AS ( a TEXT[] );
  SELECT array_agg(row(array['a'])::bar);

--
  Sam  http://samason.me.uk/

pgsql-general by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: auto truncate/vacuum full
Next
From: Merlin Moncure
Date:
Subject: Re: could not find array type for data type character varying[]