Thread: Rules containing INSERT/UPDATE lack dependencies on target columns

Rules containing INSERT/UPDATE lack dependencies on target columns

From
Tom Lane
Date:
I looked into the misbehavior reported here:
http://archives.postgresql.org/pgsql-bugs/2012-03/msg00068.php

The reason the ALTER TABLE fails to fail is $SUBJECT: it goes looking
for pg_depend entries showing that rewrite rules depend on the column to
be altered, but there isn't one.  This is basically because dependency.c
only generates column dependencies for Vars, and the representation of
an INSERT or UPDATE does not use a Var to specify a target column.

ISTM we need to add such dependencies.  Aside from the change-of-type
issue reported above, you can get very curious behavior if you remove a
target column with ALTER TABLE DROP COLUMN, and I don't think we want to
allow that.

I'm inclined to only fix this in HEAD.  Back-patching would have limited
usefulness since it wouldn't cause the missing pg_depend entries to
spring into existence for existing rules; and given the lack of prior
reports, it's clearly not something that comes up often.
        regards, tom lane


Re: Rules containing INSERT/UPDATE lack dependencies on target columns

From
Robert Haas
Date:
On Fri, Mar 9, 2012 at 2:14 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> I'm inclined to only fix this in HEAD.

+1.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company