pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Luís Sousa <llsousa@ualg.pt>
To: pgsql-admin <pgsql-admin@postgresql.org>
Subject: Problem using pg_restore with -a option
Date: Fri, 01 Sep 2006 15:40:09 +0100
Message-ID: <44F84649.9050502@ualg.pt> (raw)

Hi all,

I'm using PostgreSQL 7.4.7-6sarge2 (debian)

Using the schema below, doing a pg_dump -Fc, delete all data, and a
pg_restore -a, the sequence of inserting data isn't correct issuing an
error.
Could this be a bug?

Notice that on schema, table periodo depends on tipo, but the sequence
is table periodo, then table  tipo and after table periodo is changed to
reference tipo.

My schema file:
drop table periodo cascade ;
drop table tipo cascade ;

create table periodo (
  "idPeriodo"               serial not null,
  "idTipo"                  int4,
  designacao                varchar(50),
  constraint pk_Periodo primary key ("idPeriodo")
) ;

create table tipo (
  "idTipo"                  serial not null,
  tipo                      varchar(5),
  designacao                varchar(50),
  constraint pk_Tipo primary key ("idTipo")
) ;

alter table periodo add constraint fk_tipo
  foreign key ("idTipo")
  references tipo ("idTipo")  ;

My data on tables:
INSERT INTO tipo (tipo,designacao) VALUES ('T','Type');
INSERT INTO periodo ("idTipo",designacao) VALUES (1,'periodo');

Error:
pg_restore: ERROR:  insert or update on table "periodo" violates foreign
key constraint "fk_tipo"
DETAIL:  Key (idTipo)=(1) is not present in table "tipo".

Best regards,
Luís Sousa





view thread (3+ messages)  latest in thread

Message-ID: <44F84649.9050502@ualg.pt>
Permalink:  ../44F84649.9050502@ualg.pt/
Also on:    postgresql.org/message-id/44F84649.9050502@ualg.pt

 · 

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: llsousa@ualg.pt
  Subject: Re: Problem using pg_restore with -a option
  In-Reply-To: <44F84649.9050502@ualg.pt>
  References: <44F84649.9050502@ualg.pt>

* 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