Edge case problem with pg_dump

From: "D'Arcy J(dot)M(dot) Cain" <darcy(at)druid(dot)net>
To: pgsql-hackers(at)PostgreSQL(dot)org
Subject: Edge case problem with pg_dump
Date: 2002-05-22 13:51:24
Message-ID: 20020522095124.A25017@druid.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

There seems to be a pg_dump issue with inherited tables when columns
are added to the parent table after creating the child table. Here is
how to repeat the problem.

Create a test database and run the following SQL statements:

create table a (x int);
create table b (y int) inherits (a);
alter table a add column z int;
insert into b values (1, 2, 3);
select * from b;

You should see this:

test1=# select * from b;
x | y | z
---+---+---
1 | 2 | 3
(1 row)

Now create a second test database and dump the first into the second:

pg_dump test1 | psql test2

Now try that last select statement in the new database and you will see:

test2=# select * from b;
x | z | y
---+---+---
1 | 2 | 3
(1 row)

If you are lucky the restore fails because of conflicting types. Worse, as
in this example, the types are the same and it silently messes up your data
by reversing the names on two columns.

--
D'Arcy J.M. Cain <darcy(at){druid|vex}.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ewald Geschwinde 2002-05-22 13:53:07 index a datatype
Previous Message Tom Lane 2002-05-22 13:47:02 Re: Killing dead index tuples before they get vacuumed