X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4A06C3A3D85 for ; Mon, 3 Jan 2005 18:36:36 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 76218-10 for ; Mon, 3 Jan 2005 18:36:04 +0000 (GMT) Received: from laptop.kieser.net (kieser2.demon.co.uk [80.176.229.121]) by svr1.postgresql.org (Postfix) with ESMTP id 99F2C3A3D77 for ; Mon, 3 Jan 2005 18:29:36 +0000 (GMT) Received: from [127.0.0.1] (laptop.kieser2.demon.co.uk [127.0.0.1]) by laptop.kieser.net (Postfix) with ESMTP id E7A3B18330; Mon, 3 Jan 2005 18:29:56 +0000 (GMT) Message-ID: <41D98F24.3090208@kieser.net> Date: Mon, 03 Jan 2005 18:29:56 +0000 From: Bradley Kieser User-Agent: Mozilla Thunderbird 0.8 (X11/20040913) X-Accept-Language: en, en-us MIME-Version: 1.0 To: Tom Lane Cc: PgSQL ADMIN Subject: Re: Rules on a view overwrite default values. Any way to References: <41D97A9C.6050401@kieser.net> <24511.1104773538@sss.pgh.pa.us> In-Reply-To: <24511.1104773538@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.331 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200501/15 X-Sequence-Number: 15874 Thanks Tom and Stephan! This works perfectly! Brad Tom Lane wrote: >Bradley Kieser writes: > > >>The problem is that rules on a view mean that the default values for NOT >>NULL columns (used extensively) no longer trigger! >> >> > >The way you're supposed to fix this is to attach default values to the >view itself. > >ALTER TABLE myview ALTER COLUMN updated_time SET DEFAULT now(); > >Now an INSERT on myview will include the correct expression before view >expansion happens. > >I'm not sure how long we've had this, but it's definitely in 7.4. > > regards, tom lane > > >