Re: [postgresSQL] [bug] Two or more different types of constraints with same name creates ambiguity while drooping.

Поиск
Список
Период
Сортировка
От Amit Langote
Тема Re: [postgresSQL] [bug] Two or more different types of constraints with same name creates ambiguity while drooping.
Дата
Msg-id 56FB8D29.6080203@lab.ntt.co.jp
обсуждение исходный текст
Ответ на [postgresSQL] [bug] Two or more different types of constraints with same name creates ambiguity while drooping.  (Harshal Dhumal <harshal.dhumal@enterprisedb.com>)
Ответы Re: [postgresSQL] [bug] Two or more different types of constraints with same name creates ambiguity while drooping.  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On 2016/03/30 15:16, Harshal Dhumal wrote:
> Hi Team,
>
> While I was  working on constraints node in pgadmin4 I came across this
> scenario. Please let me know if it's correct behaviour or a bug.
>
> *Scenario:*
>
> If we create two different type of constrains (lets say primary key and
> foreign key) on same table with same name (lets say 'key' ) then its shows
> same drop query for both constrains.
> e.g.
>
> ALTER TABLE public."Test_tbl" DROP CONSTRAINT key;
>
>
> If we execute above query for first time then it drops primary key first
> and if execute same query for second time then it drops foreign key.
>
> Also in pgadmin3 if we right click on foreign key and try to drop it, it
> drops primary key and not the foreign key. We have to drop foreign key
> twice to actually drop the foreign key if primary key with same was there.

It seems that, whereas name uniqueness check occurs when creating a named
FK constraint, the same does not occur when creating a named PK constraint
or any index-based constraint for that matter (they are handled by
different code paths - in the latter's case, name conflicts with existing
relations is checked for when creating the constraint index)

Maybe, we should perform the constraint name check in code paths handling
the following two cases:

ALTER TABLE foo ADD CONSTRAINT name PK/UNIQUE/EXCLUSION ...

ALTER TABLE foo ADD CONSTRAINT name PK/UNIQUE/EXCLUSION USING INDEX ...

If so, attached a patch for the same (regression tests pass).

Thanks,
Amit

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Magnus Hagander
Дата:
Сообщение: Re: Updated backup APIs for non-exclusive backups
Следующее
От: Kyotaro HORIGUCHI
Дата:
Сообщение: Re: IF (NOT) EXISTS in psql-completion