X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id D7B7CD1B4FE for ; Tue, 4 Nov 2003 22:49:04 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 98271-08 for ; Tue, 4 Nov 2003 18:48:35 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 8D29CD1B4EF for ; Tue, 4 Nov 2003 18:48:32 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hA4MmY19026588; Tue, 4 Nov 2003 17:48:34 -0500 (EST) To: Jamie Lawrence Cc: pgsql-sql@postgresql.org Subject: Re: Problems with NEW.* in triggers In-reply-to: <20031104223319.GA2879@clueinc.net> References: <20031104223319.GA2879@clueinc.net> Comments: In-reply-to Jamie Lawrence message dated "Tue, 04 Nov 2003 17:33:19 -0500" Date: Tue, 04 Nov 2003 17:48:34 -0500 Message-ID: <26587.1067986114@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/21 X-Sequence-Number: 15836 Jamie Lawrence writes: > I had thought that if moddate isn't included in an insert or update, > that it would be null in the NEW context, No, it would be whatever the value to be assigned to the column would be, if the trigger were not present. In particular, during an UPDATE it's going to contain the old value of the field. In an INSERT it would be whatever the column's default value is. I am not sure what your intention is here. If you want the trigger to force the field to current time, it can certainly do that. If you want the user to control whether the field is updated, why do you need a trigger at all? regards, tom lane