Обсуждение: Bug #719: Restoring inherited data destroys parent table data.

Поиск
Список
Период
Сортировка

Bug #719: Restoring inherited data destroys parent table data.

От
pgsql-bugs@postgresql.org
Дата:
Rob Olsthoorn (rolsthoorn@irdetoaccess.com) reports a bug with a severity of 1
The lower the number the more severe it is.

Short Description
Restoring inherited data destroys parent table data.

Long Description
Happens at least in version 7.2

When restoring a database dump in a clean database, the data of all parents of inherited tables also get the data of
thechild tables included in the select.
 

The only workaround I found for this problem is to create the child tables as duplicates of the parent tables and
restoreonly the data.
 

See a full the code example below.

Sample Code
> createdb db
> psql db
db=# create table a (a int);
db=# create table b () inherits (a);
db=# insert into a values (1);
db=# insert into a values (2);
db=# insert into b values (1);
db=# insert into b values (12);
db=# select * from a;
 a
---
 1
 2
(2 rows)
db=# \q
> pg_dump -D -t a -t b db > db.dump
> dropdb db
> createdb db
> psql -f db.dump db
> psql db
db=# select * from a;
 a
---
 1
 2
 2
 1
(4 rows)
db=#

No file was uploaded with this report

Re: Bug #719: Restoring inherited data destroys parent table data.

От
Tom Lane
Дата:
pgsql-bugs@postgresql.org writes:
> Restoring inherited data destroys parent table data.

No it doesn't.   You appear to be expecting the pre-7.1 behavior of
SELECT on a parent table.  Recent versions default to doing the
equivalent of "SELECT FROM parent*".

See the SQL_INHERITANCE configuration parameter if you prefer the
old way.

            regards, tom lane