David Fetter and I were just looking at something on IRC...
decibel=3D# select most_common_vals[1] from pg_stats where tablename=3D'pg_=
depend' and attname=3D'classid';
ERROR: cannot subscript type anyarray because it is not an array
decibel=3D# select most_common_freqs[1] from pg_stats where tablename=3D'pg=
_depend' and attname=3D'classid';
most_common_freqs=20
-------------------
0.566
(1 row)
ISTM you'd want to be able to reference an individual element of an
ANYARRAY... but this gets even more odd...
decibel=3D# CREATE OR REPLACE FUNCTION array_to_set(anyarray) RETURNS SETOF=
anyelement LANGUAGE SQL AS $$
SELECT $1[i] from generate_series(array_lower($1, 1), array_upper($1, 1=
)) i
$$;
CREATE FUNCTION
decibel=3D# select array_to_set(most_common_vals) from pg_stats where table=
name=3D'pg_depend' and attname=3D'classid';
ERROR: argument declared "anyarray" is not an array but type anyarray
I expected that not to work, but the error is somewhat interesting...
I didn't expect the following to work:
decibel=3D# select array_to_set(most_common_freqs) from pg_stats where tabl=
ename=3D'pg_depend' and attname=3D'classid';
array_to_set=20
--------------
0.566
0.235667
0.126333
0.0343333
0.02
0.0163333
0.000666667
0.000666667
(8 rows)
decibel=3D#=20
ISTM you should be able to call an anyarray function with an anyarray,
and that you should be able to reference individual elements of an
anyarray...
--=20
Decibel!, aka Jim Nasby decibel@decibel.org
EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)