Re: [OT] why not keeping the original column name in catalog after a drop?

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Luca Ferrari <fluca1978(at)infinito(dot)it>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [OT] why not keeping the original column name in catalog after a drop?
Date: 2013-11-13 08:00:11
Message-ID: 20131113080011.GD5666@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nicolas Barbier 2013-11-13 08:07:17 Re: Fast insertion indexes: why no developments
Previous Message Rohit Goyal 2013-11-13 07:59:42 Re: Information about Access methods