Re: BUG #5688: ALTER TABLE ALTER col TYPE newtype fails if col is named in an UPDATE OF col trigger - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #5688: ALTER TABLE ALTER col TYPE newtype fails if col is named in an UPDATE OF col trigger
Date
Msg-id 3930.1285978040@sss.pgh.pa.us
Whole thread Raw
In response to BUG #5688: ALTER TABLE ALTER col TYPE newtype fails if col is named in an UPDATE OF col trigger  ("Daniel Grace" <dgrace@wingsnw.com>)
List pgsql-bugs
"Daniel Grace" <dgrace@wingsnw.com> writes:
> Description:        ALTER TABLE ALTER col TYPE newtype fails if col is named
> in an UPDATE OF col trigger

Hmm, definitely a missed case (and defensive programming saves the day
again).

There are actually two cases as of 9.0 where a trigger could depend on a
column:
    * UPDATE OF said column, as in your example
    * column is used in trigger's WHEN clause

In the first case we could just allow the ALTER to proceed, but in the
second case we'd have to adjust the WHEN expression for the column's new
type, which is something there's not code for now.  And it doesn't look
like we can easily tell which case applies.  I think what we'll have to
do here is just throw a FEATURE_NOT_SUPPORTED error, and maybe add a
TODO item to come back to improve that someday.  (Since you can just
drop the trigger and re-add it after the ALTER, a nicer fix doesn't seem
like a high priority IMO.)

Thanks for the report!  It's too late for 9.0.1 but we'll do something
about this for 9.0.2.

            regards, tom lane

pgsql-bugs by date:

Previous
From: "Daniel Grace"
Date:
Subject: BUG #5688: ALTER TABLE ALTER col TYPE newtype fails if col is named in an UPDATE OF col trigger
Next
From: Andrea Peri
Date:
Subject: Postgres 9.0 crash on win7