pg_restore failed for foreign key constraint

From: Neha Sharma <neha(dot)sharma(at)enterprisedb(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: pg_restore failed for foreign key constraint
Date: 2017-07-17 10:46:34
Message-ID: CANiYTQsxjEw-GE3e3emO2EFZ77TxbDVay_qqjZi5H=Xyh3s=sw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I am getting the below error while restoring data having foreign key
constraint.

./psql postgres
psql (10beta2)
Type "help" for help.

postgres=# create user test;
CREATE ROLE
postgres=# create schema test;
CREATE SCHEMA
postgres=# grant all on SCHEMA test to test;
GRANT
postgres=# set search_path to 'test';
SET
postgres=# CREATE TABLE test_tbl_fk (c1 INTEGER PRIMARY KEY);
CREATE TABLE
postgres=# CREATE TABLE test_tbl (c1 INTEGER PRIMARY KEY, c2 INTEGER, c3
VARCHAR,
postgres(# CONSTRAINT test_tbl_fk_c1 FOREIGN KEY (c1) REFERENCES
test_tbl_fk(c1));
CREATE TABLE
postgres=# insert into test_tbl_fk values (1),(2),(3);
INSERT 0 3
postgres=# INSERT INTO test_tbl VALUES (1,1,'p11');
INSERT 0 1
postgres=# INSERT INTO test_tbl VALUES (2,2,'p11');
INSERT 0 1
postgres=# INSERT INTO test_tbl VALUES (3,3,'p11');
INSERT 0 1
postgres=# show search_path ;
search_path
-------------
test
(1 row)

postgres=# \q
[edb(at)localhost bin]$ ./pg_dump -f a.dump -Fc postgres
[edb(at)localhost bin]$ ./createdb test1
[edb(at)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?

--
Regards,
Neha Sharma

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Christoph Berg 2017-07-17 10:49:16 Re: 10beta1/m68k: static assertion failed: "MAXALIGN too small to fit int32"
Previous Message Alik Khilazhev 2017-07-17 10:34:15 Re: [WIP] Zipfian distribution in pgbench