BUG #5495: RI/FK on self and inherited table

Поиск
Список
Период
Сортировка
От Martin Edlman
Тема BUG #5495: RI/FK on self and inherited table
Дата
Msg-id 201006090801.o5981mVK028904@wwwmaster.postgresql.org
обсуждение исходный текст
Ответы Re: BUG #5495: RI/FK on self and inherited table
Re: BUG #5495: RI/FK on self and inherited table
Список pgsql-bugs
The following bug has been logged online:

Bug reference:      5495
Logged by:          Martin Edlman
Email address:      edlman@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

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: BUG #5475: Problem during Instalation
Следующее
От: Dave Page
Дата:
Сообщение: Re: BUG #5475: Problem during Instalation