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 09A753A3AC7 for ; Tue, 23 Nov 2004 02:43:44 +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 71683-03 for ; Tue, 23 Nov 2004 02:43:31 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id AFD6F3A3AC2 for ; Tue, 23 Nov 2004 02:43:33 +0000 (GMT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.1/8.13.1) with ESMTP id iAN2hT78010246 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 22 Nov 2004 19:43:32 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.1/8.13.1) with ESMTP id iAN2hTqZ022346; Mon, 22 Nov 2004 19:43:29 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.1/8.13.1/Submit) id iAN2hTBa022345; Mon, 22 Nov 2004 19:43:29 -0700 (MST) (envelope-from mfuhr) Date: Mon, 22 Nov 2004 19:43:29 -0700 From: Michael Fuhr To: Greg Sabino Mullane Cc: pgsql-admin@postgresql.org, dicroce@pelco.com Subject: Re: Stamping rows... Message-ID: <20041123024329.GA22271@winnie.fuhr.org> References: <20d7d6be8697b20a7ba8a1b09cbff757@biglumber.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20d7d6be8697b20a7ba8a1b09cbff757@biglumber.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/168 X-Sequence-Number: 15552 On Tue, Nov 23, 2004 at 02:14:52AM -0000, Greg Sabino Mullane wrote: > CREATE OR REPLACE FUNCTION update_mtime() RETURNS TRIGGER LANGUAGE PLPGSQL AS > 'BEGIN NEW.mtime = now(); RETURN NEW; END;'; > > CREATE TRIGGER people_update_mtime BEFORE UPDATE ON people > FOR EACH ROW EXECUTE PROCEDURE update_mtime(); > > (I use a version of this for my incremental backup scheme) > > Now every update (or insert) will cause all the rows changed to have the > same unique value. Since now() doesn't advance during a transaction, every other update or insert in the same transaction will get the same "unique" value even if they were performed as separate statements; that may or may not meet the requirements for uniqueness. It also assumes that no two transactions will ever start at exactly the same time. -- Michael Fuhr http://www.fuhr.org/~mfuhr/