Re: ERROR: UNIQUE constraint ... not found?

From: "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk>
To: "Ed L(dot)" <pgsql(at)bluepolka(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: ERROR: UNIQUE constraint ... not found?
Date: 2003-04-02 22:56:38
Message-ID: Pine.LNX.4.21.0304022352360.2573-100000@ponder.fairway2k.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 2 Apr 2003, Ed L. wrote:

> > psql:test.sql:12: ERROR: UNIQUE constraint matching given keys for
> > referenced table "person" not found
>
> Ah. I was wondering why this didn't work anymore when it worked in 7.1. I
> guess the change in SERIAL semantics where the unique index is no longer
> created is what causes the problem. If I used PRIMARY KEY or create a
> unique index manually on person.id, it works fine. It seems odd that one
> cannot have a foreign key to a non-indexed column in another table.
>

Well, I suppose a trigger on insert and update could be used to impose the
unique constraint, which is what the foriegn key needs, but then every check
and use wouldn't have an index it could potentially use for the lookup.

--
Nigel J. Andrews

In response to

Browse pgsql-general by date

  From Date Subject
Next Message scott.marlowe 2003-04-02 22:59:09 date format
Previous Message Stephan Szabo 2003-04-02 22:56:25 Re: ERROR: UNIQUE constraint ... not found?