Re: UNIQUE constraint matching given keys for referenced - Mailing list pgsql-general

From Tom Lane
Subject Re: UNIQUE constraint matching given keys for referenced
Date
Msg-id 578.1028902047@sss.pgh.pa.us
Whole thread Raw
In response to Re: UNIQUE constraint matching given keys for referenced  (Jeff Eckermann <jeff_eckermann@yahoo.com>)
List pgsql-general
Jeff Eckermann <jeff_eckermann@yahoo.com> writes:
> Seems kind of odd that PostgreSQL should care more
> about the non-existence of the unique constraint on a
> field than about the non-existence of that field
> itself.

Yeah, that's irritated me too.  It doesn't look quite trivial to fix
though, since you can't just check that the fields exist --- they may
not exist, yet.  Consider a self-referential table:

    create table tree_nodes (id int primary key,
                 parent int references tree_nodes(id),
                 ...);

There are double code paths in all of the analyze.c code for foreign
keys to handle both the already-exists and the will-create-it case.
Rearranging things to check column existence before existence of the
constraint thus looks a bit tricky.

But feel free to send in a patch ;-)

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: The standard 'why does it take so long' question
Next
From: Neil Conway
Date:
Subject: Re: Stored procedures returning rowsets