RE: AW: ALTER TABLE DROP COLUMN

From: KuroiNeko <evpopkov(at)carrier(dot)kiev(dot)ua>
To: Inoue(at)tpf(dot)co(dot)jp, ZeugswetterA(at)wien(dot)spardat(dot)at, tgl(at)sss(dot)pgh(dot)pa(dot)us, scrappy(at)hub(dot)org, dhogaza(at)pacifier(dot)com
Cc: pgsql-hackers(at)postgreSQL(dot)org, pgman(at)candle(dot)pha(dot)pa(dot)us
Subject: RE: AW: ALTER TABLE DROP COLUMN
Date: 2000-10-15 14:29:31
Message-ID: 39E9BF4B.nail16A1XMMEU@ed.ed
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Inoue san,

> This style of "DROP COLUMN" would change the attribute
> numbers whose positons are after the dropped column.
> Unfortunately we have no mechanism to invalidate/remove
> objects(or prepared plans) which uses such attribute numbers.

1 create table alpha( id int4, payload text );
2 insert into alpha( id, payload ) values( 0, 'zero' );
3 create table t( payload text );
4 insert into t( payload ) select payload from alpha;
5 drop table alpha;
6 alter table t rename to alpha;

Not a big deal, right? Also, drop column isn't really needed
that often and requires alot of manual processing, like updating
views/rules/procedures etc.
On the other hand, when dropping a column (multiple columns) in a table
with 10+ columns, statements 3 and 4 above may become quite painfull.
It'd be nice if drop column were `expanded' to appropriate queries
automatically. Not sure about abovementioned attribute numbers in such
case.
In general, however, if drop column is the only statement that is likely
to affect attribute numbers this way (assuming that add column always adds
and never inserts an attribute), then a fairly simple function in plpgsql,
shipped with template1 will probably do. At least it should work to drop a
single column, because full-featured function will require argument list of
variable length.

Ed

---
Well I tried to be meek
And I have tried to be mild
But I spat like a woman
And I sulked like a child
I have lived behind the walls
That have made me alone
Striven for peace
Which I never have known

Dire Straits, Brothers In Arms, The Man's Too Strong (Knopfler)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Martin A. Marques 2000-10-15 15:00:39 Re: WAL status & todo
Previous Message Bruce Momjian 2000-10-15 14:12:13 Re: AW: ALTER TABLE DROP COLUMN