X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 8067C9FA6AF for ; Wed, 2 Aug 2006 13:37:15 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 69455-01 for ; Wed, 2 Aug 2006 13:37:05 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 1B31F9FA6B0 for ; Wed, 2 Aug 2006 13:37:04 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k72Gb0te018064; Wed, 2 Aug 2006 12:37:00 -0400 (EDT) To: Rod Taylor cc: Markus Bertheau , pgsql-sql@postgresql.org Subject: Re: alter column type from boolean to char with default In-reply-to: <1154526983.29712.223.camel@home> References: <684362e10608020546t16e6d3e8nf6756abd15a21a68@mail.gmail.com> <15041.1154524770@sss.pgh.pa.us> <1154526983.29712.223.camel@home> Comments: In-reply-to Rod Taylor message dated "Wed, 02 Aug 2006 09:56:23 -0400" Date: Wed, 02 Aug 2006 12:36:59 -0400 Message-ID: <18063.1154536619@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.175 tagged_above=0 required=5 tests=AWL, SPF_HELO_PASS, SPF_PASS X-Spam-Level: X-Archive-Number: 200608/18 X-Sequence-Number: 25976 Rod Taylor writes: > On Wed, 2006-08-02 at 09:19 -0400, Tom Lane wrote: >> Hmm ... the way I would have expected to work is >> >> alter table posts >> alter column deleted drop default, >> alter column deleted type char(1) >> using (case when deleted then 't' else 'f' end), >> alter column deleted set default 'f'; > Perhaps it is easiest to allow the user to specify the new default after > USING? He already did --- I don't want to add some random new syntax for this. Maybe we could hack things so that if both an ALTER TYPE and a SET DEFAULT operation are present, we implicitly add a DROP DEFAULT at the start. But leave the timing of any explicitly specified DROP DEFAULT as-is. regards, tom lane