Re: Re: About "Allow VIEW/RULE recompilation when the underlying tables change"

From: decibel <decibel(at)decibel(dot)org>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Caleb Welton <cwelton(at)greenplum(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, suzhiyang <suzhiyang(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Re: About "Allow VIEW/RULE recompilation when the underlying tables change"
Date: 2009-12-22 22:12:56
Message-ID: E3118575-1E46-404A-8543-F071B27A6C94@decibel.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Dec 19, 2009, at 4:38 PM, Robert Haas wrote:
> On Sat, Dec 19, 2009 at 1:56 PM, Caleb Welton <cwelton(at)greenplum(dot)com> wrote:
>> I maintain that the approaches that inform the user that they have met that
>> condition via ALTER statement failures (Postgres/DB2/Microsoft Bound Views)
>> have certain advantages over databases that allow the update but may
>> silently leave views in an usable state (Oracle, Terradata), in that at
>> least the user Knows when they have to re-examine their views.
>
> Agreed.
>
>> As far as I can tell there are three approaches that could be taken to help
>> address this problem:
>> 1) DB2 like approach - try to perform rewrites where able, but if the
>> rewrite fails then the alter operation fails. Would allow simple edits such
>> as ALTER TYPE that are only changes in typmod, or if done more ambitiously
>> would allow numbers to be changed to other numbers. But as Robert says this
>> quickly approaches the territory of black magic.
>
> And it can easily lead to silent breakage - e.g. if you change an
> integer column to text, the view's attempt to coerce the text back to
> integer will continue working as long as that coercion is valid for
> all the data the view examines, but you have to think the user had a
> reason for changing the type...

Or we could simply disallow those types of cases. It's not optimal, but would still provide a lot of benefit in other cases.

BTW, +1 on allowing something akin to SELECT * to propagate ADD COLUMN, though for compatibility we should use something other that "SELECT *".
--
Jim C. Nasby, Database Architect jim(at)nasby(dot)net
512.569.9461 (cell) http://jim.nasby.net

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-12-22 22:16:35 Re: LIKE INCLUDING COMMENTS code is a flight of fancy
Previous Message decibel 2009-12-22 22:04:15 Re: Removing pg_migrator limitations