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

2009-01-26 Thread decibel

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  deci...@decibel.org
Give your computer some brain candy! www.distributed.net Team #1828



--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] FK column doesn't exist error message could use more detail

2009-01-26 Thread Tom Lane
decibel deci...@decibel.org writes:
 How can I tell which FK constraint that's for? Could we have backend/ 
 tablecmds.c:transformColumnNameList() report the constraint name?  

If it has a name at all, the name was probably made up from the given
column names, so this seems a mite useless.

At some point we might get around to propagating error cursor
positioning ability into utility commands, but don't hold your breath...

regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers