Thread: Bug #609: CREATE TABLE with implicit index should not fail if index already exists
Bug #609: CREATE TABLE with implicit index should not fail if index already exists
From
pgsql-bugs@postgresql.org
Date:
Vladimir (VAndrianov@Omeda.com) reports a bug with a severity of 3 The lower the number the more severe it is. Short Description CREATE TABLE with implicit index should not fail if index already exists Long Description When PostgreSQL tries to create implicit index during table creation and assumed index's name already exists it fails. Probably, it's not a bug, but I don't think this behavior is right. When your intent is to create table with implicit indices you likely don't care about names of those indices. I think inthis situation PostgreSQL have to construct some unique index name that doesn't conflict with any existent names. Sample Code demo=# select version(); version --------------------------------------------------------------- PostgreSQL 7.1.3 on i686-pc-linux-gnu, compiled by GCC 2.95.4 (1 row) demo=# create table tst1 (c1 int2 unique); NOTICE: CREATE TABLE/UNIQUE will create implicit index 'tst1_c1_key' for table 'tst1' CREATE demo=# alter table tst1 rename to tst2; ALTER demo=# create table tst1 (c1 int2 unique); NOTICE: CREATE TABLE/UNIQUE will create implicit index 'tst1_c1_key' for table 'tst1' ERROR: Cannot create index: 'tst1_c1_key' already exists No file was uploaded with this report