Re: [OT] why not keeping the original column name in catalog after a drop? - Mailing list pgsql-hackers

From Andres Freund
Subject Re: [OT] why not keeping the original column name in catalog after a drop?
Date
Msg-id 20131113080011.GD5666@awork2.anarazel.de
Whole thread Raw
In response to [OT] why not keeping the original column name in catalog after a drop?  (Luca Ferrari <fluca1978@infinito.it>)
Responses Re: [OT] why not keeping the original column name in catalog after a drop?
List pgsql-hackers
Hi,

On 2013-11-13 08:52:27 +0100, Luca Ferrari wrote:
> when you drop a column on a table the pg_attribute is updated and the
> name of the column is changed with an almost fixed identifier that
> reports only the original column position:
> 
> /*
>  * Change the column name to something that isn't likely to conflict
>  */
>         snprintf(newattname, sizeof(newattname),
>                  "........pg.dropped.%d........", attnum);
>         namestrcpy(&(attStruct->attname), newattname);
> 
> I'm wondering what is the problem in placing the old/original name
> after the "pg.dropped" prefix. I know that the tuple in pg_attribute
> is temporary, but what are the possible conflicts the comment talks
> about?

The old name might not fit there, attribute names have a relatively low
maximum length (64 by default), so we cannot always fit the entire old
name there.

Also, think about:
CREATE TABLE foo(cola int);
ALTER TABLE foo DROP COLUMN cola;
ALTER TABLE foo ADD COLUMN cola;
ALTER TABLE foo DROP COLUMN cola; -- should not error out

I don't really see much need for anything better than the current
solution, why is the old name interesting?

Greetings,

Andres Freund

-- Andres Freund                       http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training &
Services



pgsql-hackers by date:

Previous
From: Rohit Goyal
Date:
Subject: Re: Information about Access methods
Next
From: Nicolas Barbier
Date:
Subject: Re: Fast insertion indexes: why no developments