The following bug has been logged online: Bug reference: 5495 Logged by: Martin Edlman Email address: edl...@fortech.cz PostgreSQL version: 8.4.4 Operating system: Scientific Linux 5.5 (RHEL) Description: RI/FK on self and inherited table Details:
I have a table net.device(id serial, parent_id integer null, name varchar(100), ip_address inet, ...) device_parent_id_fkey FOREIGN KEY (parent_id) REFERENCES net.device(id) ON UPDATE CASCADE and a table net.computer(parent_id integer not null, ...) inherits (net.device); I have a script which inserts records to both tables and it always stops on the same record for net.computer with followin message ERROR: insert or update on table "device" violates foreign key constraint "device_parent_id_fkey" DETAIL: Key (parent_id)=(19947) is not present in table "device". But the record is there, it was inserted into net.computer so it's selectable from net.device and from net.computer. select id,parent_id,name,ip_address from net.device where id = 19947; id | parent_id | name | ip_address -------+-----------+-----------------+-------------------- 19947 | 1649 | pc-lit-customer | 213.213.213.213/30 select id,parent_id,name,ip_address from net.computer where id = 19947; id | parent_id | name | ip_address -------+-----------+-----------------+-------------------- 19947 | 1649 | pc-lit-digistyl | 213.250.201.222/30 There are other records in the net.computer which are referenced in other records as the parent_id. It really puzzles me. If you want I can send you full definition of the net.device and the net.computer including indices, triggers etc. I have inserted 1795 records to net.device select count(*) from only net.device; count ------- 1795 and 5105 records to net.computer select count(*) from only net.computer; count ------- 5105 That's 6900 records in total select count(*) from net.device; count ------- 6900 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs