Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id DB11FB5F5CA for ; Tue, 7 Jun 2011 09:44:27 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 16639-10 for ; Tue, 7 Jun 2011 12:44:27 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by mail.postgresql.org (Postfix) with ESMTP id 05686B5F5C8 for ; Tue, 7 Jun 2011 09:44:26 -0300 (ADT) Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by wwwmaster.postgresql.org (8.14.3/8.14.3) with ESMTP id p57CiQi8068194 for ; Tue, 7 Jun 2011 12:44:26 GMT (envelope-from www@wwwmaster.postgresql.org) Received: (from www@localhost) by wwwmaster.postgresql.org (8.14.3/8.14.3/Submit) id p57CiQfg068192; Tue, 7 Jun 2011 12:44:26 GMT (envelope-from www) Date: Tue, 7 Jun 2011 12:44:26 GMT Message-Id: <201106071244.p57CiQfg068192@wwwmaster.postgresql.org> To: pgsql-bugs@postgresql.org Subject: BUG #6054: Insert to table, which has fkey to table, which is parenttable for another table - error From: "Alex" Content-Type: text/plain; charset=utf-8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 201106/61 X-Sequence-Number: 30440 The following bug has been logged online: Bug reference: 6054 Logged by: Alex Email address: alexander.ochkalyuk@gmail.com PostgreSQL version: 8.4.8 Operating system: CentOS Description: Insert to table, which has fkey to table,which is parenttable for another table - error Details: CREATE TABLE t1 (t1_id numeric(10,0) NOT NULL PRIMARY KEY); CREATE TABLE t2 (t2_id numeric(10,0) NOT NULL PRIMARY KEY) INHERITS (t1); CREATE TABLE t3 (t3_id numeric(10,0) NOT NULL PRIMARY KEY , t1_id numeric(10,0) NOT NULL REFERENCES t1(t1_id)) ; INSERT INTO t2 VALUES(1,2); INSERT INTO t3 VALUES(3,1); ERROR: insert or update on table "t3" violates --- foreign key constraint "t3_t1_id_fkey" DETAIL: Key (t1_id)=(1) is not present in table "t1". BUT!!!! SELECT t1_id FROM t1 WHERE t1_id = 1; -->1