Constraint and Index with same name? (chicken and egg probelm)

From: David Brain <dbrain(at)bandwidth(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Constraint and Index with same name? (chicken and egg probelm)
Date: 2007-03-27 13:26:34
Message-ID: 46091B8A.10801@bandwidth.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)bandwidth(dot)com
919.297.1078

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kenneth Downs 2007-03-27 13:35:17 Re: cutting out the middleperl
Previous Message Jesse Cleary 2007-03-27 13:19:59 Re: Could not create relation: File exists error