Re: accessing anyarray elements - Mailing list pgsql-general

From Tom Lane
Subject Re: accessing anyarray elements
Date
Msg-id 10198.1244902631@sss.pgh.pa.us
Whole thread Raw
In response to accessing anyarray elements  (Michael Glaesemann <grzm@seespotcode.net>)
List pgsql-general
Michael Glaesemann <grzm@seespotcode.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

pgsql-general by date:

Previous
From: Alban Hertroys
Date:
Subject: Re: How to store text files in the postgresql?
Next
From: Toomas Vendelin
Date:
Subject: Escaping regular expressions in plperl