Re: [HACKERS] Happy column dropping

From: Peter Eisentraut <e99re41(at)DoCS(dot)UU(dot)SE>
To: The Hermit Hacker <scrappy(at)hub(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, PostgreSQL Development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: [HACKERS] Happy column dropping
Date: 2000-01-24 12:15:27
Message-ID: Pine.GSO.4.02A.10001241313230.12556-100000@Elefant.DoCS.UU.SE
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, 23 Jan 2000, The Hermit Hacker wrote:

> Its not the *risk* that bothers me, its the lack of discussions ... IMHO,
> he should have brought up the "I'm in the process of toasting the reliance
> on OIDs" topic *before* implementing it ... give other ppl a chance to
> possibly present alternatives ...

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Alain TESIO <tesio(at)easynet(dot)fr>
Subject: Re: [GENERAL] A script which drops a column
Date: Thu, 25 Nov 1999 23:36:42 -0500 (EST)

> Hello,
>
> You may be interested by a script which drops a column as this
> feature isn't supported by Postgresql. I guess it could be easier
> and nice in Perl or something similar but I'm using what I know.
>
> The parameters are in that order :
>
> the name of the database
> the table
> the column to drop
>
> Alain
>
> #!/bin/sh
>
> psql -d $1 -c "\d $2" | awk 'BEGIN { keep=1 } /+-/ { keep=1-keep } { if
> (keep) { print } }' | grep -v "\-\-" | grep -v "Table *=" | grep -v " $3
" |
> sed "s/| \([^ ]*\).*/\1/" | tr -s \\012 "," | sed "s/,$//" | sed
> "s/\(.*\)/select \1 into temp tmp_drop_column from $2 ; drop table $2 ;
> select * into $2 from tmp_drop_column;/" > tmp_sql_drop_column
> psql -d $1 -f tmp_sql_drop_column
> rm tmp_sql_drop_column

The fact is that internally this is exactly what we would have to do to
drop a column. Now that we have temp tables, maybe someone could code
up some C to do this, or just an pg_exec_query_dest() call to do the
job.

--
Bruce Momjian | http://www.op.net/~candle
maillist(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

I think what I did is significantly better than that, and of course it
will be cleaned up by next week.

--
Peter Eisentraut Sernanders vaeg 10:115
peter_e(at)gmx(dot)net 75262 Uppsala
http://yi.org/peter-e/ Sweden

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Patrick Welche 2000-01-24 12:30:00 Re: pg_dump possible fix, need testers.
Previous Message Michael Robinson 2000-01-24 11:12:46 fatal copy in/out error (6.5.3)