pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #14521: pg_attribute.attndims = 0 for array column
3+ messages / 2 participants
[nested] [flat]
* BUG #14521: pg_attribute.attndims = 0 for array column
@ 2017-02-01 10:23 krzysztof.heim@gmail.com
0 siblings, 1 reply; 3+ messages in thread
From: krzysztof.heim@gmail.com @ 2017-02-01 10:23 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 14521
Logged by: Krzysztof Heim
Email address: krzysztof.heim@gmail.com
PostgreSQL version: 9.6.1
Operating system: Ubuntu 16.04
Description:
Hello,
I have base table A with column type integer array.
I also have table B derived from table A.
When I query pg_attribute for table A, attndims shows 1 (correct), when I do
same query for table B - attndims shows 0 for same column.
Is it a bug, or it's desired behavior (since it's a derived column).
I checked documentation, and it does not say anything about behavior in case
of derived - just says if attndims is > 0 you can assume it's array.
Thanks
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #14521: pg_attribute.attndims = 0 for array column
@ 2017-02-01 14:25 Tom Lane <tgl@sss.pgh.pa.us>
parent: krzysztof.heim@gmail.com
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2017-02-01 14:25 UTC (permalink / raw)
To: krzysztof.heim@gmail.com; +Cc: pgsql-bugs
krzysztof.heim@gmail.com writes:
> I have base table A with column type integer array.
> I also have table B derived from table A.
> When I query pg_attribute for table A, attndims shows 1 (correct), when I do
> same query for table B - attndims shows 0 for same column.
> Is it a bug, or it's desired behavior (since it's a derived column).
We don't really care. attndims is a historical leftover and should never
be relied on for any semantically significant purpose.
TBH, my inclination would be to remove the column altogether rather than
"fix" this.
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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #14521: pg_attribute.attndims = 0 for array column
@ 2017-02-01 15:13 Tom Lane <tgl@sss.pgh.pa.us>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 3+ messages in thread
From: Tom Lane @ 2017-02-01 15:13 UTC (permalink / raw)
To: Krzysztof Heim <krzysztof.heim@gmail.com>; +Cc: 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
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2017-02-01 15:13 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-02-01 10:23 BUG #14521: pg_attribute.attndims = 0 for array column krzysztof.heim@gmail.com
2017-02-01 14:25 ` Tom Lane <tgl@sss.pgh.pa.us>
2017-02-01 15:13 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox