Re: Inheritance problem when restoring db - Mailing list pgsql-general

From Tom Lane
Subject Re: Inheritance problem when restoring db
Date
Msg-id 29166.1193586417@sss.pgh.pa.us
Whole thread Raw
In response to Re: Inheritance problem when restoring db  ("Sebastjan Trepca" <trepca@gmail.com>)
Responses Re: Inheritance problem when restoring db  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
"Sebastjan Trepca" <trepca@gmail.com> writes:
> This is how to reproduce this issue:
> ...
> inh_test=# alter table capitals inherit cities;

Fascinating.  pg_dump is almost smart enough to get this right, except
that what it spits out is

ALTER TABLE capitals ALTER COLUMN id SET DEFAULT nextval('capitals_id_seq'::regclass);
...
ALTER TABLE cities ALTER COLUMN id SET DEFAULT nextval('cities_id_seq'::regclass);

and since it already declared capitals as inheriting from cities, the
second command descends the inheritance tree and replaces the local
default for capitals.

What we apparently must do is add a dependency relation within pg_dump
to cause these two commands to be emitted in the other order.  I briefly
considered making these sorts of ALTERs be ALTER TABLE ONLY, but if we
go that route we will be unable to correctly restore the inherited vs
not-inherited property of default expressions.  (Not that the system
tracks that currently, but I think there were proposals on the table
to do so.)

            regards, tom lane

pgsql-general by date:

Previous
From: Perry Smith
Date:
Subject: Re: I want to search my project source code
Next
From: aklaver@comcast.net (Adrian Klaver)
Date:
Subject: Re: select count() out of memory