Pessoal,

Mais um problema com este bendito particionamento !! 

1. Criei a tabela measurement:

CREATE TABLE "public"."measurement" (
  "city_id" INTEGER NOT NULL, 
  "logdate" DATE NOT NULL, 
  "peaktemp" INTEGER, 
  "unitsales" INTEGER, 
  CONSTRAINT "measurement_pkey" PRIMARY KEY("city_id")
) WITHOUT OIDS;

2. Criei uma particao para esta tabela herdando as caracteristicas da tabela
principal.

CREATE TABLE measurement_y2006m02 ( ) INHERITS (measurement);

3. Criei a trigger em cima da tabela principal, com a sua respectiva funcao:

CREATE TRIGGER "insert_measurement_trigger" BEFORE INSERT 
ON "public"."measurement" FOR EACH ROW 
EXECUTE PROCEDURE "public"."measurement_insert_trigger"();

4. Criei a tabela estado, com uma foreign key apontando para a tabela
anterior:
CREATE TABLE "public"."estado" (
  "estado_id" INTEGER NOT NULL, 
  "city_id" INTEGER, 
  CONSTRAINT "estado_pkey" PRIMARY KEY("estado_id"), 
  CONSTRAINT "estado_fk" FOREIGN KEY ("city_id")
    REFERENCES "public"."measurement"("city_id")
    ON DELETE NO ACTION
    ON UPDATE NO ACTION
    NOT DEFERRABLE
) WITH OIDS;


5. Problema

Persisto normalmente na tabela measurement, quando vou persistir na tabela
estado, o postgres reclama que não existe dado na tabela measurement,
conforme mensagem abaixo:

ERROR:  insert or update on table "estado" violates foreign key constraint
"estado_fk"
DETAIL:  Key (city_id)=(1) is not present in table "measurement".


Alguem tem ideia do que está acontecendo ?!



-- 
View this message in context: 
http://old.nabble.com/Foreign-Key-com-particionamento-tp28399358p28399358.html
Sent from the PostgreSQL - Brasil mailing list archive at Nabble.com.

_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a