Re: ALTER TABLE should change respective views

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org, Archana Sundararam <archnasr(at)yahoo(dot)com>
Subject: Re: ALTER TABLE should change respective views
Date: 2009-05-05 18:17:29
Message-ID: 4A0082B9.3090000@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

All,

I was discussing this with a client who experiences this problem on a
weekly basis, and the issue is mainly one of change management.

That is, manually dropping all of the views & functions dependant on a
table, changing the table, and recreating the views and functions, is a
major PITA and substantially inhibits the use of views and functions for
security and database abstraction. Add OID invalidation for cached
plans into this and you have a bunch of developers taking their business
logic out of the database and putting it into middleware.

What would solve the issue for 90% of our users would be an ALTER TABLE
... CASCADE which would apply the changes to the table, and do a REPLACE
VIEW and REPLACE FUNCTION for every dependant view and function, failing
and rolling back if any REPLACE doesn't work automatically.

Incompatible table changes would still require manual drop and
recreation, of course. But most table changes to a production database
are adding fields or changing constraints, which in most cases won't
break dependant views or functions.

--
Josh Berkus
PostgreSQL Experts Inc.
www.pgexperts.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2009-05-05 18:20:00 Re: community equipment
Previous Message Emmanuel Cecchet 2009-05-05 18:03:18 Re: Wrong stats for empty tables