Rules containing INSERT/UPDATE lack dependencies on target columns

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Cc: Bill MacArthur <webmaster(at)dhs-club(dot)com>
Subject: Rules containing INSERT/UPDATE lack dependencies on target columns
Date: 2012-03-09 19:14:41
Message-ID: 3781.1331320481@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2012-03-09 19:16:25 Re: Command Triggers, patch v11
Previous Message Andrew Dunstan 2012-03-09 18:51:37 Re: elegant and effective way for running jobs inside a database