| From: | Chris Browne <cbbrowne(at)acm(dot)org> | 
|---|---|
| To: | pgsql-hackers(at)postgresql(dot)org | 
| Subject: | Re: conditional dropping of columns/constraints | 
| Date: | 2009-05-04 19:21:10 | 
| Message-ID: | 874ow0ekt5.fsf@dba2.int.libertyrms.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
robertmhaas(at)gmail(dot)com (Robert Haas) writes:
> On Mon, May 4, 2009 at 10:10 AM, Andres Freund <andres(at)anarazel(dot)de> wrote:
>> Would a patch adding 'IF EXISTS' support to:
>> - ALTER TABLE ... DROP COLUMN
>> - ALTER TABLE ... DROP CONSTRAINT
>> possibly be accepted?
>>
>> Having it makes the annoying task of writing/testing of schema-upgrade
>> scripts a bit easier.
>
> Can't speak for the committers, but I've wished for this a time or two myself.
For constraints, it's easy enough to treat that as idempotent; it's no
big deal to drop and re-add a constraint.
For columns, I'd *much* more frequently be interested in
   ALTER TABLE ... ADD COLUMN IF NOT EXISTS ...
Note that this is distinctly NOT the same as:
   ALTER TABLE ... DROP COLUMN IF EXISTS ...
   ALTER TABLE ... ADD COLUMN ...
-- 
(format nil "~S(at)~S" "cbbrowne" "linuxdatabases.info")
http://linuxdatabases.info/info/lisp.html
Signs of a Klingon Programmer -  10. "A TRUE  Klingon Warrior does not
comment his code!"
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Archana Sundararam | 2009-05-04 20:11:22 | ALTER TABLE should change respective views | 
| Previous Message | K, Niranjan (NSN - IN/Bangalore) | 2009-05-04 17:37:01 | Synchronous replication: Admin command for replication_timeout_action |