In addition to what @Joe already cleared up, you can use pg_typof()
to get type information from PostgreSQL.
Given a 2-dimensional array of integer in this example:
SELECT pg_typeof(a)::text AS type
,(SELECT typname FROM pg_type WHERE oid = pg_typeof(a)) AS base_type
,array_dims(a) AS dims
FROM (SELECT '{{11,12,13},{21,22,23}}'::int[]) x(a);
type | base_type | dims
-----------+-----------+------------
integer[] | _int4 | [1:2][1:3]
Note that the array dimensions (dims
) can be different for each value. Postgres does not enforce dimensions at present (up to and incl. v9.3).
As documented in the manual, pg_attribute.attndims
is of limited use here:
Number of dimensions, if the column is an array type; otherwise 0.
(Presently, the number of dimensions of an array is not enforced, so
any nonzero value effectively means "it's an array".)