Re: [BUGS] BUG #14521: pg_attribute.attndims = 0 for array column - Mailing list pgsql-bugs

From Tom Lane
Subject Re: [BUGS] BUG #14521: pg_attribute.attndims = 0 for array column
Date
Msg-id 7447.1485961998@sss.pgh.pa.us
Whole thread Raw
In response to [BUGS] BUG #14521: pg_attribute.attndims = 0 for array column  (krzysztof.heim@gmail.com)
List pgsql-bugs
Krzysztof Heim <krzysztof.heim@gmail.com> writes:
> If I may ask, what is then the best way of checking if column is array.

The standard way for C code is to use this macro from lsyscache.h:

#define type_is_array(typid)  (get_element_type(typid) != InvalidOid)

or depending on what you're doing, you might want these semantics:

/* type_is_array_domain accepts both plain arrays and domains over arrays */
#define type_is_array_domain(typid)  (get_base_element_type(typid) != InvalidOid)

or then again, you might just want to check if the type has nonzero
typelem --- that would be the appropriate thing if you want to see
whether the type is subscriptable.

            regards, tom lane


--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: [BUGS] BUG #14521: pg_attribute.attndims = 0 for array column
Next
From: Fujii Masao
Date:
Subject: Re: [BUGS] Bug in Physical Replication Slots (at least 9.5)?