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

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: ash <ash(at)commandprompt(dot)com>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, "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-06-02 14:05:39
Message-ID: CA+TgmoZr9cb3OvDe8cxLTPG3UmD5k3w1SMB0Hs-SQSBRfV8VMA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jun 2, 2014 at 8:52 AM, ash <ash(at)commandprompt(dot)com> wrote:
>> On Wed, May 28, 2014 at 8:22 AM, ash <ash(at)commandprompt(dot)com> wrote:
>>>> None of that involves answering hypothetical questions; but what you
>>>> want to do does, and that I think is the problem in a nutshell.
>>>
>>> In a nutshell I'd like PostgreSQL to just re-parse the *current* view
>>> definition. Should that throw an error, user intervention will be
>>> required anyway, but most of the time it should just work.
>>
>> What exactly do you mean by "re-parse the current view definition"?
>
> I mean do what the user will have to do in this situation anyway:
>
> BEGIN;
> DROP VIEW ...;
> ALTER TABLE ...;
> CREATE VIEW ...;
> COMMIT;
>
> Should this fail, the user will have to work around it, but most of the
> time it could just work.

You're either missing or choosing to ignore the point that I'm making,
which is that we *don't have* the text form of the view anywhere. If
you try to get implement what you're proposing, I'm fairly certain
that you'll find that you can't. I agree that it would be nice if
there were to make that just work; I've wished for it myself - but I
don't see a reasonable way to implement it.

>> The only form of the view definition we actually have is already
>> parsed into an internal form (see pg_rewrite) which, for the reasons
>> I've attempted to explain, is not easy to adapt to new column types.
>> I suppose we could deparse that definition and then reparse the
>> results, but that could lead to some very surprising consequences
>> (some of which are security-relevant).
>
> Like?

Tom's email covers this point, so I won't repeat what he said.

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2014-06-02 14:07:03 Re: pg_stat directory and pg_stat_statements
Previous Message Robert Haas 2014-06-02 14:02:53 Re: Jsonb: jbvBinary usage in the convertJsonbValue?