Re: [HACKERS] pg_restore failed for foreign key constraint - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] pg_restore failed for foreign key constraint
Date
Msg-id 21358.1500300213@sss.pgh.pa.us
Whole thread Raw
In response to [HACKERS] pg_restore failed for foreign key constraint  (Neha Sharma <neha.sharma@enterprisedb.com>)
List pgsql-hackers
Neha Sharma <neha.sharma@enterprisedb.com> writes:
> I am getting the below error while restoring data having foreign key
> constraint.

> [edb@localhost bin]$ ./createdb test1
> [edb@localhost bin]$ ./pg_restore -d test1 -c -e a.dump
> pg_restore: [archiver (db)] Error while PROCESSING TOC:
> pg_restore: [archiver (db)] Error from TOC entry 2903; 2606 16399 FK
> CONSTRAINT test_tbl test_tbl_fk_c1 edb
> pg_restore: [archiver (db)] could not execute query: ERROR:  schema "test"
> does not exist
>     Command was: ALTER TABLE ONLY test.test_tbl DROP CONSTRAINT
> test_tbl_fk_c1;

> Is this an expected behaviour?

Yes, it is.  Either don't use -c (it's entirely useless when restoring
into an empty database), or specify --if-exists, or ignore the errors.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Shubham Barai
Date:
Subject: Re: [HACKERS] GSoC 2017: weekly progress reports (week 6)
Next
From: Andrew Dunstan
Date:
Subject: [HACKERS] Unportable use of select for timeouts in PostgresNode.pm