Theoretically, you could have the same problem with the primary key -- there
could be an index with that name already.
But in practice it doesn't happen. You could generate a name for the foreign
key based on similar pattern for the pk
and if it fails, then it falls on the user to provide a name. Seem like it
would work 99% of the time.

On Sat, Nov 20, 2010 at 7:49 AM, Guillaume Lelarge
<guilla...@lelarge.info>wrote:

>
> >>> Well, you could generate the name of the FOREIGN KEY in pgadmin as
> >>> well, then you know what it'll be... Even when the user doesn't specify
> one.
> >>>
> >>> Another one would be to name the index fki_<tablename>_<columnname> or
> >>> something like that instead.
> >>>
> >>
> >> I thought about it, but rejected it on the idea that you can't be sure
> >> the index creation will work (the same index name can already exist).
> >> But, thinking more about it, the old algorithm wasn't better at it
> anyway.
> >
>

Reply via email to