Re: Re-create dependent views on ALTER TABLE ALTER COLUMN ... TYPE?

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: ash <ash(at)commandprompt(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Re-create dependent views on ALTER TABLE ALTER COLUMN ... TYPE?
Date: 2014-05-28 12:04:34
Message-ID: 20140528120434.GW2556@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

* Robert Haas (robertmhaas(at)gmail(dot)com) wrote:
> On Mon, May 26, 2014 at 10:39 AM, Stephen Frost <sfrost(at)snowman(dot)net> wrote:
> > It'd need to be explicitly requested, eg a 'CASCADE' option.
>
> Why? Would any sane person NOT want this behavior?

[...]

> Now maybe there are options other than trying to reproduce what the
> original CREATE OR REPLACE statement would have done against the new
> type. For example, we could look through views that depend on t.a and
> rewrite each reference to that column to t.a::oldtype. This might
> lead to odd results with multiple nested casts and generally funny
> behavior if the column is re-typed multiple times; but maybe there's
> some way to fix that.

This.

> Also, it might not really be the semantics you
> want if you were hoping the type update would truly cascade. But it
> might still be better than a sharp stick in the eye, which is kinda
> what we offer today.

I hadn't even considered the idea that we would go through and try to
change everything which referenced that view to now be the new type- but
in that case, I'd want to know that there were other changes which were
happening beyond the single view which I was updating. Perhaps a NOTICE
would be enough, but it doesn't feel correct to me. Also consider
MatViews which would need to be rewritten for the new type, or pl/pgsql
functions which we couldn't possibly fix entirely (we're going to change
the variable's type definition because it selects out a column from this
view?) and so they'd just break instead.

Thanks,

Stephen

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message ash 2014-05-28 12:22:13 Re: Re-create dependent views on ALTER TABLE ALTER COLUMN ... TYPE?
Previous Message Gurjeet Singh 2014-05-28 12:00:32 Re: Proposing pg_hibernate