Constraint and Index with same name? (chicken and egg probelm) - Mailing list pgsql-general

From David Brain
Subject Constraint and Index with same name? (chicken and egg probelm)
Date
Msg-id 46091B8A.10801@bandwidth.com
Whole thread Raw
Responses Re: Constraint and Index with same name? (chicken and egg probelm)  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hi,

This could well be a recurrence of this issue:

http://archives.postgresql.org/pgsql-general/2007-01/msg01801.php

for which there doesn't seem to have been a resolution.

I am running:

PostgreSQL 8.1.5 on x86_64-pc-linux-gnu, compiled by GCC
x86_64-pc-linux-gnu-gcc (GCC) 4.1.1 (Gentoo 4.1.1-r1)

I seem to have wound up with what I can only assume is a constraint and
index sharing the same name:

e.g.

cdr=# drop index cdrimportsession_pkey;
ERROR:  cannot drop index cdrimportsession_pkey because constraint
cdrimportsession_pkey on table cdrimportsession requires it
HINT:  You may drop constraint cdrimportsession_pkey on table
cdrimportsession instead.


cdr=# alter table cdrimportsession drop constraint cdrimportsession_pkey;
NOTICE:  constraint fk_cdrsummary_cdrimportsession on table cdrsummary
depends on index cdrimportsession_pkey
ERROR:  "cdrimportsession_pkey" is an index


So the schema here is fairly straightforward - I have two tables,
cdrimportsession and cdrsummary which has a FK into cdrimportsession.

I discovered this issue while trying to remove the FK constraint from
the cdrsummary table - it complained about cdrimportsession_pkey being
an index.

I can send the output of pgdump -s on this db if this would be helpful.

While it would be great to figure out _why_ this happened it would be
even better to figure out a way of getting around it (I've already tried
  renaming the cdrimportsession_pkey index - it renames, but I then have
same issue just with different constraint/index names) as the tables
involved are pretty huge and a dump/restore isn't really an option.

Thanks,

David.

--
David Brain - bandwidth.com
dbrain@bandwidth.com
919.297.1078

pgsql-general by date:

Previous
From: Jesse Cleary
Date:
Subject: Re: Could not create relation: File exists error
Next
From: Kenneth Downs
Date:
Subject: Re: cutting out the middleperl