Re: FK Constraint on index not PK - Mailing list pgsql-general

From Scott Marlowe
Subject Re: FK Constraint on index not PK
Date
Msg-id 1168624761.20602.691.camel@state.g2switchworks.com
Whole thread Raw
In response to FK Constraint on index not PK  (Stéphane Schildknecht<stephane.schildknecht@postgresqlfr.org>)
Responses Re: FK Constraint on index not PK
List pgsql-general
On Fri, 2007-01-12 at 10:50, Stéphane Schildknecht wrote:
> Dear community members,
>
> I'm having a quite strange behaviour while trying to drop some index.
>
> We have some tables with two indexes on a primary key. The first one was
> automatically created by the primary constraint. The second one was
> manually created on the same column. Don't know why, but I would now
> want to suppress it.
>
> The first index is : foo_pkey
> The second one : i_foo_pk
> The constraint on table bar is fk_bar_foo references foo(id)
>
> But, when trying to drop the second index I get the following message :
>
> NOTICE:  constraint fk_bar_foo on table t_foo depends on index i_foo_pk
>
> The database server is 7.4.5 .
>
> Having dumped database and restored it on a 8.2 server, I could drop the
> second index without any problem.
>
> The fact is I could do that as I indded what to migrate all databases
> from 7.4 to 8.2. But I would prefer not to recreate every index before
> dropping the non necessary one. And duplicate indexes are surely
> unnecessary...
>
> I have read in some thread that these troubles are known and have been
> corrected in versions > 7.4.5. But, droping them before migrating is an
> option I'd prefer to use.

Simple.  Backup your db just in case, then upgrade in place to the
latest 7.4 (7.4.15 or so) then you should be able to drop the indexes in
place.

patch upgrades do NOT require dump / reload, so 7.4.5 -> 7.4.15 should
only require a brief period where you shut down the db while you install
the new version.

pgsql-general by date:

Previous
From: Scott Ribe
Date:
Subject: Re: Checkpoint request failed on version 8.2.1.
Next
From: Tom Lane
Date:
Subject: Re: Checkpoint request failed on version 8.2.1.