Re: Bug #895: incorrect error message when duplicate index name

Поиск
Список
Период
Сортировка
От greg@turnstep.com
Тема Re: Bug #895: incorrect error message when duplicate index name
Дата
Msg-id 5169e4b75ea5c36115e84a61703e353b@biglumber.com
обсуждение исходный текст
Ответ на Bug #895: incorrect error message when duplicate index name  (pgsql-bugs@postgresql.org)
Список pgsql-bugs
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


> Long Description
> ERROR:  relation named "pk_exchange_batch_idx" already exists
> Why relation when I create index?

An index is a type of relation: other types of relations include tables,
views, and sequences. A relation is simply something in the database that
can be represented as a table. Each relations must have a unique name, no
matter what type it is:

=> create table foobar(a int);
CREATE TABLE

=> create index foobar on foobar(a);
ERROR:  relation named "foobar" already exists

=> create view foobar as select * from foobar;
ERROR:  Relation 'foobar' already exists


You can see from the last example why having the same name would be a
problem - does "SELECT * FROM foobar" refer to the table 'foobar'
or the view 'foobar'? If we did not have the unique name contraint,
we would have to tell the database which 'foobar' we meant.

The error message you received means that *something* else already
has that name, but not necessarily an index.


- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200302130948
-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html

iD8DBQE+S7B4vJuQZxSWSsgRAluSAJ9lLglRRijBRhCbIh6/v5pQm0U1zACgjIKz
/AZ9yAdOsZ2xoF2xwp/YKS8=
=VW2o
-----END PGP SIGNATURE-----

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Constraints not check indexes existence on creation.
Следующее
От: Tom Lane
Дата:
Сообщение: Re: 'update' as action of 'insert' rule: permission denied