Re: Strange error dropping foreign key - Mailing list pgsql-hackers

From Hannu Krosing
Subject Re: Strange error dropping foreign key
Date
Msg-id 1192802088.6736.3.camel@hannu-laptop
Whole thread Raw
In response to Re: Strange error dropping foreign key  (Magnus Hagander <magnus@hagander.net>)
List pgsql-hackers
Ühel kenal päeval, R, 2007-10-19 kell 15:29, kirjutas Magnus Hagander:
> On Thu, Oct 18, 2007 at 10:48:02AM -0400, Tom Lane wrote:
> > "Magnus Hagander" <magnus@hagander.net> writes:
> > > db=# alter table isi.items_stat drop constraint items_stat_item_id_fkey;
> > > ERROR:  "items_pkey" is an index
> > 
> > Context please?
> 
> Yeah, I had that one coming, didn't it... That's what I get for trying to
> type it up on my phone on the way home.
> 
> Anyway. I've asked for a dump of the db to get all the details, but basically:
> CREATE TABLE items (
>    id int not null primary key,
>  <bunchoffields>
> );
> CREATE TABLE items_stat (
>    item_id int not null references items.id,
>  <bunchoffields>
> );
> 
> 
> One thing that might be related - items is a Slony slave table. items_stat
> is *not* in the Slony set. It's not *supposed* to have a foreign key to the
> items table, which is why I'm trying to drop it.

Slony does strange stuff to FK-s and other constraints, at least in 1.X
versions (like changing the relation type from index to
<i-dont-remember-what>) and thus you are not supposed to do DDL directly
on slaves (or even masters). 

You should use EXECUTE SCRIPT slonik command to do DDL, so that drop
index happens while original state is temporaryly restored)

Actually this should belongs to Slony list ;)

> It had the same scenario on teh primary slony node, but there the ALTER
> TABLE to drop the constraint worked fine. Again, items is master in the
> slony set, items_stat is not in any slony set.
> 
> //Magnus
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend



pgsql-hackers by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: Strange error dropping foreign key
Next
From: Martijn van Oosterhout
Date:
Subject: Re: debugger