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