Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > The reason I think we have to mention the constraint name is that you
> > could have a multi-column primary/foreign key, so instead of mentioning
> > each column, we just mention the constraint name, which should be easy
> > to identify.
>
> However, the complaint will be about one single column being of a
> non-matching type. In the case of a multicolumn foreign key, giving
> only the constraint name is unhelpful. Even for a one-column key,
> it's not obvious to me why the constraint name is better than the column
> name.
>
> [ thinks... ] I guess it could be that the same column is being used in
> several different FK constraints, so if we just give column names then
> it would also be important to mention the referenced column.
>
> I'd suggest something along the lines of
>
> NOTICE: foreign key constraint "constrname" will require a cross-type conversion
> DETAIL: key columns "fkcol" and "pkcol" are of different types integer and double precision
I suggested the constraint name because of multi-column keys, where he
would have to print an arbitrary number of columns in the message. It
didn't seem worth doing that work. I see your idea of just printing the
column, but that doesn't really point to the primary/foreign key
relationship. If the user can't figure out which columns are a mismatch
from the constraint name, they have larger problems than this. :-)
> if you want to be really complete.
>
> I've got mixed feelings about the WARNING-vs-NOTICE issue. WARNING
> seems too strong, like we are trying to tell them that it won't work at
> all. Particularly with text like the above, which completely fails to
> explain that the problem is only one of speed and not functionality.
> If you want it to be a WARNING then we gotta work on the text some more.
Yes, let's re-add 'costly' to the text:
> WARNING: foreign key constraint "constrname" will require a costly cross-type conversion
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073