oid not "UNIQUE" for use as FOREIGN KEY?

Поиск
Список
Период
Сортировка
Искать
От
Ernesto Baschny
Тема
oid not "UNIQUE" for use as FOREIGN KEY?
Дата
Msg-id
3BD51EFF.797.11112B@localhost
Список
Дерево обсуждения
oid not "UNIQUE" for use as FOREIGN KEY? "Ernesto Baschny" <ernst@baschny.de>
Re: oid not "UNIQUE" for use as FOREIGN KEY? Stephan Szabo <sszabo@megazone23.bigpanda.com>
Re: oid not "UNIQUE" for use as FOREIGN KEY? Tom Lane <tgl@sss.pgh.pa.us>
Re: oid not "UNIQUE" for use as FOREIGN KEY? Stephan Szabo <sszabo@megazone23.bigpanda.com>
Re: oid not "UNIQUE" for use as FOREIGN KEY? "Ernesto Baschny" <ernst@baschny.de>
Re: oid not "UNIQUE" for use as FOREIGN KEY? Stephan Szabo <sszabo@megazone23.bigpanda.com>
Re: oid not "UNIQUE" for use as FOREIGN KEY? Tom Lane <tgl@sss.pgh.pa.us>
Hi!

Imagine I have tables like those in PostgreSQL 7.1.3:

CREATE TABLE rabattgruppe (
    gruppe_oid OID,
    produktgruppe VARCHAR(256)
);

CREATE TABLE gruppe (
    obergruppe_oid OID,
    name VARCHAR(32)
);

Then I try to establish integrity check 

ALTER TABLE gruppe ADD
  FOREIGN KEY (obergruppe_oid) REFERENCES gruppe (oid);

But:

NOTICE:  ALTER TABLE ... ADD CONSTRAINT will create implicit 
trigger(s) for FOREIGN KEY check(s)
ERROR:  UNIQUE constraint matching given keys for referenced 
table "gruppe" not found

I thought the problem was I was referring to the same table,
but also this doesn't work:

ALTER TABLE rabattgruppe ADD
  FOREIGN KEY (gruppe_oid) REFERENCES gruppe (oid);

NOTICE:  ALTER TABLE ... ADD CONSTRAINT will create implicit 
trigger(s) for FOREIGN KEY check(s)
ERROR:  UNIQUE constraint matching given keys for referenced 
table "gruppe" not found

Now, what is the problem?  "oid" for sure should be an UNIQUE
field in each table, doesn't it?  Is it a bug?


Thanks,
Ernesto

--
Ernesto Baschny 
 http://www.baschny.de - PGP Key: 
http://www.baschny.de/pgp.txt
 Sao Paulo/Brasil - Stuttgart/Germany
 Ernst@IRCnet - ICQ# 2955403

В списке pgsql-general по дате отправления
От: Keary Suska
Дата:
Сообщение: UNION bug in 7.1.3?
От: Hiroshi Inoue
Дата:
FAQ