pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jani Averbach <jaa@jaa.iki.fi>
To: pgsql-admin@postgresql.org
Subject: pg_dump --data-only problem with PgSQL 8.0
Date: Mon, 24 Jan 2005 11:16:56 -0700
Message-ID: <20050124181656.GF23224@jaa.iki.fi> (raw)


Hello, I have a following problem:

In short: I can't reload pg_dump --data-only dump (ver. 8.0) back to
the database, because the loading will violate ref. integrity.


The long story:

We have a PgSQL 7.2.5 database, and we like to bring only the data to
the PgSQL 8.0 system. So I did following:

1) dump 7.2.5 database with:
       pg_dump \
            "--data-only" \
            "--column-inserts" \
            "--use-set-session-authorization" \
            old_db > old_db.data-only.dump

2) Create a schema on the new PgSQL system:
        CreateDBSchema.sh new_db 

3) Load the old data to the new system:
        psql new_db < old_db.data-only.dump 

So far, so good, the loading succeeded. Now If continue, 
the following won't work:

4) Dump only data from just created 8.0 database:
       pg_dump \
            "--data-only" \
            "--column-inserts" \
            "--use-set-session-authorization" \
            new_db > new_db.data-only.dump

5) Re-Create the new_db:
       dropdb new_db; createdb new_db
       CreateDBSchema.sh new_db

6) Try to reload data which was dumped from new ver 8.0 database:
        psql new_db < new_db.data-only.dump

This will fail with lots of these kinds of errors:
         ERROR:  insert or update on table "mytable" 
         violates foreign key constraint "mytable_myattr_fkey"


However, If I take a data+schema dump after step #3,

7) Dump data and schema from new database:
        pg_dump "--use-set-session-authorization" \
               new_db >  new_db.dump

8) And load that, it will succeed:
     dropdb new_db; createdb new_db
     psql new_db < new_db.dump


What I am doing wrong? Or have I found an ordering bug with pg_dump
when you are doing "--data-only" dumps?

These two databases are living in different machines, so there can't be
any version mismatch between pg_dump, psql and databases.

Thanks for any help,
Jani

-- 
Jani Averbach 



view thread (4+ messages)  latest in thread

Message-ID: <20050124181656.GF23224@jaa.iki.fi>
Permalink:  ../20050124181656.GF23224@jaa.iki.fi/
Also on:    postgresql.org/message-id/20050124181656.GF23224@jaa.iki.fi

 · 

reply

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-admin@postgresql.org
  Cc: jaa@jaa.iki.fi
  Subject: Re: pg_dump --data-only problem with PgSQL 8.0
  In-Reply-To: <20050124181656.GF23224@jaa.iki.fi>
  References: <20050124181656.GF23224@jaa.iki.fi>

* 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