FK column doesn't exist error message could use more detail

From: decibel <decibel(at)decibel(dot)org>
To: PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: FK column doesn't exist error message could use more detail
Date: 2009-01-26 22:45:25
Message-ID: B72A2FB7-C13A-4990-A612-F94E552EAABD@decibel.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

create table a(a_id serial primary key, a int);
create table b(b_id serial primary key, a_id int not null references a
(id), b int, c_id int not null references c(id));
NOTICE: CREATE TABLE will create implicit sequence "b_id_seq" for
serial column "b.b_id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"b_pkey" for table "b"
ERROR: column "id" referenced in foreign key constraint does not exist

How can I tell which FK constraint that's for? Could we have backend/
tablecmds.c:transformColumnNameList() report the constraint name?
Though, that wouldn't be quite enough if you did:

CREATE TABLE a(a_id ...)
CREATE TABLE b(.., a_id int not null, foreign key(id) references a(id))

Handling that would require passing something into
transformColumnNameList() to tell it if it was checking fk_attrs vs
pk_attrs. Perhaps that's overkill... Thoughts?
--
Decibel!, aka Jim C. Nasby, Database Architect decibel(at)decibel(dot)org
Give your computer some brain candy! www.distributed.net Team #1828

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Christopher Browne 2009-01-26 22:56:37 On SCM
Previous Message Joshua Brindle 2009-01-26 22:44:24 Re: 8SEPostgres WAS: .4 release planning