BUG #13489: pg_attribute.attndims turns to 0 when 'create table like/as'

Started by Shujie Shangalmost 11 years ago1 messagesbugs
Jump to latest
#1Shujie Shang
sshang@pivotal.io

The following bug has been logged on the website:

Bug reference: 13489
Logged by: sshang
Email address: sshang@pivotal.io
PostgreSQL version: 9.4.1
Operating system: centos 6
Description:

When I create a table with array column, the pg_attribute.attndims will set
to a non-zero value. Then I create another table using 'create like' or
'create as', the pg_attribute.attndims of the new table will turn to 0.

postgres=# \d test1;
Table "public.test1"
Column | Type | Modifiers
--------+-----------+-----------
id | integer |
datas | integer[] |
d2 | integer[] |
d3 | integer[] |

postgres=# create table test2 (like test1);
CREATE TABLE
postgres=# \d test2;
Table "public.test2"
Column | Type | Modifiers
--------+-----------+-----------
id | integer |
datas | integer[] |
d2 | integer[] |
d3 | integer[] |
postgres=# select att.attname, att.attndims from pg_attribute att, pg_class
c where c.relname='test1' and att.attrelid = c.oid;
attname | attndims
----------+----------
tableoid | 0
cmax | 0
xmax | 0
cmin | 0
xmin | 0
ctid | 0
id | 0
datas | 1
d2 | 2
d3 | 3
postgres=# select att.attname, att.attndims from pg_attribute att, pg_class
c where c.relname='test2' and att.attrelid = c.oid;
attname | attndims
----------+----------
tableoid | 0
cmax | 0
xmax | 0
cmin | 0
xmin | 0
ctid | 0
id | 0
datas | 0
d2 | 0
d3 | 0
(10 rows)
postgres=# create table test3 as select * from test1;
SELECT 1
postgres=# \d test3;
Table "public.test3"
Column | Type | Modifiers
--------+-----------+-----------
id | integer |
datas | integer[] |
d2 | integer[] |
d3 | integer[] |

postgres=# select att.attname, att.attndims from pg_attribute att, pg_class
c where c.relname='test3' and att.attrelid = c.oid;
attname | attndims
----------+----------
tableoid | 0
cmax | 0
xmax | 0
cmin | 0
xmin | 0
ctid | 0
id | 0
datas | 0
d2 | 0
d3 | 0
(10 rows)

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