Skip site navigation (1) Skip section navigation (2)

BUG #2335: Order of data in data-only dumps

From: "Jozef Behran" <jozef(dot)behran(at)krs(dot)sk>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #2335: Order of data in data-only dumps
Date: 2006-03-18 07:13:44
Message-ID: 200603180713.k2I7Diax014968@wwwmaster.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugs
The following bug has been logged online:

Bug reference:      2335
Logged by:          Jozef Behran
Email address:      jozef(dot)behran(at)krs(dot)sk
PostgreSQL version: 8.1.0
Operating system:   Linux (Mandriva Linux 10.0)
Description:        Order of data in data-only dumps
Details: 

When doing a data-only dump, the tables are dumped in alphabetical order.
This is unfortunate as I might want to fetch the file into a fully created
schema (including indices/constraints) for example to prevent bad data from
being fetched without an error ot to accomodate old data in a new schema and
the alphabetical order of the tables may be wrong.

Older versions (7.x particularly) ensure the order of the tables in the dump
is such that it can be fetched into fully created schema without problems.

It is OK to have the tables ordered aplabetically in full dumps as it is
unlikely to fetch such dump into something other than an empty database.

To see some problematic data try:

BEGIN;
CREATE TABLE b (
  id int4,
  PRIMARY KEY(id)
);
CREATE TABLE a (
  id int4,
  other int4 references b
    on update cascade on delete cascade
);
INSERT INTO b VALUES (1);
INSERT INTO a VALUES (1,1);
COMMIT;

Then try

pg_dump -a <database_name>

The pg_dump will dump a, then b but it should do it in reverse order.

I think the few more CPU cycles needed to sort the tables like in 7.x series
is not worth the reduced usability of the dumps when incorrect table order
is used. Especially when the order of data does not break anything even in
the full dump.

pgsql-bugs by date

Next:From: William ZHANGDate: 2006-03-18 14:05:39
Subject: Re: BUG #2332: commands ignored until end of transaction block
Previous:From: Tom LaneDate: 2006-03-18 04:52:58
Subject: Re: BUG #2330: ECPGlib: Wrong error code in case of a duplicate key violation

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group