oid not "UNIQUE" for use as FOREIGN KEY? - Mailing list pgsql-general

From Ernesto Baschny
Subject oid not "UNIQUE" for use as FOREIGN KEY?
Date
Msg-id 3BD51EFF.797.11112B@localhost
Whole thread Raw
Responses Re: oid not "UNIQUE" for use as FOREIGN KEY?
List pgsql-general
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 <ernst@baschny.de>
 http://www.baschny.de - PGP Key:
http://www.baschny.de/pgp.txt
 Sao Paulo/Brasil - Stuttgart/Germany
 Ernst@IRCnet - ICQ# 2955403


pgsql-general by date:

Previous
From: Keary Suska
Date:
Subject: UNION bug in 7.1.3?
Next
From: Hiroshi Inoue
Date:
Subject: Re: [ODBC] Writing BLOBS to pgsql via ODBC using VB