Re: accessing anyarray elements

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Glaesemann <grzm(at)seespotcode(dot)net>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: accessing anyarray elements
Date: 2009-06-13 14:17:11
Message-ID: 10198.1244902631@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Michael Glaesemann <grzm(at)seespotcode(dot)net> writes:
> I'd like to be able to access individual elements of anyarray,
> treating them as type anyelement to take advantage of the
> polymorphism. Using pg_stats.histogram_bounds as a convenient example
> of an anyelement array, here's an example of the issue I'm running into.

The problem with histogram_bounds is that there isn't any way to
infer an element type for it in the abstract, and thus also no way to
know what type anyelement is. When looking at an individual row you can
know that it must have the type of the associated column and explain
that to the parser via an explicit cast, but there's pretty much no hope
of having that happen automagically.

There are a few other problems, like array columns --- the contents of
pg_statistic for them is actually an array of arrays, which simply
has not got a representation in our type system.

So you're pretty much out of luck. I think the only meaningful thing
you can do with it in SQL is cast to text.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Toomas Vendelin 2009-06-14 09:20:29 Escaping regular expressions in plperl
Previous Message Alban Hertroys 2009-06-13 11:09:19 Re: How to store text files in the postgresql?