From: buschmann@nidsa.net
To: pgsql-bugs@postgresql.org
Subject: BUG #14684: pg_dump omits columns in inherited tables / psql -d shows deleted columns
Date: Fri, 02 Jun 2017 12:19:47 +0000
Message-ID: <20170602121947.1436.81319@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
The following bug has been logged on the website:
Bug reference: 14684
Logged by: Hans Buschmann
Email address: buschmann@nidsa.net
PostgreSQL version: 9.6.3
Operating system: Windows x64
Description:
I use a partitioned table design with an active table (getting the current
data) and an archiv table.
During application development I added some columns to the existing active
table by
alter table or_followup
add column of_id_off smallint
,add column of_id_for_group smallint
;
I also dropped a column by
alter table or_followup
drop column of_style_cus
;
When I take a schema_only dump with pg_dump, the table creation looks like
(excerpt from dmp file)
CREATE TABLE or_followup (
...
of_p_deliver_etd date,
of_p_deliver_eta date,
of_id_off smallint,
of_id_for_group smallint,
CONSTRAINT ck_of_new CHECK ((of_season >= 24)) NO INHERIT
);
CREATE TABLE or_followup_archiv (
...
of_p_deliver_etd date,
of_p_deliver_eta date,
of_style_cus character varying(35),
CONSTRAINT ck_of_old CHECK ((of_season < 24)) NO INHERIT
)
INHERITS (public.or_followup);
AS we might see, the inserted and the deleted columns (all after the date
columns) are not created in the (inheriting) archiv table!
Additionely I compared psql \d output: (excerpt from screen)
xxxdb=# \d public.or_followup
Table "public.or_followup"
Column | Type |
Modifiers
------------------------+-----------------------+-------------------------------------------------------------
...
of_p_deliver_etd | date |
of_p_deliver_eta | date |
of_id_off | smallint |
of_id_for_group | smallint |
Indexes:
...
Check constraints:
"ck_of_new" CHECK (of_season >= 24) NO INHERIT
Triggers:
...
Number of child tables: 1 (Use \d+ to list them.)
xxxdb=# \d or_followup_archiv;
Table "archiv.or_followup_archiv"
Column | Type |
Modifiers
------------------------+-----------------------+-------------------------------------------------------------
...
of_p_deliver_etd | date |
of_p_deliver_eta | date |
of_id_off | smallint |
of_id_for_group | smallint |
of_style_cus | character varying(35) |
Indexes:
...
Check constraints:
"ck_of_old" CHECK (of_season < 24) NO INHERIT
Inherits: or_followup
In psql \d the added columns are displayed in the inherited archiv table,
but the dropped column is still there!
It seems that the catalogs are screwed up when adding /deleting columns
inderectly for inherited tables. This was tested under PG 9.6.3 and 10beta1
under Windows x64.
I didn't check if other row altering statements are reflected correctly,
like adding/change defaults, types etc.
Surprisingly the full backup and restore via pg_dump and pg_restore to a
fresh system does not produce errors and runs flawlessly (tested often in
backup procedure)
Could anybody reproduce this behavior?
Thanks
Hans Buschmann
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: buschmann@nidsa.net
Subject: Re: BUG #14684: pg_dump omits columns in inherited tables / psql -d shows deleted columns
In-Reply-To: <20170602121947.1436.81319@wrigleys.postgresql.org>
References: <20170602121947.1436.81319@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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