Skip site navigation (1) Skip section navigation (2)

Re: "alter table rename" does not update constraints

From: JanWieck(at)t-online(dot)de (Jan Wieck)
To: Ulf Mehlig <umehlig(at)uni-bremen(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: "alter table rename" does not update constraints
Date: 2000-07-26 20:38:54
Message-ID: 200007262038.WAA25225@hot.jw.home (view raw or flat)
Thread:
Lists: pgsql-general
Ulf Mehlig wrote:
> Hi there,
>
> I successfully renamed one of the columns of the primary key of one of
> my tables (it is used in one of the foreign keys, too -- I think, this
> is the problem). Unfortunately, the constraint (rule system?) wasn't
> updated by "alter table" -- have a look:
>
> ----------------------------------------------------------------------
>   db=# create table blatt_schaeden (
>                nummer smallint not null,
>                datum date not null,
>                typ smallint not null,
>                klasse smallint,
>                schaden smallint,
>                primary key (nummer,datum,typ),
>                foreign key (nummer) references blatt,
>                foreign key (typ) references blatt_schadenstyp
>                );
>   CREATE
>   db=# alter table blatt_schaeden rename column nummer to blatt_nummer;
>   ALTER
>   db=# update blatt_schaeden set klasse = 0 where schaden=0;
>   ERROR:  constraint <unnamed>: table blatt_schaeden does not have an attribute nummer
> ----------------------------------------------------------------------

Hallo Ulf,

    wie geht's?

    Still  mucking  around  with  your  leaf's?  What's  the  boy
    measuring snails doing?  Still  aggregating  them  or  is  he
    totally slimed? Where the views we developed of help for him?

    Hope you don't mind, but these where the funniest samples for
    using aggregates and views I ever heard from. I'm still using
    them when it boils down to tell fun stories about work.

    :-)

> Do you consider this as a bug? There are similar items in the TODO
> file, related to "alter table add" ...

    This is a buggy feature. The refint triggers are defined in a
    way,  that  they  know  the  attribute names to look for from
    their  trigger  arguments.   But  these  trigger  definitions
    aren't updated at RENAME COLUMN time.

    We  need  to  change that to an OID based system, so they are
    out of the way for column name changes. We know  how  to  fix
    it, but time is a finite resource...


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck(at)Yahoo(dot)com #



In response to

pgsql-general by date

Next:From: Marc GehlingDate: 2000-07-26 20:52:30
Subject: pg_dump error
Previous:From: Timothy H. KeittDate: 2000-07-26 19:57:33
Subject: adding column constraint

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group