[OT] why not keeping the original column name in catalog after a drop?
Hi all,
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?
Thanks,
Luca
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Wed, Nov 13, 2013 at 1:22 PM, Luca Ferrari <fluca1978@infinito.it> wrote:
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?
May be when a column with the same name is added and again dropped ? Of
course, we can have the attribute number and column name both to avoid
conflict.
Thanks,
Pavan
--
Pavan Deolasee
http://www.linkedin.com/in/pavandeolasee
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
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Wed, Nov 13, 2013 at 9:00 AM, Andres Freund <andres@2ndquadrant.com> wrote:
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.
Thanks, I was guessing this.
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
Well, I was talking about appending the original column name, and
therefore the above should have been respectively pg.dropped.1.cola.
and pg.dropped.2.cola. Of course the original name is not very much
interesting, I was just curios about the conflicts.
Luca
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers