Re: ALTER RENAME and indexes

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Brent Verner <brent(at)rcfile(dot)org>
Cc: Rod Taylor <rbt(at)zort(dot)ca>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ALTER RENAME and indexes
Date: 2001-10-07 11:03:40
Message-ID: Pine.BSF.4.21.0110070400210.72409-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On Sat, 6 Oct 2001, Brent Verner wrote:

> On 06 Oct 2001 at 20:13 (-0400), Rod Taylor wrote:
> | Of course, in 7.1 foreign key constraints become rather confused when
> | you rename columns on them.
> |
> | create table parent (id serial);
> | create table child (id int4 references parent(id) on update cascade);
> | alter table parent rename column id to anotherid;
> | alter table child rename column id to junk;
> | insert into child values (1);
> |
> | -> ERROR: constraint <unnamed>: table child does now have an
> | attribute id
>
> ok, I see where this breaks. The args to the RI_ConstraintTrigger_%d
> are written into the pg_trigger tuple like so..
>
> '<unnamed>\000child\000parent\000UNSPECIFIED\000id\000id\000'
>
> There are really two approaches, AFAICS.
>
> 1) modify this tgargs value to reflect the modified column name(s).
> 2) modify <whatever uses these args> to use the oid instead of
> the column names, and modify CreateTrigger to reflect this change..
>
> #2 seems to be the most bulletproof approach, so I'm looking
> into hacking this up right now. Any comments would be much
> appreciated about any (better) ways to fix this problem.

#2 also requires changes to dump/restore stuff, since AFAIK
it currently dumps create constraint trigger statements and the
oids won't be known for the restore, but this is probably a good
idea in general.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Brent Verner 2001-10-07 12:49:10 Re: ALTER RENAME and indexes
Previous Message Brent Verner 2001-10-07 02:56:14 Re: ALTER RENAME and indexes