Re: pg_dump --data-only problem with PgSQL 8.0 - Mailing list pgsql-admin

From Tom Lane
Subject Re: pg_dump --data-only problem with PgSQL 8.0
Date
Msg-id 23557.1106592398@sss.pgh.pa.us
Whole thread Raw
In response to pg_dump --data-only problem with PgSQL 8.0  (Jani Averbach <jaa@jaa.iki.fi>)
Responses Re: pg_dump --data-only problem with PgSQL 8.0
List pgsql-admin
Jani Averbach <jaa@jaa.iki.fi> writes:
> 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"

Try it with --disable-triggers.

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

No.  pg_dump can't guarantee a safe order for loading data when there
are pre-existing foreign key constraints in place (since the constraints
could be circular, and it wouldn't necessarily know what they are anyway).
So it doesn't try.  You have to use --disable-triggers instead.

            regards, tom lane

pgsql-admin by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: pg_dump --data-only problem with PgSQL 8.0
Next
From: Tom Lane
Date:
Subject: Re: Trouble Escaping Quotes