Re: ALTER TABLE table RENAME COLUMN x TO y

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Donald Fraser" <demolish(at)cwgsy(dot)net>
Cc: pgsql-bugs(at)postgreSQL(dot)org, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: ALTER TABLE table RENAME COLUMN x TO y
Date: 2003-08-11 17:23:01
Message-ID: 3777.1060622581@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

"Donald Fraser" <demolish(at)cwgsy(dot)net> writes:
> When issuing the following type of command:
> ALTER TABLE table RENAME COLUMN x TO y
> The column name change is not cascading through to RULEs on a VIEW.

More specifically, INSERTs and UPDATEs contained in rules don't have
their target column names adjusted. This is because the "resname"
fields in their targetlists contain the original column names, and
those fields are actually looked at to determine the target columns.

I think this behavior is vestigial, and we could both simplify the code
and make it RENAME-proof by using just the "resno" fields to determine
the target columns. "resname" would then have just one purpose: to
carry the "AS" alias of targetlist entries in SELECTs. There is already
code in ruleutils.c to allow "resname" to be overridden by the current
column name of a view (thus handling RENAME applied to the view itself),
and I don't think "resname" is user-visible in any other way.

Anyone see a problem with this plan?

I regard this as something we should fix for 7.4, mainly because if you
use --enable-cassert then the backend actually dumps core when trying to
execute the outdated rule (there are Asserts in there that notice the
resname mismatch).

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Mike Nerone 2003-08-11 19:46:01 SysV startup script name in binary RPM distribution
Previous Message Oscar Estevez Lopez 2003-08-11 15:11:30 Re: extract and time zones

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-08-11 17:29:19 Re: Windows on SuSE? 7.4
Previous Message The Hermit Hacker 2003-08-11 17:14:21 Re: Farewell